From 0538ea22d4b39dd2f2e2762b0068b5d387331d50 Mon Sep 17 00:00:00 2001 From: Vector Date: Mon, 2 Nov 2026 11:36:21 +0700 Subject: [PATCH] fix(F40): sua hien thi M07/A02/A05/B04/C11 va het giat khi chuyen trang --- .../SafeSpace-Customer-UI/src/app/App.jsx | 7 +++- .../SafeSpace-Customer-UI/src/app/router.js | 9 +++- .../src/features/admin/AdminRoutes.jsx | 3 +- .../features/admin/users/CreateUserPage.jsx | 42 +++++++++++-------- .../features/admin/users/UserDetailPage.jsx | 4 +- .../src/features/business/BusinessRoutes.jsx | 3 +- .../src/features/business/business.css | 5 ++- .../customer/contracts/RenewalStatusPage.jsx | 2 +- .../FacilityOperationsRoutes.jsx | 3 ++ .../state/FacilityOperationsProvider.jsx | 8 +++- .../manager/contracts/ContractListPage.jsx | 13 +++--- .../src/shared/styles/motion.css | 10 +++-- .../src/shared/styles/ss.css | 7 ++++ .../src/shared/styles/workflows.css | 11 +++-- .../src/shared/utils/roles.js | 13 ++++++ progress.md | 14 +++++++ 16 files changed, 112 insertions(+), 42 deletions(-) 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 f3db9d3..5522615 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/App.jsx @@ -184,7 +184,10 @@ 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.

} -
+ {/* 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. */} +
{needsLogin ? null : loadError && !ready ? (
@@ -202,7 +205,7 @@ function Shell() { businessBody || ) : isOpsPage ? ( opsAllowed ? ( - + ) : ( diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/router.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/router.js index 2689639..8327be8 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/router.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/app/router.js @@ -12,9 +12,14 @@ export function useRoute() { const read = () => (typeof window === "undefined" ? parseRoute("") : parseRoute(window.location.hash)); const [route, setRoute] = useState(read); useEffect(() => { + let lastPath = read().raw.split("?")[0]; const onChange = () => { - setRoute(read()); - window.scrollTo(0, 0); + const next = read(); + const path = next.raw.split("?")[0]; + setRoute(next); + // Chỉ cuộn lên đầu khi đổi trang; đổi bộ lọc / ?id trong cùng trang thì giữ vị trí để không bị nhảy + if (path !== lastPath) window.scrollTo(0, 0); + lastPath = path; }; window.addEventListener("hashchange", onChange); return () => window.removeEventListener("hashchange", onChange); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/AdminRoutes.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/AdminRoutes.jsx index a5f94a7..1ea49fa 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/AdminRoutes.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/AdminRoutes.jsx @@ -82,5 +82,6 @@ export default function AdminRoutes({ parts }) { // tab: truyền mục menu hiện tại cho AdminShell. // body: nội dung trang được chọn ở các điều kiện phía trên. // {body} được truyền vào AdminShell thông qua children. - return {body}; + // key theo đường dẫn: nội dung trang dựng lại khi đổi trang, header/menu giữ nguyên (không giật) + return {body}; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/CreateUserPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/CreateUserPage.jsx index 605af25..a1f0bd4 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/CreateUserPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/CreateUserPage.jsx @@ -22,7 +22,7 @@ import { adminApi } from "../api/adminApi.js"; import { Select } from "../../../shared/components/Pickers.jsx"; import { Button, Field, Modal, Notice } from "../../../shared/components/UI.jsx"; import { isEmail, isPhone, today } from "../../../shared/utils/format.js"; -import { FACILITY_ROLES, roleLabel, sortRoles } from "../../../shared/utils/roles.js"; +import { FACILITY_ROLES, roleLabel, sortRoles, uniqueRoles } from "../../../shared/utils/roles.js"; import { go } from "../../../app/router.js"; import { useChangeFlow } from "../../../shared/components/ChangeFlowDialog.jsx"; import { useApp } from "../../../app/state/AppProvider.jsx"; @@ -63,7 +63,7 @@ export default function CreateUserPage() { const meta = useLoad(async () => { const [roles, facilities] = await Promise.all([adminApi.roles(), adminApi.facilities()]); - return { roles: sortRoles(roles, (r) => r.roleName), facilities: facilities.filter((f) => f.status === "ACTIVE") }; + return { roles: uniqueRoles(sortRoles(roles, (r) => r.roleName), (r) => r.roleName), facilities: facilities.filter((f) => f.status === "ACTIVE") }; }, [], onApiError); @@ -380,32 +380,38 @@ export default function CreateUserPage() { Hiển thị mỗi role dưới dạng một nút lựa chọn. */}
Vai trò -
- - {/* Render danh sách vai trò lấy từ API. */} - {roles.map((r) => ( + {/* Hai nhóm: vai trò phải chọn cơ sở (Nhân viên, Quản lý) ở trên; vai trò không gắn cơ sở ở dưới. */} +
+
+ Theo cơ sở · cần chọn cơ sở phụ trách +
{roles.filter((r) => FACILITY_ROLES.includes(r.roleName)).map((r) => ( - ))} - - {/* Trong lúc API tải vai trò, hiển thị thông báo. */} + ))}
+
+
+ Không gắn cơ sở +
{roles.filter((r) => !FACILITY_ROLES.includes(r.roleName)).map((r) => ( + + ))}
+
{meta.loading && Đang tải vai trò…}
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/UserDetailPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/UserDetailPage.jsx index 57e3f32..fd80c62 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/UserDetailPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/admin/users/UserDetailPage.jsx @@ -30,7 +30,7 @@ import { DatePicker, Select } from "../../../shared/components/Pickers.jsx"; import { Button, Empty, Field, LinkButton, Notice, StatusTag } from "../../../shared/components/UI.jsx"; import { useChangeFlow } from "../../../shared/components/ChangeFlowDialog.jsx"; import { isEmail, isPhone, today } from "../../../shared/utils/format.js"; -import { ASSIGNMENT_STATUS, USER_STATUS, needsFacility, roleLabel, sortRoles } from "../../../shared/utils/roles.js"; +import { ASSIGNMENT_STATUS, USER_STATUS, needsFacility, roleLabel, sortRoles, uniqueRoles } from "../../../shared/utils/roles.js"; import { useApp } from "../../../app/state/AppProvider.jsx"; import { dateOnlyLabel, dateTime, tempPassword, useLoad } from "../utils/adminUtils.js"; @@ -221,7 +221,7 @@ export default function UserDetailPage({ id }) { ]); return { user, - roles: sortRoles(roles, (r) => r.roleName), + roles: uniqueRoles(sortRoles(roles, (r) => r.roleName), (r) => r.roleName), facilities: facilities.filter((f) => f.status === "ACTIVE"), assignments, }; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/BusinessRoutes.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/BusinessRoutes.jsx index dafd42c..b3997de 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/BusinessRoutes.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/BusinessRoutes.jsx @@ -44,5 +44,6 @@ export default function BusinessRoutes({ parts, query }) {
); } - return {body}; + // key theo đường dẫn: nội dung trang dựng lại khi đổi trang, header/menu giữ nguyên (không giật) + return {body}; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/business.css b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/business.css index 4d089f8..d7d6123 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/business.css +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/business/business.css @@ -132,7 +132,10 @@ .business-app .biz-bars { align-items: flex-start; gap: 20px; height: 184px; padding-top: 10px; } .business-app .biz-bars__col { justify-content: flex-start; gap: 8px; } .business-app .biz-bars__col b { display: none; } -.business-app .biz-bars__col i { max-width: none; flex: none; background: var(--purple); border-radius: 6px; } +.business-app .biz-bars__col i { max-width: 220px; flex: none; background: var(--purple); border-radius: 6px; } +/* Ít cơ sở (1–2) thì cột không kéo hết chiều ngang; giữ độ rộng cột như Figma B04 (~5 cơ sở) */ +.business-app .biz-bars { justify-content: flex-start; } +.business-app .biz-bars__col { flex: 0 1 220px; } .business-app .biz-bars__col span { font-size: 13px; line-height: 16px; } .business-app .business-reports .table th:first-child { width: 27%; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalStatusPage.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalStatusPage.jsx index f813fd3..5f22fe3 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalStatusPage.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/customer/contracts/RenewalStatusPage.jsx @@ -11,7 +11,7 @@ export function RenewalStatusPage({ id }) { const expiredOf = r => r.status === "EXPIRED" || (!paidOf(r) && r.status === "APPROVED" && r.payment_deadline_at && Date.parse(r.payment_deadline_at) <= Date.now()); const label = r => expiredOf(r) ? "Đã hết hạn thanh toán" : r.status === "REJECTED" ? "Đã từ chối" : paidOf(r) ? "Đã thanh toán · Đã gia hạn" : r.status === "APPROVED" ? (r.at_counter ? "Chờ thu tại quầy" : "Đã duyệt · Chờ thanh toán") : "Chờ cơ sở duyệt"; return
{error && {error}} - {rows.map(r => Thanh toán PayOS}> + {rows.map(r => {!r.at_counter && Thanh toán PayOS}}> {expiredOf(r) && Yêu cầu gia hạn đã hết hiệu lực. Kỳ thuê hiện tại không thay đổi; không chuyển tiền theo mã cũ.}{r.reason && Lý do từ chối: {r.reason}}{r.at_counter && !paidOf(r) && !expiredOf(r) && Đang chờ nhân viên thu tiền tại quầy. Kỳ thuê hiện tại chưa thay đổi.} )}{!rows.length && }Về hợp đồng
; diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx index 57fed25..f5e2604 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/features/facility-operations/FacilityOperationsRoutes.jsx @@ -80,6 +80,8 @@ export default function FacilityOperationsRoutes({ role, parts, query }) { const [Page, active] = hit || [null, ""]; return ( + {/* key theo đường dẫn: nội dung trang dựng lại khi đổi trang, header/menu/dữ liệu giữ nguyên */} + {Page ? ( staff && LIST_KIND[parts[0]] ? : ) : ( @@ -89,6 +91,7 @@ export default function FacilityOperationsRoutes({ role, parts, query }) { )} + ); } 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 89bcf6a..3c64037 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 @@ -39,7 +39,7 @@ function appendLog(state, text, to) { return { ...state, log: [{ id: `L-${at.getTime()}`, text, to, role: "ALL", at: at.toISOString(), read: false }, ...(state.log || [])].slice(0, 60) }; } -export function OpsProvider({ children, notify, mode = "local", onApiError, role }) { +export function OpsProvider({ children, notify, mode = "local", onApiError, role, navKey }) { // source: "loading" | "api" | "local" const [source, setSource] = useState(mode === "api" ? "loading" : "local"); const [state, setState] = useState(() => (mode === "api" ? null : readOps())); @@ -214,6 +214,12 @@ export function OpsProvider({ children, notify, mode = "local", onApiError, role window.addEventListener("focus", refresh); return () => { clearInterval(timer); window.removeEventListener("focus", refresh); }; }, [mode, reload]); + // Đổi trang trong khu vận hành: nạp lại board ngầm (giữ dữ liệu đang hiện, không bật màn "Đang tải…") + const firstNav = useRef(true); + useEffect(() => { + if (firstNav.current) { firstNav.current = false; return; } + if (mode === "api" && !activeAction.current && ref.current) reload(); + }, [navKey, mode, reload]); const reset = useCallback(() => commit(createOpsData()), [commit]); 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 9cffd4d..8a27746 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 @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { InspectionReview } from "../../facility-operations/settlements/SettlementComponents.jsx"; import { canFinalizeReturn } from "../../facility-operations/settlements/settlementModel.js"; import { RecordCard } from "../../facility-operations/workflows/WorkflowComponents.jsx"; @@ -33,6 +33,9 @@ export function ContractListPage({ query }) { const sel = query.get("id") ? ops.contracts.find(c=>c.id===query.get("id")) : null; const [note, setNote] = useState(""); const mismatch = ops.payments.filter((p) => p.status === "MISMATCH"); + const detailRef = useRef(null); + // "Xem hồ sơ" mở chi tiết ngay dưới danh sách: cuộn tới để quản lý thấy trang đã chuyển + useEffect(() => { if (sel) detailRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); }, [sel?.id]); return (
@@ -42,9 +45,8 @@ export function ContractListPage({ query }) { ))}
{ops.contracts.map(c=>{const [label,tone]=CONTRACT_STATE(c);return {c.state==="RETURNED"?"Duyệt đối soát":c.state==="OVERDUE"?"Xem hồ sơ quá hạn":"Xem hồ sơ"}}>

{c.state==="RETURNED"?"Biên bản đã gửi · khấu trừ tối đa bằng cọc":c.state==="RENEWAL"?"Có yêu cầu gia hạn cần duyệt":"Theo dõi hạn thuê và lịch sử liên hệ khách"}

;})}
{query.get("id")&&!sel&&} -
Hoàn tiền đơn huỷHoàn cọc sau trả kho
{sel && ( -
+

{sel.id} · Bước tiếp theo

{sel.state === "RETURNED" ? ( <> @@ -84,9 +86,6 @@ export function ContractListPage({ query }) { }} /> )} - Hoàn cọc sau trả kho - {/* Figma M07: lối vào M08 hoàn tiền đơn huỷ */} - Hoàn tiền đơn huỷ{(ops.refunds || []).some((r) => r.status === "PENDING") ? ` (${ops.refunds.filter((r) => r.status === "PENDING").length})` : ""} {(sel.reminders || []).length > 0 && (
    {sel.reminders.map((r, i) =>
  • {dateTimeLabel(r.at)}{r.text}
  • )} @@ -94,6 +93,8 @@ export function ContractListPage({ query }) { )}
)} + {/* Figma M07: lối vào M08 hoàn tiền đơn huỷ và hoàn cọc, một thẻ cuối trang */} +
Hoàn tiền đơn huỷ{(ops.refunds || []).some((r) => r.status === "PENDING") ? ` (${ops.refunds.filter((r) => r.status === "PENDING").length})` : ""}Hoàn cọc sau trả kho
); } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/motion.css b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/motion.css index 608c9bb..84735ae 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/motion.css +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/motion.css @@ -57,9 +57,10 @@ from { opacity: 0; } to { opacity: 1; } } +/* Chuyển trang chỉ mờ nhẹ, không trượt: mờ từ 0 hoặc dịch lên xuống làm màn hình chớp và nhảy khi bấm liên tục */ @keyframes ss-page-in { - from { opacity: 0; transform: translateY(6px); } - to { opacity: 1; transform: none; } + from { opacity: 0.55; } + to { opacity: 1; } } @keyframes ss-pop-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } @@ -70,8 +71,9 @@ to { opacity: 1; transform: none; } } -/* Chuyển trang: #main đổi key theo đường dẫn trong App.jsx nên chạy lại mỗi lần đổi trang */ -#main { animation: ss-page-in var(--ss-base) var(--ss-ease) both; } +/* Chuyển trang: #main đổi key theo đường dẫn ở khu khách hàng (App.jsx) nên chạy lại mỗi lần đổi trang. + Khu nhân viên/quản lý/vận hành/quản trị giữ #main theo khu nên chỉ chạy khi vào khu, không chớp mỗi lần bấm. */ +#main { animation: ss-page-in var(--ss-fast) ease-out; } /* Popup chuẩn (Modal/ConfirmDialog): nền mờ dần, hộp phóng nhẹ */ .overlay { animation: ss-fade-in var(--ss-fast) ease-out both; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/ss.css b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/ss.css index 9f8c6a8..8eb429d 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/ss.css +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/ss.css @@ -430,6 +430,10 @@ a.cell-strong:hover { color: var(--blue); } .input-action input { flex: 1; min-width: 0; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; } .input-action button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--blue); cursor: pointer; white-space: nowrap; } .role-chips { display: flex; flex-wrap: wrap; gap: 8px; } +.role-groups { display: grid; gap: 12px; } +.role-group { display: grid; gap: 6px; } +.role-group__label { font-size: 13px; color: var(--muted); } +.role-group .role-chips button { min-width: 132px; text-align: center; } .role-chips button { border: 1px solid var(--line); background: var(--field); border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; color: var(--text); } .role-chips button.is-on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; } .note-box { background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--text); line-height: 1.5; } @@ -447,6 +451,9 @@ a.cell-strong:hover { color: var(--blue); } .role-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); color: var(--blue); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 14px; font-weight: 600; } .role-pill button { border: 0; background: #fff; color: var(--muted); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1; } .role-pill button:hover { color: var(--red); } +/* A05: nút "Gỡ vai trò" nằm trong chip — chữ một dòng, không bị bóp thành ô tròn 22px */ +.role-pill .btn { width: auto; height: auto; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; line-height: 1.4; border: 1px solid var(--line); background: #fff; color: var(--red); } +.role-pill .btn:hover:not(:disabled) { background: #fef2f2; box-shadow: none; } .inline-form { display: flex; gap: 10px; align-items: flex-start; } .inline-form > .select { flex: 1; } .inline-form--wrap { flex-wrap: wrap; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/workflows.css b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/workflows.css index f1b14fc..518e97c 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/workflows.css +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/styles/workflows.css @@ -12,14 +12,19 @@ .record-card__body { flex: 1; min-width: 0; display: grid; gap: 6px; } .record-card__body h2 { font-size: 20px; } .record-card__body > .muted { font-size: 14px; } -.record-card__actions { width: 199px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; } -.record-card__actions > .btn { width: 100%; text-align: center; justify-content: center; padding-inline: 8px; font-size: 15px; } -.record-card__actions > .tag { text-align: center; justify-content: center; } +.record-card__actions { flex-shrink: 0; max-width: 400px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px 16px; } +.record-card__actions > .btn { min-width: 160px; text-align: center; justify-content: center; padding-inline: 16px; font-size: 15px; } +/* Figma M07/D30: các thẻ trong cột xếp sát nhau, khoảng cách do lưới quyết định */ +.customer-detail__column > .record-card { margin-block: 0; } +.customer-detail__column:has(> .record-card) { gap: 16px; } +.record-card__actions > .tag { text-align: center; justify-content: center; white-space: nowrap; } .record-card:has(form) { align-items: stretch; flex-direction: column; } .record-card:has(form) .record-card__actions { align-self: flex-end; } .refund-amount { font-size: 18px; } .workflow-links { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 20px; } .workflow-links .btn { font-size: 14px; min-height: 40px; } +.workflow-links--panel { justify-content: flex-end; padding: 16px 24px; } +.contract-detail { margin-top: 20px; scroll-margin-top: 160px; } .workflow-thread li { padding: 16px; margin-block: 12px; border-radius: 8px; background: var(--soft); } .demo-banner { background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid var(--line); text-align: center; padding: 8px 16px; font-size: 14px; } .workflow-page .btn, .modal__actions .btn { justify-content: center; text-align: center; } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/utils/roles.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/utils/roles.js index e017490..351d4e6 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/utils/roles.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/shared/utils/roles.js @@ -19,6 +19,19 @@ export const sortRoles = (list, key = (x) => x) => return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib); }); +// DB có thể có nhiều mã cùng nghĩa "Vận hành KD" (OPERATIONS, BUSINESS_OPERATOR…). Danh sách chọn vai trò chỉ hiện +// một mục cho mỗi nhãn; ưu tiên OPERATIONS vì đây là mã được BE cho phép lưu chính sách (RentalPolicyEndpoints). +const PREFERRED_ROLE = { "Vận hành KD": "OPERATIONS" }; +export const uniqueRoles = (list, key = (x) => x) => { + const byLabel = new Map(); + for (const item of list) { + const label = roleLabel(key(item)); + const kept = byLabel.get(label); + if (!kept || (PREFERRED_ROLE[label] === key(item) && key(kept) !== key(item))) byLabel.set(label, item); + } + return list.filter((item) => byLabel.get(roleLabel(key(item))) === item); +}; + // Vai trò gắn với một cơ sở cụ thể (BE: chỉ STAFF / MANAGER được phân công cơ sở) export const FACILITY_ROLES = ["STAFF", "MANAGER"]; export const needsFacility = (roles = []) => roles.some((r) => FACILITY_ROLES.includes(r)); diff --git a/progress.md b/progress.md index 82c81ec..84b635a 100644 --- a/progress.md +++ b/progress.md @@ -1,3 +1,17 @@ +## 2026-11-02 — F40: sửa giật/chớp khi bấm trong khu Nhân viên, Quản lý cơ sở, Vận hành KD, Quản trị + +- Nguyên nhân: `#main` trong `src/app/App.jsx` đổi `key` theo đường dẫn, mà header/menu (`*Layout.jsx`) và `OpsProvider` nằm trong `#main`. Mỗi lần bấm menu/nút đổi trang, cả header, menu và dữ liệu vận hành bị dựng lại: hiện "Đang tải dữ liệu vận hành…", gọi lại `/api/ops/board`, chiều cao `--site-header-height` bị xoá rồi đo lại, cộng hiệu ứng `ss-page-in` (mờ từ 0 + trượt 6 px) chạy lại cho cả màn hình. `router.js` còn cuộn lên đầu cả khi chỉ đổi `?id`/bộ lọc. +- Sửa: khu staff/manager/business/admin giữ `key` theo khu; nội dung từng trang vẫn dựng lại nhờ `React.Fragment key` trong `AdminRoutes`, `BusinessRoutes`, `FacilityOperationsRoutes`. `OpsProvider` nhận `navKey` và nạp lại board ngầm khi đổi trang (giữ dữ liệu đang hiện, không bật màn tải). `router.js` chỉ cuộn lên đầu khi đổi đường dẫn. `motion.css`: chuyển trang chỉ mờ nhẹ 0.55→1 trong 0.15 s, bỏ trượt. Khu khách hàng giữ cách dựng lại theo đường dẫn như cũ. +- Kiểm tra (Node 22.23, nối sau patch hiển thị 02/11): `check:structure` PASS, `npm test` 155/155, `test:business` 9/9, `test:render` 173 route PASS, `build` PASS (cảnh báo bundle >500 kB có sẵn). Đo bằng Chromium headless trên `MOCK_OPS=1 npm run dev:mock`, đăng nhập manager01, bấm 6 mục menu: bản cũ header dựng lại 5 lần, hiện màn "Đang tải…" 5 lần, 10 lần gọi board; bản sửa 0, 0 và 5 lần gọi board ngầm. Đây là mock API, chưa kiểm với backend .NET/SQL Server thật. Không đổi API, nghiệp vụ hay trạng thái tính năng. + +## 2026-11-02 — F40: sửa hiển thị theo Figma (M07, A02/A05, B04, C11 gia hạn) + +- M07 `#/manager/contracts`: "Xem hồ sơ" cuộn tới khối chi tiết (trước đó chi tiết hiện ở cuối trang nên trông như không chuyển trang); bỏ hai nút hoàn tiền lặp trong khối chi tiết, gom vào một thẻ cuối trang như Figma; thẻ hồ sơ xếp sát nhau, nhãn trạng thái và nút cùng một hàng bên phải (áp dụng mọi `RecordCard`). +- A02 thêm tài khoản: bỏ mục "Vận hành KD" lặp (DB có cả `OPERATIONS` và `BUSINESS_OPERATOR`; giữ `OPERATIONS`); chia hai nhóm: Nhân viên/Quản lý cơ sở (cần cơ sở) ở trên, Khách hàng/Vận hành KD/Quản trị ở dưới. A05: nút "Gỡ vai trò" trong chip không còn bị bóp thành ô tròn 22 px. +- B04: cột biểu đồ tối đa 220 px, ít cơ sở không kéo hết chiều ngang. +- C11 theo dõi gia hạn: đã chọn thu tại quầy thì ẩn nút "Thanh toán PayOS" (BE đã huỷ link PayOS khi chọn quầy, T04). +- Kiểm tra: `check:structure` PASS, `npm test` 155/155, `test:business` 9/9, `test:workflows` 12/12, `test:render` 173 route PASS, `build` PASS. `test:approved-ui` lỗi môi trường cả trước và sau khi sửa (không có trình duyệt). Chưa xem trên trình duyệt thật; không đổi trạng thái tính năng. + ## 2026-11-02 — F40: hiệu ứng chuyển cảnh dùng chung + chốt D34 - Theo yêu cầu thành viên FE: thêm `src/shared/styles/motion.css` (mới), import một lần trong `src/app/App.jsx` ngay sau `ss.css`. Chỉ thêm hiệu ứng, không đổi màu, kích thước, bố cục, route, API hay nghiệp vụ.