From bac184b8e231607913e05051226a2a78c80ea0b3 Mon Sep 17 00:00:00 2001 From: VectorNguyen Date: Tue, 17 Nov 2026 22:26:29 +0700 Subject: [PATCH] chore(fe): don ghi chu man hinh, vai tro Khach hang, hotline chu thuong; fix huy don PayOS het gio va loi dat lai mat khau (D63) --- DECISIONS.md | 10 ++++++ .../SafeSpace-Customer-UI/package.json | 2 +- .../SafeSpace-Customer-UI/src/app/App.jsx | 6 ++-- .../src/app/state/AppProvider.jsx | 31 ++++++++++++++----- .../src/app/state/appReducer.js | 4 +-- .../src/features/admin/api/adminApi.js | 2 +- .../components/AccountAssignmentCards.jsx | 4 +-- .../src/features/admin/demo/DoorLogPage.jsx | 2 +- .../admin/permissions/PermissionListPage.jsx | 2 +- .../src/features/auth/PasswordResetPage.jsx | 5 +-- .../src/features/auth/api/passwordResetApi.js | 8 ++--- .../auth/components/ForgotPasswordDialog.jsx | 2 +- .../src/features/business/api/businessApi.js | 2 +- .../business/policies/PolicyStatusPage.jsx | 2 +- .../policies/RentalPolicyEditorPage.jsx | 10 +++--- .../business/policies/policyActions.js | 3 +- .../business/policies/policyFields.js | 4 +-- .../business/reports/BusinessReportPage.jsx | 4 +-- .../reports/FacilityReportDetailPage.jsx | 6 ++-- .../customer/access/AccessQrModal.jsx | 2 +- .../customer/contracts/ContractPaperPage.jsx | 2 +- .../customer/contracts/RenewalRequestPage.jsx | 1 - .../contracts/RenewalUnitChangePage.jsx | 6 ++-- .../contracts/RentedUnitDetailPage.jsx | 4 +-- .../contracts/ReturnDeductionPage.jsx | 2 +- .../customer/contracts/ReturnProgressPage.jsx | 2 +- .../customer/contracts/ReturnRequestPage.jsx | 1 - .../customer/contracts/UnitChangePage.jsx | 2 +- .../components/CancelRenewalButton.jsx | 4 +-- .../customer/contracts/renewalUnitModel.js | 2 +- .../customer/payments/CashRefundPage.jsx | 2 +- .../customer/payments/CheckoutPage.jsx | 2 +- .../customer/payments/PaymentListPage.jsx | 2 +- .../customer/payments/PaymentStatusPage.jsx | 2 +- .../payments/ReservationReviewPage.jsx | 5 ++- .../customer/policies/RentalPolicyPage.jsx | 8 ++--- .../reservations/CancelReservationPage.jsx | 1 - .../FacilityOperationsLayout.jsx | 2 +- .../api/facilityOperationsApi.js | 2 +- .../incidents/IncidentComponents.jsx | 2 +- .../incidents/incidentApi.js | 2 +- .../settlements/SettlementComponents.jsx | 1 - .../settlements/settlementModel.js | 6 ++-- .../state/FacilityOperationsProvider.jsx | 6 ++-- .../state/facilityOperationsReducer.js | 2 +- .../workflows/WorkflowComponents.jsx | 2 +- .../workflows/useOpsEndpoint.js | 4 +-- .../workflows/workflowApi.js | 4 +-- .../manager/contracts/ContractListPage.jsx | 2 +- .../refunds/CancellationRefundPage.jsx | 2 +- .../manager/refunds/DepositRefundPage.jsx | 4 +-- .../manager/renewals/RenewalApprovalPage.jsx | 3 +- .../manager/reports/DailyStaffReportPage.jsx | 2 +- .../manager/reports/FacilityReportPage.jsx | 2 +- .../manager/units/UnitManagementPage.jsx | 8 ++--- .../handovers/CustomerVerificationPage.jsx | 3 +- .../features/staff/keys/KeyReceiptPage.jsx | 5 ++- .../staff/payments/RenewalCollectionPage.jsx | 2 +- .../staff/returns/OldUnitInspectionPage.jsx | 2 +- .../staff/returns/ReturnInspectionPage.jsx | 5 ++- .../staff/returns/ReturnRecheckPage.jsx | 3 +- .../src/shared/api/httpClient.js | 2 +- .../src/shared/api/paymentStatus.js | 17 ++++++++++ .../src/shared/api/refundRequestApi.js | 4 +-- .../src/shared/api/renewalConsentApi.js | 2 +- .../src/shared/api/reservationConsentApi.js | 2 +- .../src/shared/components/Header.jsx | 4 ++- .../src/shared/components/PublicFooter.jsx | 2 +- .../src/shared/styles/ss.css | 5 +-- .../src/shared/utils/rentalPolicy.js | 4 +-- .../src/shared/utils/status.js | 2 +- .../tests/admin-business-batch09.test.js | 2 +- .../tests/approved-workflows.test.js | 2 +- .../tests/auth-support-integration.test.js | 2 +- .../tests/incident-workflow.test.js | 2 +- .../tests/ops-api.test.mjs | 4 +-- .../SafeSpace-Customer-UI/tests/ops.test.js | 4 +-- .../tests/payment-status.test.js | 29 +++++++++++++++++ .../tests/reducer.test.js | 4 +-- .../tests/render.test.mjs | 2 +- .../tests/settlement-batch08.test.js | 2 +- .../Services/CustomerEmailDelivery.cs | 4 +-- .../Services/PayOSService.cs | 3 +- .../CheckoutTests.Reconcile.cs | 11 +++++++ progress.md | 8 +++++ 85 files changed, 220 insertions(+), 138 deletions(-) create mode 100644 SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/api/paymentStatus.js create mode 100644 SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/payment-status.test.js diff --git a/DECISIONS.md b/DECISIONS.md index c588f16..f5de6f4 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -721,3 +721,13 @@ Bổ sung @playwright/test trong devDependencies để kiểm thao tác biểu m - Khách đã chọn một ô cụ thể trên sơ đồ mà ô đó đang thuê / đang giữ: ô **Ngày bắt đầu** chỉ cho chọn từ ngày ô trống lại (`free_from` = hết hạn đơn trước + ngày đệm). Các ngày trước đó vẫn hiện trên lịch nhưng **làm mờ, không bấm được**; ngày đang chọn tự dời tới ngày sớm nhất hợp lệ. Dưới lịch ghi "Ô … đang có người thuê đến … · chọn được ngày bắt đầu từ …". - Ở chế độ đặt đúng ô **không hiện hộp đỏ "Không còn ô trống cho cả kỳ thuê"** và nút đặt không bị khoá vì số ô trống theo loại kho; chỉ xét chính ô đã chọn. Hộp này vẫn giữ cho chế độ tự bố trí. - Ô quá hạn trả (không có `free_from`) giữ như cũ: không nhận đặt trước, hiện lý do. + +## D63 — 17/11/2026: Dọn ghi chú màn hình, vai trò dưới tên khách, hotline chữ thường — Đã chốt + +> Vector chốt ngày 17/11/2026. Bổ sung D32 (mục Giao diện: "màn không ghi mã nội bộ") và D50 (#1 hotline, #23 bỏ quản lý duyệt gia hạn); giữ nguyên lịch sử ở trên. Không đổi API, không đổi database (D48). + +- **Ghi chú trên màn hình viết cho người dùng, không viết cho dev:** bỏ hoặc viết lại câu nhắc lệnh chạy, biến môi trường, đường dẫn API, "backend", "máy chủ chưa hỗ trợ…", mã quyết định (D32) và các câu giải thích cách hệ thống tính. Thông báo lỗi giữ hướng dẫn cho người dùng ("Vui lòng thử lại sau", "Tải lại trước khi gửi tiếp"). +- **Chế độ thử nghiệm (mock/offline):** giữ một dải báo chung ở đầu trang ("Chế độ thử nghiệm · Dữ liệu mẫu, không thanh toán hoặc chuyển tiền thật.") để người kiểm thử nhận biết (AGENTS.md mục 5); bỏ các ghi chú "Chế độ mô phỏng FE" lặp lại trên từng màn. +- **Gia hạn (D50 #23):** chữ hiển thị không còn "chờ quản lý duyệt" / "cơ sở duyệt và chốt giá"; dùng "chờ xác nhận" / "đã được xác nhận". +- **Màn khách hàng:** dưới họ tên trên thanh đầu trang hiện vai trò "Khách hàng" (giống thẻ vai trò của nhân viên, quản lý, admin). +- **Hotline ở chân trang** hiện chữ thường cùng màu các dòng khác, không còn là liên kết `tel:`. Số hotline giữ theo D50. diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/package.json b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/package.json index 8ed8083..00e94ba 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/package.json +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/package.json @@ -10,7 +10,7 @@ "dev": "vite --host 127.0.0.1", "build": "vite build --base=./", "preview": "vite preview --host 127.0.0.1", - "test": "node --test tests/patch13.test.js tests/contract-paper.test.js tests/refund-request.test.js tests/renewal-consent.test.js tests/figma-batch04.test.js tests/reservation-policy.test.js tests/damage-workflow.test.js tests/incident-workflow.test.js tests/settlement-batch08.test.js tests/admin-business-batch09.test.js tests/return-policy.test.js tests/reducer.test.js tests/api-mappers.test.js tests/admin.test.js tests/ops.test.js tests/units.test.js tests/ops-api.test.mjs tests/payment-access.test.js tests/payment-api.test.mjs tests/access.test.js tests/figma-workflow.test.js tests/auth-support-integration.test.js tests/renewal-unit-move.test.js tests/luot1-ui.test.js tests/luot2-settlement.test.js tests/luot3-renewal.test.js tests/luot4-units.test.js tests/luot4b-nav.test.js tests/luot5-reports.test.js tests/luot6-door-demo.test.mjs tests/qr-reader.test.js tests/admin-logs.test.js", + "test": "node --test tests/patch13.test.js tests/contract-paper.test.js tests/refund-request.test.js tests/renewal-consent.test.js tests/figma-batch04.test.js tests/reservation-policy.test.js tests/damage-workflow.test.js tests/incident-workflow.test.js tests/settlement-batch08.test.js tests/admin-business-batch09.test.js tests/return-policy.test.js tests/reducer.test.js tests/api-mappers.test.js tests/admin.test.js tests/ops.test.js tests/units.test.js tests/ops-api.test.mjs tests/payment-access.test.js tests/payment-api.test.mjs tests/payment-status.test.js tests/access.test.js tests/figma-workflow.test.js tests/auth-support-integration.test.js tests/renewal-unit-move.test.js tests/luot1-ui.test.js tests/luot2-settlement.test.js tests/luot3-renewal.test.js tests/luot4-units.test.js tests/luot4b-nav.test.js tests/luot5-reports.test.js tests/luot6-door-demo.test.mjs tests/qr-reader.test.js tests/admin-logs.test.js", "test:render": "node tests/render.test.mjs", "dev:mock": "node scripts/dev-mock.mjs", "check:structure": "node scripts/check-structure.mjs", diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx index 373f04c..d7b09be 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx @@ -177,7 +177,7 @@ function Shell() { }, [isAdmin, isOps, businessAllowed, roles, route.page]); const businessBody = mode !== "api" ? ( -
+
) : authed && !businessAllowed ? (
Về tổng quan
) : null; @@ -185,7 +185,7 @@ function Shell() { const adminBody = mode !== "api" ? (
- + Về trang chủ
@@ -201,7 +201,7 @@ function Shell() {
{ e.preventDefault(); document.getElementById("main")?.focus(); }}>Chuyển đến nội dung {!(isAdminPage && !adminBody && authed) && !(isOpsPage && authed && opsAllowed) && !(isBusinessPage && !businessBody && authed) &&
} - {(WORKFLOW_DEMO || mode === "local") &&

MÔ PHỎNG FE · Dữ liệu thử nghiệm, không thanh toán / chuyển tiền thật.

} + {(WORKFLOW_DEMO || mode === "local") &&

Chế độ thử nghiệm · Dữ liệu mẫu, không thanh toán hoặc chuyển tiền thật.

} {/* Khu khách hàng: đổi key theo đường dẫn để mỗi trang dựng lại. Khu Nhân viên/Quản lý/Vận hành KD/Quản trị: giữ key theo khu để header, menu và dữ liệu vận hành không bị dựng lại (mất dữ liệu → hiện "Đang tải…" → giật) mỗi lần bấm; nội dung từng trang dựng lại trong *Routes. */} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx index fb3d869..64123aa 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/AppProvider.jsx @@ -17,6 +17,7 @@ import { submitCancellation, submitReturnRequest } from "../../shared/api/refund import { readPhotoData, verifyPhotoFile } from "../../shared/utils/refundRequest.js"; import { submitRenewalWithConsent } from "../../shared/api/renewalConsentApi.js"; import { api } from "../../shared/api/customerApi.js"; +import { paidBeforeExpiry } from "../../shared/api/paymentStatus.js"; import { ApiError, setToken } from "../../shared/api/httpClient.js"; import { isUnsupported, localAccessCode, normAccess, normCancelPreview, normDoor, normPayos, normScan } from "../../features/customer/access/accessApi.js"; import { notYetMessage } from "../../shared/utils/access.js"; @@ -312,6 +313,7 @@ const EMPTY_REMOTE = { reservations: [], reservationDetails: {}, contracts: [], const fail = (error, code) => ({ ok: false, error, code }); const readOverlay = (userId) => ({ ...emptyOverlay(), ...(readJson(overlayKey(userId)) || {}) }); + function ApiProvider({ children }) { const [session, setSession] = useState(() => { const s = readSession(); @@ -479,10 +481,11 @@ function ApiProvider({ children }) { if (cancelling.current.has(r.reservationId)) continue; cancelling.current.add(r.reservationId); const seconds = refs.current.overlay.holds[r.reservationId] ? paymentTimeoutSeconds : 24 * 3600; - api - .cancelReservation(r.reservationId, `Quá ${timeoutLabel(seconds)} chưa thanh toán`) - .catch(() => {}) - .then(() => loadCustomer().catch(() => {})); + paidBeforeExpiry(r.reservationId).then(async (paid) => { + if (paid === false) await api.cancelReservation(r.reservationId, `Quá ${timeoutLabel(seconds)} chưa thanh toán`).catch(() => {}); + else if (paid === null) cancelling.current.delete(r.reservationId); + await loadCustomer().catch(() => {}); + }); } }; const id = setInterval(tick, 5000); @@ -661,8 +664,14 @@ function ApiProvider({ children }) { const r = d.reservations.find((x) => x.reservation_id === p.reservation_id); if (!r) return fail("Không tìm thấy đơn đặt chỗ.", "NOT_FOUND"); if (!r.transfer_confirmed_at && ["PENDING_PAYMENT", "CANCELLED"].includes(r.status)) { + // Khách có thể vừa trả tiền ở những giây cuối: hỏi máy chủ trước khi huỷ. + const paid = cancelling.current.has(r.api_id) ? false : await paidBeforeExpiry(r.api_id); + if (paid) { + await loadCustomer().catch(() => {}); + return { ok: true, status: "PAID" }; + } updateOverlay((o) => ({ ...o, expired: { ...o.expired, [r.api_id]: Date.now() } })); - if (!cancelling.current.has(r.api_id)) { + if (paid === false && !cancelling.current.has(r.api_id)) { cancelling.current.add(r.api_id); api .cancelReservation(r.api_id, `Quá ${timeoutLabel(r.timeout_seconds || paymentTimeoutSeconds)} chưa thanh toán`) @@ -694,7 +703,7 @@ function ApiProvider({ children }) { const { dto, acknowledged } = await submitRenewalWithConsent(api, c.api_id, months, p.policy_consent); if (!acknowledged) { await loadCustomer(); - return fail("Máy chủ đã nhận gia hạn nhưng chưa xác nhận bằng chứng đồng ý. Kiểm tra Theo dõi gia hạn hoặc liên hệ cơ sở trước khi gửi lại."); + return fail("Đã gửi gia hạn nhưng chưa ghi nhận được xác nhận đồng ý chính sách. Kiểm tra Theo dõi gia hạn trước khi gửi lại."); } remember("Gia hạn đã được xác nhận", `Kho ${c.unit_number} · mở thanh toán để kéo dài hợp đồng.`, "payments", `Gia hạn ${c.unit_number} đã xác nhận — chờ thanh toán`); await loadCustomer(); @@ -703,7 +712,7 @@ function ApiProvider({ children }) { case "CANCEL_RENEWAL": { const r = d.renewals.find((x) => x.renewal_id === p.renewal_id); if (!r) return fail("Không tìm thấy yêu cầu gia hạn.", "NOT_FOUND"); - if (r.status !== "PENDING") return fail("Chỉ huỷ được yêu cầu gia hạn đang chờ quản lý duyệt."); + if (r.status !== "PENDING") return fail("Chỉ huỷ được yêu cầu gia hạn đang chờ xác nhận."); await api.cancelRenewal(r.api_id); const c = d.contracts.find((x) => x.contract_id === r.contract_id); remember("Đã huỷ yêu cầu gia hạn", `${r.renewal_id} · Kho ${c?.unit_number ?? ""}`.trim(), `units/${r.contract_id}`, `Yêu cầu gia hạn ${r.renewal_id} đã huỷ`); @@ -796,7 +805,7 @@ function ApiProvider({ children }) { // C11fc: backend chưa có API chọn trả phí tại quầy → ghi trong trình duyệt; nhân viên thu ở S09f case "CHOOSE_RENEWAL_AT_COUNTER": { const renewal = d.renewals.find(x => x.renewal_id === p.renewal_id); - if (!renewal || renewal.status !== "APPROVED") return fail("Yêu cầu chưa được duyệt hoặc đã thanh toán."); + if (!renewal || renewal.status !== "APPROVED") return fail("Yêu cầu chưa được xác nhận hoặc đã thanh toán."); await api.chooseRenewalCounter(renewal.api_id); await loadCustomer(); return { ok: true }; @@ -871,6 +880,12 @@ function ApiProvider({ children }) { if (paid) await loadCustomer().catch(() => {}); return { ok: true, paid }; } + // /status nhờ máy chủ đối soát thẳng với PayOS (khi chạy máy cá nhân webhook không về được). + const quick = await api.reservationStatus(item.api_id).catch(() => null); + if (quick?.isPaid) { + await loadCustomer().catch(() => {}); + return { ok: true, paid: true, cancelled: false }; + } const r = await api.reservation(item.api_id); const status = String(r?.status || ""); const paid = ["PAID", "CONFIRMED", "UNIT_ASSIGNED", "CHECKED_IN", "COMPLETED"].includes(status); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js index a831a1b..e68e190 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/state/appReducer.js @@ -328,7 +328,7 @@ const handlers = { CANCEL_RENEWAL(state, p, ctx) { const r = state.renewals.find((x) => x.renewal_id === p.renewal_id); if (!r) fail("Không tìm thấy yêu cầu gia hạn.", "NOT_FOUND"); - if (r.status !== "PENDING") fail("Chỉ huỷ được yêu cầu gia hạn đang chờ quản lý duyệt."); + if (r.status !== "PENDING") fail("Chỉ huỷ được yêu cầu gia hạn đang chờ xác nhận."); let next = { ...state, renewals: state.renewals.map((x) => (x.renewal_id === r.renewal_id ? { ...x, status: "CANCELLED", cancelled_at: iso(ctx.now) } : x)), @@ -392,7 +392,7 @@ const handlers = { if (!c || ["ENDED", "RETURN_PENDING"].includes(c.status) || c.start_date > localDate(ctx.now)) fail("Hợp đồng chưa thể đăng ký trả kho."); const pending = hasPending(state, c.contract_id); if (state.returns.some(r => r.contract_id === c.contract_id && !["CANCELLED", "REJECTED"].includes(r.status))) fail("Đã có yêu cầu trả kho đang chờ xử lý."); - if (pending.renewal) fail("Hợp đồng đang có yêu cầu gia hạn chờ duyệt."); + if (pending.renewal) fail("Hợp đồng đang có yêu cầu gia hạn chờ xử lý."); const dateError = visitDateError(p.date, c.end_date, localDate(ctx.now), "trả kho", c.start_date); if (dateError) fail(dateError); const invalid = validateRefundChoice(p.bank, c.customer_name || state.user?.full_name); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/api/adminApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/api/adminApi.js index 671f35d..f6243f2 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/api/adminApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/api/adminApi.js @@ -70,7 +70,7 @@ export const adminApi = { // Gán một vai trò cho người dùng (POST /api/admin/users/{userId}/roles) // Đề xuất atomic replacement; không fallback assign rồi revoke. - changeRole: async(userId,body)=>{try{return await request(`/api/admin/users/${userId}/role-change`,{method:"POST",body});}catch(error){if([404,405].includes(error.status))throw new ApiError("Máy chủ chưa hỗ trợ đổi vai trò trong một thao tác. Chưa đổi vai trò; không gán rồi gỡ thay thế.",error.status);throw error;}}, + changeRole: async(userId,body)=>{try{return await request(`/api/admin/users/${userId}/role-change`,{method:"POST",body});}catch(error){if([404,405].includes(error.status))throw new ApiError("Chưa đổi được vai trò. Vui lòng thử lại sau.",error.status);throw error;}}, assignRole: (userId, roleId) => request(`/api/admin/users/${userId}/roles`, { method: "POST", body: { roleId } }), // Thu hồi một vai trò khỏi người dùng (DELETE /api/admin/users/{userId}/roles/{roleId}) diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/components/AccountAssignmentCards.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/components/AccountAssignmentCards.jsx index 6daa105..02816a2 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/components/AccountAssignmentCards.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/components/AccountAssignmentCards.jsx @@ -26,7 +26,7 @@ export function RolesCard({user,allRoles,onSaved}) { const run=async(kind,roleId)=>{if(guard.current||refresh)return;guard.current=true;setBusy(true);const role=allRoles.find(r=>String(r.roleId)===String(roleId));const out=await change({action:kind==="change"?"Đổi vai trò":kind==="revoke"?"Gỡ vai trò":"Cấp lại vai trò",scope:user.fullName,content:roleLabel(role?.roleName),danger:kind==="revoke",perform:()=>roleActionChecked(adminApi,user,kind,roleId,from)});setBusy(false);guard.current=false;if(out.error){onApiError(out.error);if(out.uncertain)setRefresh(true);}if(out.ok){setPanel(null);onSaved();}}; useEffect(()=>{if(!user.roles.some(r=>String(r.roleId)===from))setFrom(user.roles.length===1?String(user.roles[0].roleId):"");},[user.roles,from]); const owned=new Set(user.roles.map(r=>String(r.roleId))); - return

Vai trò & quyền

{user.roles.map(r=>{roleLabel(r.roleName)})}{!user.roles.length&&

Chưa có vai trò.

}

Quyền của vai trò được định nghĩa sẵn; không chỉnh sửa tại đây. Máy chủ kiểm tra quản trị viên hoạt động cuối cùng và phạm vi cơ sở.

{user.roles.length>1&&}
Xem quyền theo vai trò
{refresh&&Tải lại tài khoản trước khi gửi tiếp.}{panel&&({id:r.roleId,label:roleLabel(r.roleName),description:ROLE_SCOPE[r.roleName],disabled:owned.has(String(r.roleId))}))} onClose={()=>setPanel(null)} onSelect={id=>run(panel,id)} confirmLabel={panel==="change"?"Kiểm tra & đổi vai trò":"Kiểm tra & cấp lại"} disabled={busy||refresh}/>} {flow}
; + return

Vai trò & quyền

{user.roles.map(r=>{roleLabel(r.roleName)})}{!user.roles.length&&

Chưa có vai trò.

}

Quyền của vai trò được định nghĩa sẵn, không chỉnh sửa tại đây.

{user.roles.length>1&&}
Xem quyền theo vai trò
{refresh&&Tải lại tài khoản trước khi gửi tiếp.}{panel&&({id:r.roleId,label:roleLabel(r.roleName),description:ROLE_SCOPE[r.roleName],disabled:owned.has(String(r.roleId))}))} onClose={()=>setPanel(null)} onSelect={id=>run(panel,id)} confirmLabel={panel==="change"?"Kiểm tra & đổi vai trò":"Kiểm tra & cấp lại"} disabled={busy||refresh}/>} {flow}
; } /** * Thẻ quản lý phân công cơ sở phụ trách (A06). @@ -36,5 +36,5 @@ export function FacilityCard({user,facilities,rows,onSaved}) { const {onApiError}=useApp(),[selected,setSelected]=useState(""),[open,setOpen]=useState(false),[from,setFrom]=useState(today()),[busy,setBusy]=useState(false),[error,setError]=useState(""),[refresh,setRefresh]=useState(false),guard=useRef(false),[flow,change]=useChangeFlow(); const permitted=needsFacility(user.roles.map(r=>r.roleName)),options=facilities.filter(f=>f.status==="ACTIVE"),current=rows.find(r=>r.status==="ACTIVE"); const run=async(perform,action,content)=>{if(guard.current||refresh)return;guard.current=true;setBusy(true);const out=await change({action,scope:user.fullName,content,perform});setBusy(false);guard.current=false;if(out.error){onApiError(out.error);setError(out.error.message);if(out.uncertain)setRefresh(true);}if(out.ok)onSaved();}; - return

Cơ sở phụ trách

{current?`Đang phụ trách ${current.facilityName} từ ${dateOnlyLabel(current.assignedFrom)}.`:"Chưa được phân công cơ sở."}

Mỗi nhân viên/quản lý phụ trách một cơ sở tại một thời điểm. Phân công mới cần được máy chủ xác nhận.

{permitted&&<>setFrom(e.target.value)}/>}{!permitted&&Vai trò hiện tại không cần cơ sở phụ trách. Lịch sử được giữ để đối chiếu.}{rows.map(r=>
{r.facilityName}

{dateOnlyLabel(r.assignedFrom)} – {r.assignedTo?dateOnlyLabel(r.assignedTo):"nay"} · {r.status}

{permitted&&["ACTIVE","SUSPENDED"].includes(r.status)&&}{r.status!=="ENDED"&&}
)}{error&&{error}}{refresh&&}{open&&({id:f.facilityId,label:f.name}))} value={selected} onClose={()=>setOpen(false)} onSelect={id=>{setSelected(id);setOpen(false);}} confirmLabel="Dùng cơ sở này"/>}{flow}
; + return

Cơ sở phụ trách

{current?`Đang phụ trách ${current.facilityName} từ ${dateOnlyLabel(current.assignedFrom)}.`:"Chưa được phân công cơ sở."}

Mỗi nhân viên/quản lý phụ trách một cơ sở tại một thời điểm.

{permitted&&<>setFrom(e.target.value)}/>}{!permitted&&Vai trò hiện tại không cần cơ sở phụ trách. Lịch sử được giữ để đối chiếu.}{rows.map(r=>
{r.facilityName}

{dateOnlyLabel(r.assignedFrom)} – {r.assignedTo?dateOnlyLabel(r.assignedTo):"nay"} · {r.status}

{permitted&&["ACTIVE","SUSPENDED"].includes(r.status)&&}{r.status!=="ENDED"&&}
)}{error&&{error}}{refresh&&}{open&&({id:f.facilityId,label:f.name}))} value={selected} onClose={()=>setOpen(false)} onSelect={id=>{setSelected(id);setOpen(false);}} confirmLabel="Dùng cơ sở này"/>}{flow}
; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/DoorLogPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/DoorLogPage.jsx index 2be05e0..0e249d1 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/DoorLogPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/demo/DoorLogPage.jsx @@ -36,7 +36,7 @@ export default function DoorLogPage() { const isToday = filter.from === today() && filter.to === today(); return (
- + {isToday ? "Hôm nay" : `${dateLabel(filter.from)} – ${dateLabel(filter.to)}`} · {data.total} sự kiện
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/permissions/PermissionListPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/permissions/PermissionListPage.jsx index 2e21d68..ce552e1 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/permissions/PermissionListPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/permissions/PermissionListPage.jsx @@ -12,7 +12,7 @@ import {useLoad} from "../utils/adminUtils.js"; import {useApp} from "../../../app/state/AppProvider.jsx"; import {Button,Empty,Notice,PageHeader} from "../../../shared/components/UI.jsx"; import {ROLE_SCOPE,roleLabel,sortRoles} from "../../../shared/utils/roles.js"; -const descriptions={CUSTOMER:"Đặt kho, thanh toán, quản lý hợp đồng và gửi hỗ trợ",STAFF:"Thu tiền tại kho, xác minh, giao chìa khóa, kiểm tra và hỗ trợ khách",MANAGER:"Phân bổ kho, phân công, duyệt gia hạn và xử lý hoàn tiền",OPERATIONS:"Quản lý cơ sở, giá thuê, chính sách và báo cáo",ADMIN:"Quản lý tài khoản, gán vai trò, cơ sở phụ trách và xem nhật ký"}; +const descriptions={CUSTOMER:"Đặt kho, thanh toán, quản lý hợp đồng và gửi hỗ trợ",STAFF:"Thu tiền tại kho, xác minh, giao chìa khóa, kiểm tra và hỗ trợ khách",MANAGER:"Quản lý ô kho, hợp đồng, quá hạn, sự cố và hoàn tiền",OPERATIONS:"Quản lý cơ sở, giá thuê, chính sách và báo cáo",ADMIN:"Quản lý tài khoản, gán vai trò, cơ sở phụ trách và xem nhật ký"}; /** * Bảng hiển thị ma trận vai trò, phạm vi dữ liệu và danh sách quyền hạn tương ứng. * @param {{ roles: Array }} props diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/PasswordResetPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/PasswordResetPage.jsx index 347f8f5..f9e6b99 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/PasswordResetPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/PasswordResetPage.jsx @@ -112,8 +112,9 @@ export function PasswordResetPage() { setPassword(""); setConfirm(""); setCode(""); setDemoCode(""); setStep("done"); } catch (ex) { - // Mã sai/hết hạn: quay lại bước nhập mã, giữ mật khẩu đã nhập. - if (ex.status === 400 || /mã/i.test(ex.message || "")) { setStep("code"); setErrors({ code: "Mã chưa đúng hoặc đã hết hạn. Nhập mã mới nhất hoặc bấm Gửi lại mã." }); } + // Mã sai/hết hạn: quay lại bước nhập mã. Lỗi về mật khẩu mới (trùng mật khẩu cũ…) hiện ngay ở ô mật khẩu. + if (/mã xác nhận/i.test(ex.message || "")) { setStep("code"); setErrors({ code: "Mã chưa đúng hoặc đã hết hạn. Nhập mã mới nhất hoặc bấm Gửi lại mã." }); } + else if (ex.status === 400 && /mật khẩu/i.test(ex.message || "")) setErrors({ password: ex.message }); else setErrors({ form: ex.message }); } finally { pending.current = false; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/api/passwordResetApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/api/passwordResetApi.js index 798a9d4..64ab684 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/api/passwordResetApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/api/passwordResetApi.js @@ -7,16 +7,16 @@ */ import { request } from "../../../shared/api/httpClient.js"; -async function call(path, body) { +async function call(path, body, unavailable) { try { return await request(path, { method: "POST", body, auth: false }); } catch (error) { if (error.status === 405 || (error.status === 404 && !error.data?.code && !error.data?.error)) { - throw new Error("Máy chủ chưa hỗ trợ đặt lại mật khẩu qua email. Vui lòng liên hệ quản trị viên."); + throw new Error(unavailable); } throw error; } } export const passwordResetApi = { - request: email => call("/api/auth/password-reset/request", { email }), - confirm: body => call("/api/auth/password-reset/confirm", body), + request: email => call("/api/auth/password-reset/request", { email }, "Chưa gửi được mã đặt lại mật khẩu. Vui lòng thử lại sau hoặc gọi hotline."), + confirm: body => call("/api/auth/password-reset/confirm", body, "Chưa đặt lại được mật khẩu. Vui lòng thử lại sau hoặc gọi hotline."), }; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/components/ForgotPasswordDialog.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/components/ForgotPasswordDialog.jsx index a6fddf7..4a153fa 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/components/ForgotPasswordDialog.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/auth/components/ForgotPasswordDialog.jsx @@ -13,7 +13,7 @@ import { Button, LinkButton, Modal } from "../../../shared/components/UI.jsx"; */ export function ForgotPassword({ onClose }) { return -

Mở biểu mẫu để nhận mã xác nhận qua email. Nếu máy chủ chưa hỗ trợ, liên hệ quản trị viên hoặc nhân viên cơ sở.

+

Nhận mã xác nhận qua email đã đăng ký để đặt mật khẩu mới.

Đặt lại mật khẩu
; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/api/businessApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/api/businessApi.js index dfdeb4b..5b828bd 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/api/businessApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/api/businessApi.js @@ -7,7 +7,7 @@ async function requestFile(path, { fallbackName = "bao-cao.csv" } = {}) { try { token = JSON.parse(localStorage.getItem('safespace.customer.session'))?.token; } catch { /* absent session */ } let res; try { res = await fetch(`${API_URL}${path}`, { headers: token ? { Authorization: `Bearer ${token}` } : {} }); } - catch { throw new ApiError('Không kết nối được máy chủ. Vui lòng kiểm tra địa chỉ API.', 0); } + catch { throw new ApiError('Không kết nối được máy chủ. Vui lòng thử lại.', 0); } if (!res.ok) { const data = await res.json().catch(() => ({})); throw new ApiError(data.error || data.message || `Không xuất được báo cáo (HTTP ${res.status}).`, res.status, data); } if(!res.headers.get("content-type")?.toLowerCase().includes("text/csv"))throw new Error("Máy chủ chưa trả tệp CSV hợp lệ. Chưa tải báo cáo."); return { blob: await res.blob(), fileName: fallbackName }; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/PolicyStatusPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/PolicyStatusPage.jsx index 57f7d4f..cfc2ec9 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/PolicyStatusPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/PolicyStatusPage.jsx @@ -41,7 +41,7 @@ export function PolicyStatusPage() { const content = isRemove ? "Chỉ xoá bản DRAFT chưa áp dụng." : isActivate - ? "Kích hoạt chính sách nháp để bắt đầu áp dụng vào hệ thống tính toán tự động." + ? "Kích hoạt bản nháp để bắt đầu áp dụng chính sách." : "Giữ lịch sử phiên bản và phạm vi chính sách hiện hành."; const out = await runChange({ diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/RentalPolicyEditorPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/RentalPolicyEditorPage.jsx index 6c96447..8d559c4 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/RentalPolicyEditorPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/RentalPolicyEditorPage.jsx @@ -81,7 +81,7 @@ export function RentalPolicyEditorPage() { {!valid && !draft ? ( - Máy chủ chưa cung cấp đầy đủ nội dung/phiên bản chính sách. Không dùng bản mặc định để công bố. + Chưa tải được đầy đủ nội dung chính sách. Vui lòng tải lại trước khi công bố. ) : ( @@ -112,22 +112,22 @@ export function RentalPolicyEditorPage() {

- Máy chủ cấp số phiên bản và thời điểm khi lưu. Công bố tạo phiên bản mới có hiệu lực ngay. + Công bố tạo phiên bản mới có hiệu lực ngay.

{draft && load.data?.version > draft.version && ( - Bản máy chủ đã thay đổi (người khác vừa công bố phiên bản mới). Nội dung bạn đang soạn vẫn được bảo lưu an toàn. + Vừa có người công bố phiên bản mới. Nội dung bạn đang soạn vẫn được giữ. )} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyActions.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyActions.js index e242e69..ce59894 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyActions.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyActions.js @@ -19,8 +19,7 @@ export async function activateWithConfirm(policy,ask){ try{await businessApi.activatePolicy(policy.policyId);return true;} catch(e){ if(!(e instanceof ApiError && e.status===409))throw e; - const ids=e.data?.details?.conflictingPolicyIds || []; - const ok=await ask({title:'Thay chính sách đang áp dụng?',message:`API báo xung đột chính sách ${POLICY_TYPES[policy.policyType]?.toLowerCase()||''} cùng loại và phạm vi${ids.length?` (mã ${ids.join(', ')})`:''}. Nếu xác nhận, các bản xung đột sẽ được thay thế theo quy tắc backend.`,actionLabel:'Thay chính sách'}); + const ok=await ask({title:'Thay chính sách đang áp dụng?',message:`Đang có chính sách ${POLICY_TYPES[policy.policyType]?.toLowerCase()||''} cùng loại và phạm vi áp dụng trong thời gian này. Nếu xác nhận, bản đang áp dụng sẽ được thay bằng bản này.`,actionLabel:'Thay chính sách'}); if(!ok)return false; await businessApi.activatePolicy(policy.policyId,true);return true; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js index 2bd73bf..1ead171 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/policies/policyFields.js @@ -11,7 +11,7 @@ export const ENGINE_SECTIONS = [ category: 'ENGINE', tone: 'green', badge: 'Tự động áp dụng', - description: 'Các tham số tự động thực thi trong tính tiền cọc, phí phạt quá hạn và số ngày đệm kho trống.', + description: 'Các mức dùng để tính tiền cọc, phí quá hạn và số ngày đệm giữa hai lượt thuê.', fields: [ { key: 'deposit', label: 'Mức đặt cọc mặc định', type: 'DEPOSIT', numeric: true, readOnly: true, suffix: '', hint: 'Cố định bằng 1 tháng tiền thuê toàn hệ thống.' }, { key: 'overdue', label: 'Tỷ lệ phí phạt quá hạn', type: 'OVERDUE', numeric: true, suffix: '% cọc / ngày', placeholder: '5', hint: 'Từ 0.01% đến 100% cọc ban đầu mỗi ngày trễ.' }, @@ -47,7 +47,7 @@ export const SYSTEM_ENFORCED_POLICIES = [ label: 'Hạn thanh toán yêu cầu gia hạn', value: '24 giờ kể từ khi duyệt', reference: 'D11/D32 · RenewalApproval', - description: 'Khách hàng có 24 giờ để thanh toán gia hạn sau khi yêu cầu được phê duyệt.', + description: 'Khách hàng có 24 giờ để thanh toán gia hạn sau khi gửi yêu cầu.', }, { key: 'penalty_cap', diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/BusinessReportPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/BusinessReportPage.jsx index 90e122b..5c27b9c 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/BusinessReportPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/BusinessReportPage.jsx @@ -165,7 +165,7 @@ export default function BusinessReportPage({ query }) {

Báo cáo hệ thống

-

Bộ lọc áp dụng cho thẻ tổng quan, cả hai biểu đồ, bảng chi tiết và file xuất. Số tiền hiển thị đầy đủ, không rút gọn.

+

Bộ lọc áp dụng cho toàn bộ báo cáo và file xuất.

{data && {(data.current.facilities || []).length} cơ sở}
@@ -184,7 +184,7 @@ export default function BusinessReportPage({ query }) {
+ footer={`Tổng ${trend.length} tháng: ${money(trendTotal(data.trend.months))}.${range.to === now.slice(0, 7) ? ` ${monthLabel(range.to)} tính đến ${now.split("-").reverse().join("/")}.` : ""}`} />
{ANALYSIS.map(([k, label]) => )}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/FacilityReportDetailPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/FacilityReportDetailPage.jsx index d5fce87..8317f4d 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/FacilityReportDetailPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/reports/FacilityReportDetailPage.jsx @@ -93,7 +93,7 @@ export function FacilityReportDetailPage({ query }) {

{name}

-

Mở là thấy ngay biểu đồ tăng trưởng và báo cáo chi tiết, cùng cơ sở và cùng khoảng thời gian.

+

Doanh thu và tình hình cho thuê của cơ sở theo khoảng thời gian đã chọn.

set(r)} @@ -110,7 +110,7 @@ export function FacilityReportDetailPage({ query }) {
Hợp đồng quá hạn{kpi.overdue}{kpi.overdueDiff == null ? Chưa có số liệu cùng kỳ : {kpi.overdueDiff === 0 ? "Không đổi" : `${kpi.overdueDiff < 0 ? "▼" : "▲"} ${Math.abs(kpi.overdueDiff)} so với cùng kỳ`}}
+ footer={`Tổng ${trend.length} tháng: ${money(trendTotal(data.trend.months))}.`} />

Báo cáo chi tiết

Cùng phạm vi {rangeText(range).split(" · ")[0]} · tổng doanh thu {money(trendTotal(data.trend.months))}

@@ -146,7 +146,7 @@ export function FacilityReportDetailPage({ query }) { ))}
)} -

Khoản chờ thu là khoản chưa thanh toán còn hiệu lực (tiền thuê, gia hạn đã duyệt). Không có công nợ ngoài cọc (D32).

+

Khoản chờ thu là khoản chưa thanh toán còn hiệu lực (tiền thuê, gia hạn chờ thanh toán). Không có công nợ ngoài cọc.

Về báo cáo hệ thống
); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/access/AccessQrModal.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/access/AccessQrModal.jsx index 24d4a46..a9163b3 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/access/AccessQrModal.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/access/AccessQrModal.jsx @@ -40,7 +40,7 @@ export function AccessQrModal({ c, facility, onClose }) {

{where}

{/* #59: xem được mã trước ngày thuê nhưng chỉ mở cửa từ 00:00 ngày bắt đầu; đến ngày tự chuyển "Đang có hiệu lực" */} {a && (a.usable_now === false - ?
Chưa đến ngày sử dụng{usableFromText(a.usable_from || a.valid_from || c.start_date)}Trước thời điểm này, QR và PIN chưa mở được cửa, kể cả khi bạn đã xem hoặc lưu mã.
+ ?
Chưa đến ngày sử dụng{usableFromText(a.usable_from || a.valid_from || c.start_date)}Trước thời điểm này, QR và PIN chưa mở được cửa.
:
Đang có hiệu lựcCửa giữ mở sau khi quét đến khi bạn bấm “Đóng cửa” trong Kho của tôi hoặc trên máy quét.
)} {state.status === "unsupported" ? ( Mã QR mở cửa đang được cơ sở kích hoạt. Vui lòng liên hệ nhân viên trực để kiểm tra hợp đồng. diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ContractPaperPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ContractPaperPage.jsx index f1e5e92..abccb99 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ContractPaperPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ContractPaperPage.jsx @@ -79,7 +79,7 @@ export function ContractPaperPage({ id }) { {!issued ? ( Hợp đồng chưa được phát hành. Hợp đồng giấy có sau khi thanh toán xong và hệ thống cấp ô kho. ) : offline ? ( - Hợp đồng giấy được tạo từ máy chủ SafeSpace. Bản xem này chưa kết nối máy chủ nên chưa hiển thị được hợp đồng. + Chưa hiển thị được hợp đồng giấy. Vui lòng thử lại sau. ) : state.error ? ( {state.error} ) : state.loading ? ( diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalRequestPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalRequestPage.jsx index 594df8d..f0f452f 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalRequestPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalRequestPage.jsx @@ -60,7 +60,6 @@ export function RenewalRequestPage({ id }) { Chọn số tháng * {RENTAL_PLANS.map(m => )} - {policy.demo && Chế độ mô phỏng FE: bằng chứng đồng ý chỉ lưu trong trình duyệt.} {!policyReady && {policy.loading ? "Đang tải chính sách…" : "Chưa tải được phiên bản chính sách hợp lệ. Vui lòng tải lại trước khi gửi gia hạn."}} {policy.error && } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalUnitChangePage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalUnitChangePage.jsx index bba6c1d..295d1b0 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalUnitChangePage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalUnitChangePage.jsx @@ -23,7 +23,7 @@ import "../../../shared/styles/customer-detail.css"; // D46 / D46b · Figma C08-D41a (gia hạn sang ô khác) và C08-D41b (gia hạn sau nâng cấp miễn phí). // Khách chọn ô trống cụ thể; ô được giữ khi quản lý duyệt; khoản thanh toán gộp tiền gia hạn + cọc chênh. function choiceText(x, c) { - if (x.kind === "KEEP") return `Giữ ô ${x.unitNumber} · giá của ô này theo bảng giá, chốt khi duyệt · không phải chuyển đồ`; + if (x.kind === "KEEP") return `Giữ ô ${x.unitNumber} · giá của ô này theo bảng giá · không phải chuyển đồ`; const deposit = x.depositTopUp > 0 ? `cọc thêm ${money(x.depositTopUp)}` : "không thu thêm cọc"; const type = x.kind === "ORIGINAL_TYPE" ? " · về loại đã đặt ban đầu" : ""; return `Ô ${x.unitNumber}${x.typeName ? ` · ${x.typeName}` : ""}${type} · ${money(x.monthlyRate)}/tháng · ${deposit}`; @@ -74,7 +74,7 @@ export function RenewalUnitChangePage({ id }) {

SafeSpace / Khách hàng / Kho của tôi / {id} / Gia hạn

Hết hạn {dateLabel(c.end_date)} - {load.demo ? Chế độ mô phỏng chưa có danh sách ô trống thật. Vui lòng dùng chế độ kết nối máy chủ. + {load.demo ? Chức năng này chưa có dữ liệu trong chế độ thử nghiệm. : load.loading ? Đang tải ô trống… : load.error ? <>{load.error} : choices.length === 0 ? Về hợp đồng @@ -106,7 +106,7 @@ export function RenewalUnitChangePage({ id }) { text={choice.kind === "KEEP" ? "Gia hạn được xác nhận ngay theo bảng giá ô hiện tại để bạn thanh toán trong 24 giờ." : "Ô mới được giữ ngay cho bạn khi xác nhận gia hạn. Sau khi thanh toán, bạn tự chuyển đồ trong 3 ngày cuối kỳ cũ."} rows={[["Ô kỳ mới", choice.kind === "KEEP" ? c.unit_number : choice.unitNumber], ["Kỳ gia hạn", `${months} tháng · đến ${dateLabel(addMonths(c.end_date, months))}`], ...(choice.kind === "KEEP" ? [] : [["Tổng thanh toán", money(est.total)]])]} />} {result?.ok && go(`units/${encodeURIComponent(id)}`)} onConfirm={() => go(`units/${encodeURIComponent(id)}`)} />} + text="Gia hạn đã được xác nhận. Vui lòng thanh toán trong 24 giờ." onCancel={() => go(`units/${encodeURIComponent(id)}`)} onConfirm={() => go(`units/${encodeURIComponent(id)}`)} />} {result && !result.ok && setResult(null)} onConfirm={() => { setResult(null); if (!result.taken && choice) setConfirm(true); }} />} ; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RentedUnitDetailPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RentedUnitDetailPage.jsx index 5770c0b..c1f6be1 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RentedUnitDetailPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RentedUnitDetailPage.jsx @@ -89,7 +89,7 @@ export function RentedUnitDetailPage({ id }) {

Chính sách áp dụng

-

Xem phiên bản và bằng chứng đồng ý theo hợp đồng hoặc từng yêu cầu gia hạn. Hồ sơ chưa có dữ liệu sẽ được thông báo rõ.

+

Xem phiên bản chính sách bạn đã đồng ý cho hợp đồng và từng lần gia hạn.

Xem chính sách đã đồng ý
@@ -120,7 +120,7 @@ export function RentedUnitDetailPage({ id }) { :

Hỗ trợ

Hợp đồng đã kết thúc. Cần hỏi thêm? Gửi hỗ trợ chung.

Gửi hỗ trợ chung
} {ended && Thuê kho mới} {!issued && !ended && Xem lịch nhận chìa khóa} -

{ended ? "Hợp đồng đã kết thúc. Tiền cọc được hoàn theo biên bản trả kho." : "Tiền cọc được đối chiếu sau kiểm tra kho. Nhận chìa khóa không kích hoạt hợp đồng."}

+

{ended ? "Hợp đồng đã kết thúc. Tiền cọc được hoàn theo biên bản trả kho." : "Tiền cọc được đối chiếu sau kiểm tra kho."}

Hỗ trợ do sự cố cơ sởXác nhận khấu trừ trả khoTheo dõi gia hạnGia hạn sang ô khác / sau nâng cấpLịch khấu trừ cọcTiến độ trả kho / hoàn cọcLịch sử thanh toánChính sách cho thuê
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnDeductionPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnDeductionPage.jsx index 198eb26..767d73d 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnDeductionPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnDeductionPage.jsx @@ -122,7 +122,7 @@ export function ReturnDeductionPage({ id }) { return

SafeSpace / Khách hàng / Kho của tôi / {id}

{d && {pill}} - {load.demo ? Chế độ mô phỏng chưa có biên bản trả kho thật. Vui lòng dùng chế độ kết nối máy chủ. + {load.demo ? Chức năng này chưa có dữ liệu trong chế độ thử nghiệm. : load.loading ? Đang tải biên bản… : load.error ? <>{load.error} : !d ? diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx index 8e622b8..9b46e58 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnProgressPage.jsx @@ -13,7 +13,7 @@ export function ReturnProgressPage({ id }) { if (!c) return ; const ret = pendingReturn(data, id), refund = load.data?.find(r => r.contractId === id && String(r.ownerId) === String(user?.user_id)); return
-

{ret ? "Đã gửi lịch trả kho" : "Chưa có yêu cầu trả kho"}

{ret && <>Liên hệ nhân viên nếu cần hỗ trợ ra vào sau khi gửi yêu cầu. Yêu cầu trả kho chưa được coi là đã kiểm tra xong — nhân viên sẽ kiểm tra thực tế và chụp ảnh hiện trạng trước khi đối soát hoàn cọc.}
+

{ret ? "Đã gửi lịch trả kho" : "Chưa có yêu cầu trả kho"}

{ret && <>Nhân viên sẽ kiểm tra kho và chụp ảnh hiện trạng trước khi đối soát hoàn cọc. Cần hỗ trợ ra vào, vui lòng liên hệ nhân viên.}

Biên bản & hoàn cọc

{refund ? <>{refund.transactionRef &&

Mã giao dịch: {refund.transactionRef}

} :

Chưa có kết quả kiểm tra / đối soát cọc từ cơ sở.

}
Về hợp đồngLiên hệ cơ sở
; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx index b3433b2..34e6b36 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/ReturnRequestPage.jsx @@ -83,7 +83,6 @@ export function ReturnRequestPage({ id }) {

2 · Nhận tiền hoàn

- {support.demo && Chế độ mô phỏng: lịch trả kho và thông tin nhận hoàn lưu trong trình duyệt.} {!support.ready && {support.loading ? "Đang kiểm tra chức năng gửi trả kho…" : support.error || "Chức năng gửi trả kho đang được cập nhật. Vui lòng liên hệ cơ sở để được hỗ trợ."}} {support.error && } {blocked && Chưa thể gửi thêm: hợp đồng chưa bắt đầu, đã kết thúc hoặc đang có yêu cầu gia hạn/trả kho. Xem hợp đồng} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/UnitChangePage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/UnitChangePage.jsx index 4c96c1a..9be8c64 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/UnitChangePage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/UnitChangePage.jsx @@ -78,7 +78,7 @@ export function UnitChangePage({ id }) { return

SafeSpace / Khách hàng / Đặt chỗ / {orderId}

{item && {pill}} - {load.demo ? Chế độ mô phỏng chưa có đề xuất đổi kho. Vui lòng dùng chế độ kết nối máy chủ. + {load.demo ? Chức năng này chưa có dữ liệu trong chế độ thử nghiệm. : load.loading ? Đang tải… : load.error ? <>{load.error} : !item ? diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/components/CancelRenewalButton.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/components/CancelRenewalButton.jsx index 6212470..e9ead07 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/components/CancelRenewalButton.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/components/CancelRenewalButton.jsx @@ -34,13 +34,13 @@ export function CancelRenewalButton({ renewal, contract }) { return <> {stage === "confirm" && setStage(null)} onConfirm={send} />} {stage === "success" && setStage(null)} onConfirm={() => setStage(null)} />} {stage === "failure" && setStage(null)} onConfirm={() => { setStage(null); retry?.(); }} />} ; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/renewalUnitModel.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/renewalUnitModel.js index d42bd3a..54cf343 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/renewalUnitModel.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/renewalUnitModel.js @@ -1,7 +1,7 @@ // D46 / D46b · Gia hạn sang ô khác và gia hạn sau nâng cấp miễn phí (D41). Hàm thuần, có test. export const UNIT_MOVE_STATUS = { - REQUESTED: ["Chờ cơ sở duyệt", "amber"], + REQUESTED: ["Chờ xác nhận", "amber"], HELD: ["Đã giữ ô · chờ thanh toán", "blue"], PAID: ["Đang chuyển sang ô mới", "blue"], MOVED: ["Đã chuyển · chờ kiểm tra ô cũ", "green"], diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CashRefundPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CashRefundPage.jsx index e74d0c1..f951c89 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CashRefundPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CashRefundPage.jsx @@ -97,7 +97,7 @@ export function CashRefundPage({ query }) { const onSwitch = async (id, bank) => { await load.switchToBank(id, bank); await load.reload(); }; return

SafeSpace / Khách hàng / Thanh toán & lịch hẹn / Hoàn tiền mặt

- {load.demo ? <>Chế độ mô phỏng chưa có khoản hoàn tiền mặt. Vui lòng dùng chế độ kết nối máy chủ. + {load.demo ? <>Chức năng này chưa có dữ liệu trong chế độ thử nghiệm. : load.loading ? Đang tải… : load.error ? <>{load.error} : selected ? diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CheckoutPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CheckoutPage.jsx index 16dbbe4..695376a 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CheckoutPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/CheckoutPage.jsx @@ -58,7 +58,7 @@ export function CheckoutPage({ id }) { useEffect(() => { if (pending && deadline && remaining <= 0) { - dispatch("EXPIRE_RESERVATION", { reservation_id: id }).then(() => go(`checkout/${id}/failed`, { replace: true })); + dispatch("EXPIRE_RESERVATION", { reservation_id: id }).then((res) => go(res?.status === "PAID" ? `confirmation/${id}` : `checkout/${id}/failed`, { replace: true })); } }, [remaining <= 0, pending]); // eslint-disable-line react-hooks/exhaustive-deps diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/PaymentListPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/PaymentListPage.jsx index 8aead59..2e5cced 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/PaymentListPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/PaymentListPage.jsx @@ -86,7 +86,7 @@ export default function PaymentListPage() { Chính sách cho thuê - {paid && Đã nhận thanh toán gia hạn qua mã QR. Kỳ thuê được cập nhật theo kết quả máy chủ.} + {paid && Đã nhận thanh toán gia hạn qua mã QR. Kỳ thuê mới đã được cập nhật.} {detail && ( Về thanh toán
- + {paying && setPaying(false)} onPaid={() => { setPaying(false); setResult({ paid: true }); }} />}
; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/ReservationReviewPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/ReservationReviewPage.jsx index 1c19d8e..28417cf 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/ReservationReviewPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/payments/ReservationReviewPage.jsx @@ -56,7 +56,7 @@ export function ReservationReviewPage({ id }) {

{reservation.allocation_mode === "EXACT" ? `Hệ thống giữ chính xác ô ${reservation.unit_code} cho bạn trong toàn bộ kỳ ${dateLabel(reservation.start_date)} – ${dateLabel(reservation.end_date)}.` - : `Trống trong toàn bộ kỳ ${dateLabel(reservation.start_date)} – ${dateLabel(reservation.end_date)} · không trùng hợp đồng hoặc lượt đặt khác. Bạn không cần chọn ô trên sơ đồ.`} + : `Trống trong toàn bộ kỳ ${dateLabel(reservation.start_date)} – ${dateLabel(reservation.end_date)}.`}

Xem vị trí ô trên sơ đồ → :

Hệ thống bố trí ô trống cả kỳ theo loại kho và diện tích bạn chọn; mã ô hiện ở đây ngay khi có.

} @@ -73,11 +73,10 @@ export function ReservationReviewPage({ id }) { {policy.error && {policy.error}} {ready &&

Bản hiện hành: {policyVersionLabel(policy.data)}

} - {mode === "local" && Chế độ mô phỏng: xác nhận chỉ lưu trên trình duyệt này.} {error && {error}} {(!pending || expired) && Đơn không còn chờ thanh toán hoặc đã hết hạn giữ chỗ. Vui lòng kiểm tra trạng thái đơn.} -

Sự đồng ý được lưu cùng đơn, phiên bản chính sách và thời điểm xác nhận. Nhân viên không xác nhận thay bạn.

+

Bạn có thể xem lại chính sách đã đồng ý trong mục Chính sách.

Xem đơn đặt chỗ diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/policies/RentalPolicyPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/policies/RentalPolicyPage.jsx index 1c2650f..ce15b19 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/policies/RentalPolicyPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/policies/RentalPolicyPage.jsx @@ -8,7 +8,7 @@ import { useApp } from "../../../app/state/AppProvider.jsx"; import "../../../shared/styles/rental-policy.css"; export function RentalPolicyPage({ query = new URLSearchParams() }) { - const { data, authed, mode, retry } = useApp(); + const { data, authed, retry } = useApp(); const [tab, setTab] = useState(query.get("tab") === "contract" ? "contract" : "current"); const [selected, setSelected] = useState(query.get("contract") || ""); const [record, setRecord] = useState(query.get("renewal") || "initial"); @@ -32,14 +32,12 @@ export function RentalPolicyPage({ query = new URLSearchParams() }) { {tab === "contract" &&
} {load.loading &&
Đang tải đúng phiên bản chính sách…
} {load.error &&
{load.error}
} - {tab === "contract" && !consent &&

Chưa có bằng chứng đồng ý

Hồ sơ này không có bản ghi đồng ý được lưu. Máy chủ chưa cung cấp phiên bản và thời điểm đồng ý cho hồ sơ này. Không dùng bản hiện hành để thay cho bản bạn đã đồng ý.

} + {tab === "contract" && !consent &&

Chưa có bằng chứng đồng ý

Chưa tải được thông tin đồng ý chính sách của hồ sơ này. Vui lòng tải lại hoặc liên hệ cơ sở.

} {policy && POLICY_SECTIONS.map(([key, title], index) =>

{String(index + 1).padStart(2, "0")} · {title}

{policy.sections[key]}

)} } ; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/reservations/CancelReservationPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/reservations/CancelReservationPage.jsx index a7fa5e5..8a30402 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/reservations/CancelReservationPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/reservations/CancelReservationPage.jsx @@ -74,7 +74,6 @@ export function CancelReservationPage({ id }) {
{paid &&

Nhận tiền hoàn

}

Lý do huỷ

setReason(e.target.value)} disabled={busy || !allowed} /> - {support.demo && Chế độ mô phỏng: thao tác chỉ lưu trong trình duyệt, không chuyển tiền thật.} {paid && !support.ready && {support.loading ? "Đang kiểm tra chức năng hoàn tiền…" : support.error || "Chức năng huỷ đơn đã thanh toán đang được cập nhật. Vui lòng liên hệ cơ sở để được hỗ trợ."}} {paid && support.error && } {!allowed && Đơn này không còn đủ điều kiện huỷ. {c && Xem hợp đồng và yêu cầu trả kho}} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsLayout.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsLayout.jsx index f50e355..6047918 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsLayout.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsLayout.jsx @@ -122,7 +122,7 @@ export default function FacilityOperationsLayout({ role, active, subActive, chil {mode === "api" && source === "local" && (

- Chưa kết nối được dữ liệu vận hành của cơ sở. Thao tác trên màn hình này đang được lưu tạm trên trình duyệt. + Mất kết nối dữ liệu của cơ sở. Thao tác lúc này chỉ lưu tạm trên máy, vui lòng tải lại trang.

)} {/* #7: không còn hàng ô/tab nào dưới navbar; chức năng con mở từ thẻ việc và nút trong trang */} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/api/facilityOperationsApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/api/facilityOperationsApi.js index cf70046..5ebff09 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/api/facilityOperationsApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/api/facilityOperationsApi.js @@ -122,7 +122,7 @@ export async function fetchLocationLayout(facilityId) { export async function callAction(type, payload, shouldContinue=()=>true) { const make = OPS_ACTIONS[type]; - if (!make) throw new Error("Máy chủ chưa hỗ trợ thao tác này; dữ liệu chưa được thay đổi."); + if (!make) throw new Error("Thao tác này chưa thực hiện được; dữ liệu chưa thay đổi."); const [method, path, body] = make(payload); if(type==="SUBMIT_RETURN"&&payload.files?.length){body.photos=[];for(const file of payload.files){await verifyPhotoFile(file);body.photos.push(await readPhotoData(file));}} if(!shouldContinue())throw new Error("Phiên làm việc đã thay đổi. Chưa gửi thao tác."); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/IncidentComponents.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/IncidentComponents.jsx index 62fa9e0..2b89bfe 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/IncidentComponents.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/IncidentComponents.jsx @@ -7,7 +7,7 @@ import { INCIDENT_STATUS, incidentStatusLabel, incidentRefund } from "./incident import "./incidents.css"; export const incidentTime=value=>value&&Number.isFinite(Date.parse(value))?new Intl.DateTimeFormat("vi-VN",{timeZone:"Asia/Ho_Chi_Minh",dateStyle:"short",timeStyle:"short"}).format(new Date(value)):"Chưa có thông tin"; export function IncidentState({load,children}) { - return <>{load.demo&&Chế độ mô phỏng FE: hồ sơ sự cố lưu riêng trên trình duyệt, không đổi hợp đồng, mã ra vào hoặc chuyển tiền thật. Ảnh chỉ giữ tên tệp sau gửi.}{load.needsRefresh&&Chưa xác minh kết quả lần gửi trước. Tải lại trước khi thao tác tiếp.}
{load.loading?

Đang tải hồ sơ sự cố…

:load.error?:children}; + return <>{load.needsRefresh&&Chưa xác minh kết quả lần gửi trước. Tải lại trước khi thao tác tiếp.}
{load.loading?

Đang tải hồ sơ sự cố…

:load.error?:children}; } export function IncidentContract({item}) { return ; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/incidentApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/incidentApi.js index 8f8055d..ed30c43 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/incidentApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/incidents/incidentApi.js @@ -26,7 +26,7 @@ export function normalizeIncident(value) { return {...value,photos:Array.isArray(value.photos)?value.photos:[],candidates:Array.isArray(value.candidates)?value.candidates:[]}; } const pathFor=scope=>{if(scope==="customer")return "/api/incidents";if(scope==="manager")return "/api/ops/incidents";throw new Error("Phạm vi không hợp lệ.");}; -const explain=error=>[404,405].includes(error.status)?new ApiError("Máy chủ chưa hỗ trợ luồng sự cố cơ sở. Chưa ghi nhận thay đổi; vui lòng liên hệ cơ sở.",error.status):error; +const explain=error=>[404,405].includes(error.status)?new ApiError("Chưa ghi nhận được thay đổi. Vui lòng thử lại sau.",error.status):error; export async function loadIncidents(scope) { try{const data=await request(pathFor(scope));if(!Array.isArray(data?.items))throw new Error("Danh sách sự cố từ máy chủ không hợp lệ.");return data.items.map(normalizeIncident);}catch(error){throw explain(error);} } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/SettlementComponents.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/SettlementComponents.jsx index 0ec77e9..c6d9932 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/SettlementComponents.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/SettlementComponents.jsx @@ -7,7 +7,6 @@ export function SettlementSummary({deposit,damage,cleaning,overdue,amount,offici const hasKeep=typeof keep==="number"&&keep>0,known=[deposit,damage,cleaning,overdue].every(v=>typeof v==="number"&&Number.isFinite(v)&&v>=0),deduction=known?Math.min(deposit,damage+cleaning+overdue+(hasKeep?keep:0)):undefined; return ; } -export function OpsDemo({source}) {return source==="local"?Chế độ mô phỏng FE: thao tác lưu trên trình duyệt, không chuyển tiền hoặc thay đổi quyền mở kho thật.:null;} // #17 · Figma M-ĐS: tách kiểm kê, hư hỏng & khấu trừ, ảnh hiện trạng; nhãn và giá trị thẳng hàng, không khối lồng. export function InspectionReview({ret}) { diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js index 9ff2a39..c4ee631 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/settlements/settlementModel.js @@ -60,12 +60,12 @@ export function isReturnSettlementReady(board,contract) { export function opsMutationCheck(type,payload,ops,source,role) { const staff=["VERIFY_CUSTOMER","RECORD_KEY_RECEIPT","SUBMIT_RETURN"].includes(type),manager=["CONFIRM_REFUND","CONFIRM_RESERVATION_REFUND","CONFIRM_DEPOSIT_REFUND"].includes(type); if((staff&&!["STAFF","MANAGER"].includes(role))||(manager&&role!=="MANAGER"))throw new Error("Vai trò không được thực hiện thao tác này."); - if(type==="VERIFY_CUSTOMER") {if(!["original_valid","photo_ok","info_ok","booking_matched"].every(k=>payload[k]===true))throw new Error("Đánh dấu đủ bốn mục đối chiếu.");if(source==="api"&&ops.verification_checklist_supported!==true)throw new Error("Máy chủ chưa hỗ trợ xác minh bằng checklist.");} + if(type==="VERIFY_CUSTOMER") {if(!["original_valid","photo_ok","info_ok","booking_matched"].every(k=>payload[k]===true))throw new Error("Đánh dấu đủ bốn mục đối chiếu.");if(source==="api"&&ops.verification_checklist_supported!==true)throw new Error("Chưa thể xác minh lúc này. Vui lòng thử lại sau.");} if(type==="RECORD_KEY_RECEIPT")validateKeyReceipt(ops,payload); - if(type==="SUBMIT_RETURN") {validateInspection(ops.returns.find(r=>r.id===payload.id),payload.report,payload.files);if(source==="api"&&ops.inspection_evidence_supported!==true)throw new Error("Máy chủ chưa hỗ trợ lưu đủ ảnh và khấu trừ kiểm kê. Chưa gửi biên bản.");} + if(type==="SUBMIT_RETURN") {validateInspection(ops.returns.find(r=>r.id===payload.id),payload.report,payload.files);if(source==="api"&&ops.inspection_evidence_supported!==true)throw new Error("Chưa thể gửi biên bản lúc này. Vui lòng thử lại sau.");} if(type==="CONFIRM_REFUND") {const c=ops.contracts.find(c=>c.id===payload.id),r=ops.returns.find(r=>r.contract===payload.id);if(!canFinalizeReturn(ops,c,r))throw new Error("Chưa đủ biên bản hoặc phản hồi/khắc phục chưa xử lý xong.");if(source==="api"&&r.damage_workflow_resolved!==true)throw new Error("Máy chủ chưa xác nhận đã giải quyết phản hồi/khắc phục.");} if(type==="CONFIRM_DEPOSIT_REFUND")transferProof(ops.deposit_refunds?.find(r=>r.id===payload.id),payload); - if(type==="CONFIRM_RESERVATION_REFUND") {const item=ops.refunds?.find(r=>r.id===payload.id);transferProof(item,payload);if(source==="api"&&ops.refund_evidence_supported!==true)throw new Error("Máy chủ chưa hỗ trợ lưu tài khoản và bằng chứng chuyển tiền. Chưa ghi nhận đã hoàn.");} + if(type==="CONFIRM_RESERVATION_REFUND") {const item=ops.refunds?.find(r=>r.id===payload.id);transferProof(item,payload);if(source==="api"&&ops.refund_evidence_supported!==true)throw new Error("Chưa thể ghi nhận đã hoàn lúc này. Vui lòng thử lại sau.");} } export function opsReceiptCheck(type,payload,res,board) { if(!board)throw new Error("Chưa tải lại được kết quả sau thao tác. Tải lại trước khi gửi tiếp."); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/FacilityOperationsProvider.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/FacilityOperationsProvider.jsx index b7e2208..648986b 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/FacilityOperationsProvider.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/FacilityOperationsProvider.jsx @@ -38,8 +38,8 @@ function readOps() { } const UNSUPPORTED = { - UPDATE_UNIT_STATUS: "Máy chủ chưa hỗ trợ đổi trạng thái ô kho. Cập nhật backend có PUT /api/staff/units/{mã}/status rồi thử lại.", - CONFIRM_FEE_COLLECTION: "Máy chủ chưa hỗ trợ ghi nhận thu phí tại quầy (POST /api/ops/fees/{mã}/confirm). Chưa lưu khoản thu này; không thu thêm tiền của khách.", + UPDATE_UNIT_STATUS: "Chưa đổi được trạng thái ô kho. Vui lòng thử lại sau.", + CONFIRM_FEE_COLLECTION: "Chưa ghi nhận được khoản thu này; không thu thêm tiền của khách. Vui lòng thử lại sau.", }; // Nhật ký / thông báo trong ca chỉ giữ ở trình duyệt (backend chưa có API thông báo) @@ -142,7 +142,7 @@ export function OpsProvider({ children, notify, mode = "local", onApiError, role onApiError?.(e); // Route chưa có trên backend: ASP.NET trả 404/405 không kèm nội dung → báo rõ thay vì "Không tìm thấy dữ liệu." const missing = e instanceof ApiError && (e.status === 404 || e.status === 405) && !e.data; - const error = missing ? UNSUPPORTED[type] || "Máy chủ chưa hỗ trợ thao tác này." : e?.message || "Thao tác không thành công."; + const error = missing ? UNSUPPORTED[type] || "Thao tác này chưa thực hiện được. Vui lòng thử lại sau." : e?.message || "Thao tác không thành công."; notify?.(error, "error"); return { ok: false, error }; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/facilityOperationsReducer.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/facilityOperationsReducer.js index 97860a9..a6ec08b 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/facilityOperationsReducer.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/state/facilityOperationsReducer.js @@ -169,7 +169,7 @@ const ACTIONS = { // M03 — giữ handler để trả lỗi rõ ràng nếu UI/API cũ gọi duyệt/từ chối gia hạn thủ công DECIDE_RENEWAL() { - fail("Chức năng quản lý duyệt gia hạn đã bỏ. Hệ thống tự động xác nhận gia hạn hợp lệ để khách thanh toán trực tiếp."); + fail("Gia hạn hợp lệ được hệ thống xác nhận tự động."); }, // M05 diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/WorkflowComponents.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/WorkflowComponents.jsx index 8e4ec61..ad82a64 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/WorkflowComponents.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/WorkflowComponents.jsx @@ -4,7 +4,7 @@ import { Button, Empty, Modal, Notice, Tag } from "../../../shared/components/UI // errorView: chữ trạng thái lỗi tải theo Figma của từng màn ({ title, text, label }); 403 khi tải = dữ liệu ngoài cơ sở phụ trách (Figma QUYEN02) export function WorkflowState({ load, children, errorView }) { - return <>{load.demo && Chế độ mô phỏng FE · Dữ liệu lưu trong trình duyệt, không phải giao dịch thật.} + return <> {load.needsRefresh&&Chưa xác minh kết quả. Tải lại trước khi gửi tiếp; không chuyển tiền lần nữa.} {load.loading ?

Đang tải dữ liệu…

: load.error ? ( load.errorStatus === 403 ? diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useOpsEndpoint.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useOpsEndpoint.js index 2f3be13..e5a55ef 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useOpsEndpoint.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/useOpsEndpoint.js @@ -19,13 +19,13 @@ export function useOpsEndpoint(path) { setLoading(true); setError(""); setErrorStatus(0); try { const res = await request(path); if (n === seq.current) setData(res); } catch (e) { - if (n === seq.current) { setError([404, 405].includes(e.status) ? "Máy chủ chưa cung cấp dữ liệu cho chức năng này." : e.message); setErrorStatus(e.status || 0); } + if (n === seq.current) { setError([404, 405].includes(e.status) ? "Chưa tải được dữ liệu. Vui lòng thử lại sau." : e.message); setErrorStatus(e.status || 0); } onApiError?.(e); } finally { if (n === seq.current) setLoading(false); } }, [demo, path, onApiError]); useEffect(() => { reload(); return () => { seq.current++; }; }, [reload]); const post = useCallback(async (url, body) => { - if (demo) return { ok: false, error: "Chế độ mô phỏng không ghi được thao tác này. Vui lòng dùng chế độ kết nối máy chủ." }; + if (demo) return { ok: false, error: "Chế độ thử nghiệm không ghi được thao tác này." }; if (guard.current) return { ok: false, error: "Đang lưu, vui lòng chờ." }; guard.current = true; setBusy(true); try { const res = await request(url, { method: "POST", body }); await reload(); return { ok: true, result: res }; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/workflowApi.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/workflowApi.js index 2e7aa56..6f6b91e 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/workflowApi.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/workflows/workflowApi.js @@ -5,10 +5,10 @@ const RESOURCES = { customerRefunds: "/api/deposit-refunds", overdue: "/api/ops/ export async function loadWorkflow(resource) { if (!RESOURCES[resource]) throw new Error("Nguồn dữ liệu không hợp lệ."); try { return await request(RESOURCES[resource], { auth: resource !== "policy" }); } - catch (error) { if ([404, 405].includes(error.status)) throw new Error("Máy chủ chưa cung cấp dữ liệu cho chức năng này. Vui lòng thử lại sau hoặc liên hệ cơ sở."); throw error; } + catch (error) { if ([404, 405].includes(error.status)) throw new Error("Chưa tải được dữ liệu. Vui lòng thử lại sau."); throw error; } } export async function saveWorkflow(resource, action, payload) { if (!RESOURCES[resource]) throw new Error("Nguồn dữ liệu không hợp lệ."); try { return await request(`${RESOURCES[resource]}/actions`, { method: "POST", body: { action, ...payload } }); } - catch (error) { if ([404, 405].includes(error.status)) throw new Error("Máy chủ chưa hỗ trợ lưu màn này. Dữ liệu chưa được ghi nhận."); throw error; } + catch (error) { if ([404, 405].includes(error.status)) throw new Error("Chưa lưu được. Dữ liệu chưa được ghi nhận."); throw error; } } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/contracts/ContractListPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/contracts/ContractListPage.jsx index e23c2be..c8b117b 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/contracts/ContractListPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/contracts/ContractListPage.jsx @@ -48,7 +48,7 @@ function SettledCase({ ops, contract }) {
{label}
- {ret ? : Biên bản cũ hơn 30 ngày không còn trên bảng việc; xem lại tại khoản hoàn.} + {ret ? : Biên bản cũ hơn 30 ngày xem lại tại mục Hoàn tiền.} {refund && (

Khoản hoàn {refund.id}

diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/CancellationRefundPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/CancellationRefundPage.jsx index 37c4e9d..0b05246 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/CancellationRefundPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/CancellationRefundPage.jsx @@ -71,7 +71,7 @@ export function CancellationRefundPage({ embedded = false } = {}) { const Wrap = embedded ? "section" : "main"; return {embedded ?

Hoàn tiền đơn huỷ

: } - {source==="api"&&ops.refund_evidence_supported!==true&&Máy chủ chưa hỗ trợ lưu đủ tài khoản và bằng chứng chuyển tiền; chưa thể xác nhận đã hoàn.} + {source==="api"&&ops.refund_evidence_supported!==true&&Chưa thể xác nhận đã hoàn lúc này. Vui lòng thử lại sau.} {confirmed && Đã ghi nhận hoàn {money(confirmed.amount)} · {confirmed.id}.} {refunds.map(r => {r.status === "PENDING" && } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx index 5d1ea26..82e07e2 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/refunds/DepositRefundPage.jsx @@ -80,7 +80,7 @@ function TransferForm({item,load,ask}) { {isCash ? "Khách hàng đã chọn nhận tiền mặt tại quầy cơ sở. Kiểm tra CCCD trùng tên hợp đồng trước khi chi tiền và lưu phiếu chi." - : "Khách đã chọn nhận chuyển khoản ngân hàng (khóa theo lựa chọn của khách). Chuyển đúng số tiền vào tài khoản nhận hoàn rồi nhập mã giao dịch thật."} + : "Khách đã chọn nhận chuyển khoản ngân hàng. Chuyển đúng số tiền vào tài khoản nhận hoàn rồi nhập mã giao dịch."}
- {!isCash &&

Nhập sau khi chuyển tiền, lấy từ giao dịch ngân hàng thực tế. Khác mã hồ sơ nội bộ {item.id}; hệ thống không tự sinh mã này.

} + {!isCash &&

Nhập mã giao dịch ngân hàng sau khi chuyển tiền.

}
Tỷ lệ lấp đầy hiện tại{occ}%{rented}/{ops.units.length} ô
- {missing &&

Đang dùng số liệu 6 tháng gần nhất của bảng vận hành; tháng ngoài khoảng đó hiện 0 đ.

} + {missing &&

Chỉ có số liệu 6 tháng gần nhất; các tháng trước đó hiển thị 0 đ.

} ({ key: r.key, label: r.label, value: r.value, highlight: r.key === now.slice(0, 7) }))} footer={`Tổng ${rows.length} tháng: ${money(total)}.`} /> diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/units/UnitManagementPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/units/UnitManagementPage.jsx index c7d4627..673ee12 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/units/UnitManagementPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/manager/units/UnitManagementPage.jsx @@ -64,7 +64,7 @@ export function UnitStatusDialog({ unit, onClose }) { ))} -

Chỉ hiện các trạng thái được phép chuyển: Trống ↔ Bảo trì. Ô đang có khách thuê ghi nhận hư hỏng, bảo trì bằng “Ghi nhận sự cố”; trạng thái sử dụng luôn theo hợp đồng.

+

Chỉ đổi được giữa Trống và Bảo trì. Ô đang có khách thuê dùng “Ghi nhận sự cố”.