From 4500d800a9aa635105db91e38a9a86cb50e9fd24 Mon Sep 17 00:00:00 2001 From: Vector Date: Wed, 14 Oct 2026 22:34:35 +0700 Subject: [PATCH] =?UTF-8?q?feat(F30):=20=C4=91=E1=BB=93ng=20b=E1=BB=99=20g?= =?UTF-8?q?iao=20di=E1=BB=87n=20v=E1=BB=9Bi=20Figma=20m=E1=BB=9Bi=20nh?= =?UTF-8?q?=E1=BA=A5t=20s=E1=BB=ADa=20nh=E1=BB=AFng=20l=E1=BB=97i=20th?= =?UTF-8?q?=E1=BA=A7y=20coment=20tr=C3=AAn=20l=E1=BB=9Bp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 + DECISIONS.md | 10 + README.md | 4 + .../SafeSpace-Customer-UI/src/api/mappers.js | 1 - .../src/components/UnitMap.jsx | 2 +- .../SafeSpace-Customer-UI/src/data/seed.js | 62 ++-- .../SafeSpace-Customer-UI/src/lib/catalog.js | 28 +- .../SafeSpace-Customer-UI/src/lib/format.js | 3 - .../SafeSpace-Customer-UI/src/lib/units.js | 44 ++- .../src/ops/OpsShell.jsx | 8 +- .../SafeSpace-Customer-UI/src/ops/tasks.jsx | 2 +- .../src/pages/Checkout.jsx | 2 - .../src/pages/FacilityDetail.jsx | 5 +- .../src/pages/FindList.jsx | 10 +- .../src/pages/FindMap.jsx | 2 +- .../SafeSpace-Customer-UI/src/pages/Home.jsx | 312 ++++++++++++++---- .../src/pages/Public.jsx | 17 +- .../SafeSpace-Customer-UI/src/styles/ss.css | 116 +++++-- .../tests/api-mappers.test.js | 4 +- .../tests/reducer.test.js | 13 +- .../tests/render.test.mjs | 2 +- .../SafeSpace-Customer-UI/tests/units.test.js | 47 ++- progress.md | 20 ++ 23 files changed, 507 insertions(+), 209 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 88d598f..d278381 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,6 +17,8 @@ 9. **Không xoá/sửa test để cho pass.** Test sai → ghi lý do trong `progress.md` rồi mới sửa. 10. Làm trên nhánh `feature/` → Pull Request vào `main`. Không push thẳng `main`. 11. Tiếng Việt cho giao diện và tài liệu; tên biến, hàm, API bằng tiếng Anh. +12. **AI không được tự `git push`, tạo Pull Request hay merge lên repo này.** Chỉ sửa code và commit trên máy; + giao lại cho thành viên nhóm (patch / file zip / hướng dẫn lệnh) để người đó tự kiểm tra rồi tự push. ## 2. Dự án là gì diff --git a/DECISIONS.md b/DECISIONS.md index 6ba929d..ab865f4 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -86,3 +86,13 @@ "Cọc còn giữ"; "Doanh thu thuê và phí" không trừ REFUND. Khi thêm hoàn tiền thuê/phí thì phải thêm liên kết khoản gốc. - Cơ sở `TEMPORARILY_CLOSED` chặn đặt chỗ mới; `INACTIVE` chỉ khi không còn hợp đồng / đơn đang xử lý. Không xoá cơ sở. +## D17 — Mô hình kho theo Figma 14/10: 2 cỡ, mọi cơ sở có kho lạnh, gợi ý theo khu vực — Đã chốt (14/10/2026) +- Chỉ còn 2 cỡ kho: **Cỡ M · 15 m²** và **Cỡ L · 30 m²** (bỏ cỡ S). Loại kho từ backend: diện tích ≤ 20 m² là M, lớn hơn là L. +- Cả 12 cơ sở đều có kho thường và kho lạnh. Mỗi cơ sở 12 ô: 8 kho thường (4 M + 4 L) và 4 kho lạnh (2 M + 2 L). + Sơ đồ ô kho: dãy A cỡ M (K01–K04 thường, K05–K06 lạnh), dãy B cỡ L (K07–K10 thường, K11–K12 lạnh). +- Gợi ý cơ sở theo **khu vực khách chọn**, không theo vị trí người dùng: bỏ "Gần bạn nhất" và "Cách bạn … km". +- Tên loại kho hiển thị là "Kho lạnh" (thay "Kiểm soát nhiệt độ") cho khớp Figma. +- Nhân viên / quản lý cơ sở thấy tên cơ sở phụ trách dưới vai trò trên header (SRS A06: mỗi người 1 cơ sở). +- Trang chủ theo Figma mới: hero ảnh + tìm theo khu vực, số liệu, 4 loại kho, 3 bước, cơ sở theo khu vực, kêu gọi, footer. +- Backend cần đổi seed cho khớp (4 loại kho, 12 cơ sở, 12 ô mỗi cơ sở) — chưa làm. + diff --git a/README.md b/README.md index a88e8e9..355340e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Hệ thống quản lý và cho thuê kho tự quản thông minh (SafeSpace Sel --- +> **Quy định cho công cụ AI (Claude, Cursor, Copilot, Codex…):** AI chỉ được sửa code và commit trên máy, +> **không được tự `git push`, tạo Pull Request hay merge** lên repo này. Thành viên nhóm tự kiểm tra rồi tự push. +> Quy tắc đầy đủ cho AI nằm trong [`AGENTS.md`](AGENTS.md). + ## 📋 Yêu Cầu Môi Trường (Prerequisites) Trước khi chạy dự án, hãy đảm bảo máy tính đã cài đặt các công cụ sau: diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/api/mappers.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/api/mappers.js index 9093887..c732f67 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/api/mappers.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/api/mappers.js @@ -82,7 +82,6 @@ export function mapCatalog({ facilities = [], unitTypes = [], rates = [] }) { city, phone: f.contactPhone || "", hours: open && close ? `${open}–${close}` : "06:00–22:00", - distance_km: null, camera: true, has_climate: offers.some((o) => o.type === "climate"), offers, diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/components/UnitMap.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/components/UnitMap.jsx index 240281c..95308fe 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/components/UnitMap.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/components/UnitMap.jsx @@ -2,7 +2,7 @@ import React from "react"; import { typeLabel } from "../lib/catalog"; import { LEGEND, UNIT_STATUS, countBy, freeCount } from "../lib/units"; -// Sơ đồ 10 ô kho (Figma C03b-sđ): chú giải, dãy A – hành lang – dãy B, ô đang chọn có viền sáng. +// Sơ đồ 12 ô kho (Figma C03b-sđ, 14/10): chú giải, dãy A cỡ M – hành lang – dãy B cỡ L, ô đang chọn có viền sáng. export default function UnitMap({ units, selected, onSelect }) { const counts = countBy(units); const rowA = units.filter((u) => u.row === "A"); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/data/seed.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/data/seed.js index 9fadd1c..c04c3b3 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/data/seed.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/data/seed.js @@ -4,32 +4,32 @@ import { addDays, addMonths, today } from "../lib/format.js"; export const SEED_EMAIL = "mai.nguyen@example.com"; export const SEED_PASSWORD = "SafeSpace@123"; -// Danh sách 12 cơ sở SafeSpace (tên, giá, khoảng cách theo Figma C02). +// Danh sách 12 cơ sở SafeSpace (Figma 14/10). Cơ sở nào cũng có kho thường và kho lạnh, cỡ M và L. +// Gợi ý theo khu vực khách chọn, không theo vị trí người dùng → không có khoảng cách. const FACILITIES = [ - [1, "SafeSpace Nguyễn Lương Bằng", "Quận 7", 1.2, 1150000, true, "Số 12 Nguyễn Lương Bằng, Tân Phú"], - [2, "SafeSpace Him Lam", "Quận 7", 2.8, 1050000, true, "Khu dân cư Him Lam, Tân Hưng"], - [3, "SafeSpace Phú Xuân", "Quận 7", 5.4, 890000, true, "Đường Nguyễn Hữu Thọ, Phú Xuân"], - [4, "SafeSpace Tân Thuận", "Quận 4", 6.1, 1100000, true, "Đường Huỳnh Tấn Phát, Tân Thuận"], - [5, "SafeSpace Phú Mỹ Hưng", "Huyện Nhà Bè", 6.8, 1250000, true, "Đường Nguyễn Lương Bằng, Phú Mỹ"], - [6, "SafeSpace Bình Thạnh", "Quận Bình Thạnh", 8.7, 980000, true, "Đường Nguyễn Xí, Phường 26"], - [7, "SafeSpace Nhà Bè", "Huyện Nhà Bè", 9.3, 850000, true, "Đường Huỳnh Tấn Phát, Thị trấn Nhà Bè"], - [8, "SafeSpace Bình Chánh", "Huyện Bình Chánh", 12.4, 790000, false, "Quốc lộ 50, Bình Chánh"], - [9, "SafeSpace Thủ Đức", "TP. Thủ Đức", 15.2, 920000, false, "Đường Võ Văn Ngân, Linh Chiểu"], - [10, "SafeSpace Gò Vấp", "Quận Gò Vấp", 16.8, 930000, true, "Đường Quang Trung, Phường 10"], - [11, "SafeSpace Tân Bình", "Quận Tân Bình", 18.1, 1020000, true, "Đường Cộng Hòa, Phường 13"], - [12, "SafeSpace Bình Tân", "Quận Bình Tân", 19.5, 820000, false, "Đường Kinh Dương Vương, An Lạc"], + [1, "SafeSpace Nguyễn Lương Bằng", "Quận 7", 1150000, "Số 12 Nguyễn Lương Bằng, Tân Phú"], + [2, "SafeSpace Him Lam", "Quận 7", 1050000, "Khu dân cư Him Lam, Tân Hưng"], + [3, "SafeSpace Phú Xuân", "Quận 7", 890000, "Đường Nguyễn Hữu Thọ, Phú Xuân"], + [4, "SafeSpace Tân Thuận", "Quận 7", 1100000, "Đường Huỳnh Tấn Phát, Tân Thuận"], + [5, "SafeSpace Phú Mỹ Hưng", "Quận 7", 1250000, "Đường Nguyễn Lương Bằng, Tân Phong"], + [6, "SafeSpace Bình Thạnh", "Quận Bình Thạnh", 980000, "Đường Nguyễn Xí, Phường 26"], + [7, "SafeSpace Nhà Bè", "Huyện Nhà Bè", 850000, "Đường Huỳnh Tấn Phát, Thị trấn Nhà Bè"], + [8, "SafeSpace Bình Chánh", "Huyện Bình Chánh", 790000, "Quốc lộ 50, Bình Hưng"], + [9, "SafeSpace Thủ Đức", "TP. Thủ Đức", 920000, "Đường Võ Văn Ngân, Linh Chiểu"], + [10, "SafeSpace Gò Vấp", "Quận Gò Vấp", 930000, "Đường Quang Trung, Phường 10"], + [11, "SafeSpace Tân Bình", "Quận Tân Bình", 1020000, "Đường Cộng Hòa, Phường 13"], + [12, "SafeSpace Bình Tân", "Quận Bình Tân", 820000, "Đường Kinh Dương Vương, An Lạc"], ]; export function createFacilities() { - return FACILITIES.map(([facility_id, name, district, distance_km, base_price, has_climate, street]) => withOffers({ + return FACILITIES.map(([facility_id, name, district, base_price, street]) => withOffers({ facility_id, name, district, city: "TP. Hồ Chí Minh", address: `${street}, ${district}, TP. Hồ Chí Minh`, - distance_km, base_price, - has_climate, + has_climate: true, camera: true, hours: "06:00–22:00", })); @@ -59,7 +59,7 @@ export function createSeedData(t = today()) { type: "normal", band: "M", offer_key: "normal-M", - size_label: "10 – 20 m²", + size_label: "Cỡ M · 15 m²", months: 3, start_date: t, end_date: a102End, @@ -74,16 +74,16 @@ export function createSeedData(t = today()) { reservation_id: "SS-20260615-0086", facility_id: 1, type: "climate", - band: "S", - offer_key: "climate-S", - size_label: "2 – 5 m²", + band: "M", + offer_key: "climate-M", + size_label: "Cỡ M · 15 m²", months: 3, start_date: b015Start, end_date: b015End, - monthly_rate: 500000, - deposit: 500000, - rent_total: 1500000, - initial_total: 2000000, + monthly_rate: 1380000, + deposit: 1380000, + rent_total: 4140000, + initial_total: 5520000, status: "CHECKED_IN", created_at: at(addDays(b015Start, -2), "14:30"), }, @@ -96,7 +96,7 @@ export function createSeedData(t = today()) { unit_number: "A-102", type: "normal", band: "M", - size_m2: 12, + size_m2: 15, location: "Tầng 1 · Dãy A", months: 3, start_date: t, @@ -112,14 +112,14 @@ export function createSeedData(t = today()) { facility_id: 1, unit_number: "B-015", type: "climate", - band: "S", - size_m2: 5, + band: "M", + size_m2: 15, location: "Tầng 1 · Dãy B", months: 3, start_date: b015Start, end_date: b015End, - monthly_rate: 500000, - deposit: 500000, + monthly_rate: 1380000, + deposit: 1380000, status: "EXPIRING", handed_over: true, }, @@ -146,7 +146,7 @@ export function createSeedData(t = today()) { label: "Thuê kho B-015 · 3 tháng", contract_id: "HĐ-2026-0086", reservation_id: "SS-20260615-0086", - amount: 1500000, + amount: 4140000, status: "RECONCILED", }, { @@ -154,7 +154,7 @@ export function createSeedData(t = today()) { label: "Cọc hợp đồng B-015", contract_id: "HĐ-2026-0086", reservation_id: "SS-20260615-0086", - amount: 500000, + amount: 1380000, status: "DEPOSIT_HELD", }, ], diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/catalog.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/catalog.js index a757636..0805791 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/catalog.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/catalog.js @@ -2,18 +2,18 @@ import { addMonths } from "./format.js"; export const UNIT_TYPES = [ { id: "normal", label: "Kho thường" }, - { id: "climate", label: "Kiểm soát nhiệt độ" }, + { id: "climate", label: "Kho lạnh" }, ]; export const typeLabel = (id) => UNIT_TYPES.find((t) => t.id === id)?.label || "Kho thường"; -// Nhóm diện tích theo Figma (C03 "10 – 20 m²", P01 "2–5 m²" / "Trên 20 m²") +// Hai cỡ kho theo Figma 14/10: mỗi cơ sở có 8 kho thường (4 M + 4 L) và 4 kho lạnh (2 M + 2 L) export const SIZE_BANDS = [ - { id: "S", label: "2 – 5 m²", name: "Small", note: "Vali, tài liệu và đồ cá nhân" }, - { id: "M", label: "10 – 20 m²", name: "Medium", note: "Đồ nội thất và hàng kinh doanh" }, - { id: "L", label: "Trên 20 m²", name: "Large", note: "Nhiều hàng hóa và nhu cầu dài hạn" }, + { id: "M", label: "Cỡ M · 15 m²", short: "15 m²", area: 15, name: "Cỡ M", note: "Đồ đạc một phòng, hàng shop online, hồ sơ giấy tờ" }, + { id: "L", label: "Cỡ L · 30 m²", short: "30 m²", area: 30, name: "Cỡ L", note: "Đồ chuyển nhà 2–3 phòng ngủ, hàng tồn kho số lượng lớn" }, ]; -export const bandLabel = (id) => SIZE_BANDS.find((b) => b.id === id)?.label || "10 – 20 m²"; -export const bandOfArea = (area) => (area <= 5 ? "S" : area <= 20 ? "M" : "L"); +export const bandLabel = (id) => SIZE_BANDS.find((b) => b.id === id)?.label || SIZE_BANDS[0].label; +// Loại kho từ backend: đến 20 m² là cỡ M, lớn hơn là cỡ L +export const bandOfArea = (area) => (area <= 20 ? "M" : "L"); // Gói thuê trong Figma: 1 / 3 / 6 tháng export const RENTAL_PLANS = [1, 3, 6]; @@ -25,7 +25,7 @@ export const BUDGET_LIMIT = 1100000; // chip "Dưới 1.100.000 đ / tháng" // - Dữ liệu cục bộ: sinh từ giá gốc của cơ sở × loại kho × nhóm diện tích // - Backend: mỗi loại kho (UnitType) có bảng giá tại cơ sở là một offer -const BAND_FACTOR = { S: 0.63, M: 1, L: 1.75 }; +const BAND_FACTOR = { M: 1, L: 1.75 }; const TYPE_FACTOR = { normal: 1, climate: 1.2 }; const round10k = (n) => Math.round(n / 10000) * 10000; @@ -51,7 +51,7 @@ export const offerLabel = (o) => `${typeLabel(o.type)} · ${o.size_label}`; const matches = (o, f) => (!f.type || o.type === f.type) && (!f.band || o.band === f.band); -// Gói hiển thị trên thẻ cơ sở: khớp bộ lọc; nếu chưa lọc thì ưu tiên "Kho thường · 10 – 20 m²" như Figma +// Gói hiển thị trên thẻ cơ sở: khớp bộ lọc; nếu chưa lọc thì ưu tiên "Kho thường · Cỡ M" như Figma export function displayOffer(facility, filters = {}) { const list = (facility?.offers || []).filter((o) => matches(o, filters)); if (!list.length) return null; @@ -94,12 +94,6 @@ export const DEFAULT_FILTERS = { type: "", band: "", area: "", camera: false, bu export const hasActiveFilters = (f) => Boolean(f.type || f.band || f.area || f.camera || f.budget); -// Theo khoảng cách; không có khoảng cách (dữ liệu backend) thì giữ thứ tự danh mục (sort ổn định) -const byDistance = (a, b) => { - if (a.distance_km == null || b.distance_km == null) return (a.distance_km == null) - (b.distance_km == null); - return a.distance_km - b.distance_km; -}; - // Lọc + sắp xếp danh sách cơ sở (C02 / C03) export function searchFacilities(facilities, filters) { const f = { ...DEFAULT_FILTERS, ...filters }; @@ -111,6 +105,8 @@ export function searchFacilities(facilities, filters) { if (f.budget && offer.monthly_rate >= BUDGET_LIMIT) return false; return true; }); + // Gợi ý theo khu vực khách chọn (không theo vị trí): "Phù hợp nhất" giữ thứ tự danh mục, hoặc sắp theo giá + if (f.sort !== "price") return list; const price = (x) => displayOffer(x, f).monthly_rate; - return [...list].sort((a, b) => (f.sort === "price" ? price(a) - price(b) || byDistance(a, b) : byDistance(a, b))); + return [...list].sort((a, b) => price(a) - price(b)); } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/format.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/format.js index ba1a697..85a5d59 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/format.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/format.js @@ -58,9 +58,6 @@ export function daysBetween(fromIso, toIso) { return Math.round((parse(toIso) - parse(fromIso)) / 86400000); } -export const distanceLabel = (km) => - `${new Intl.NumberFormat("vi-VN", { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(km)} km`; - // Số điện thoại hiển thị dạng che bớt: 09•• ••• 142 export function maskPhone(phone) { const digits = String(phone || "").replace(/\D/g, ""); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/units.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/units.js index 9aa704e..f771adb 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/units.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/lib/units.js @@ -1,7 +1,7 @@ // Sơ đồ & tình trạng từng ô kho của một cơ sở (Figma C03b-sđ). // Backend chưa có API danh sách ô kho → sinh cố định theo mã cơ sở. Khi có API, // thay unitsFor() bằng dữ liệu StorageUnit (UnitNumber, Floor, Zone, Status, UnitType). -import { offerByKey } from "./catalog.js"; +import { SIZE_BANDS } from "./catalog.js"; // Trạng thái ô kho hiển thị cho khách (map từ StorageUnit.Status của backend) export const UNIT_STATUS = { @@ -16,42 +16,38 @@ export const LEGEND = ["FREE", "RENTED", "HELD", "SERVICE"]; export const fromBackendStatus = (s) => s === "AVAILABLE" ? "FREE" : s === "RESERVED" || s === "ASSIGNED" ? "HELD" : ["MAINTENANCE", "INSPECTION", "OUT_OF_SERVICE"].includes(s) ? "SERVICE" : "RENTED"; -// Bố cục theo Figma: dãy A (K01–K05, 5 m²) và dãy B (K06–K10, 10 m²), hành lang ở giữa +// Bố cục theo Figma 14/10: 12 ô, hành lang ở giữa. +// Dãy A cỡ M: K01–K04 kho thường, K05–K06 kho lạnh. Dãy B cỡ L: K07–K10 kho thường, K11–K12 kho lạnh. const LAYOUT = [ - ["K01", "A", 5], ["K02", "A", 5], ["K03", "A", 5], ["K04", "A", 5], ["K05", "A", 5], - ["K06", "B", 10], ["K07", "B", 10], ["K08", "B", 10], ["K09", "B", 10], ["K10", "B", 10], + ["K01", "A", "normal", "M"], ["K02", "A", "normal", "M"], ["K03", "A", "normal", "M"], ["K04", "A", "normal", "M"], + ["K05", "A", "climate", "M"], ["K06", "A", "climate", "M"], + ["K07", "B", "normal", "L"], ["K08", "B", "normal", "L"], ["K09", "B", "normal", "L"], ["K10", "B", "normal", "L"], + ["K11", "B", "climate", "L"], ["K12", "B", "climate", "L"], ]; // Tình trạng mẫu của Figma, xoay vòng theo mã cơ sở để mỗi cơ sở khác nhau nhưng luôn ổn định -const PATTERN = ["FREE", "RENTED", "FREE", "HELD", "FREE", "RENTED", "FREE", "SERVICE", "FREE", "RENTED"]; -const COLD = ["K04", "K05", "K09", "K10"]; +const PATTERN = ["FREE", "RENTED", "FREE", "HELD", "FREE", "RENTED", "FREE", "SERVICE", "FREE", "RENTED", "FREE", "RENTED"]; const NON_FREE = ["RENTED", "HELD", "SERVICE"]; const areaText = (n) => `${String(n).replace(".", ",")} m²`; +const BAND_AREA = Object.fromEntries(SIZE_BANDS.map((b) => [b.id, b.area])); -// Gán gói kho cho 10 ô: dữ liệu cục bộ theo bố cục Figma (5 m² / 10 m²); -// dữ liệu backend (gói theo UnitType) → dãy A nhận các loại nhỏ, dãy B các loại lớn. +// Gán gói kho cho 12 ô theo loại (thường / lạnh) và cỡ (M / L). +// Dữ liệu backend chưa đủ 4 loại thì ô lấy gói gần nhất: cùng loại + cùng cỡ → cùng cỡ → cùng loại → gói bất kỳ. function offersForLayout(facility) { const offers = facility.offers || []; - if (!offers.some((o) => o.unit_type_id)) { - return LAYOUT.map(([code, , area]) => { - const wantCold = facility.has_climate !== false && COLD.includes(code); - const band = area <= 5 ? "S" : "M"; - return { offer: offerByKey(facility, `${wantCold ? "climate" : "normal"}-${band}`) || offerByKey(facility, `normal-${band}`), area }; - }); - } - const sorted = [...offers].sort((x, y) => (x.area || 0) - (y.area || 0)); - const half = Math.max(1, Math.ceil(sorted.length / 2)); - const small = sorted.slice(0, half); - const large = sorted.length > 1 ? sorted.slice(half) : sorted; - return LAYOUT.map(([, row], i) => { - const pool = row === "A" ? small : large; - const offer = pool[(row === "A" ? i : i - 5) % pool.length]; - return { offer, area: offer?.area ?? (row === "A" ? 5 : 10) }; + return LAYOUT.map(([, , type, band]) => { + const offer = + offers.find((o) => o.type === type && o.band === band) || + offers.find((o) => o.band === band) || + offers.find((o) => o.type === type) || + offers[0] || + null; + return { offer, area: offer?.area ?? BAND_AREA[band] }; }); } /** - * 10 ô kho của một cơ sở. + * 12 ô kho của một cơ sở. * `stock` (không bắt buộc): { [offer.key]: số ô trống } lấy từ POST /api/availability/check — * khi có, số ô "Còn trống" của mỗi loại khớp đúng số backend trả về. */ diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/OpsShell.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/OpsShell.jsx index 699828b..45189d7 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/OpsShell.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/OpsShell.jsx @@ -79,7 +79,7 @@ function Bell({ role }) { ); } -function UserMenu({ roleLabel, tone }) { +function UserMenu({ roleLabel, tone, facilityName }) { const { user, logout } = useApp(); const [open, setOpen] = useState(false); const ref = useRef(null); @@ -89,6 +89,7 @@ function UserMenu({ roleLabel, tone }) { {open && (
@@ -116,7 +117,7 @@ function UserMenu({ roleLabel, tone }) { // Khung chung khu vận hành (Figma S01 / M01): logo, tên + vai trò, chuông, thanh điều hướng theo vai trò export default function OpsShell({ role, active, children }) { const { mode } = useApp(); - const { source } = useOps(); + const { source, ops } = useOps(); const staff = role === "STAFF"; const tabs = staff ? STAFF_TABS : MANAGER_TABS; const home = staff ? "staff" : "manager"; @@ -130,7 +131,8 @@ export default function OpsShell({ role, active, children }) {
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/tasks.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/tasks.jsx index 72623e4..eb7ffc0 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/tasks.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/ops/tasks.jsx @@ -73,7 +73,7 @@ export function staffTasks(ops, me, kind = "all") { list.push({ key: h.id, kind: "handover", status: ready ? ["Sẵn sàng bàn giao", "green"] : ["Chờ xác minh", "gray"], title: `Kho #${h.unit} · ${h.customer}`, - meta: `${ready ? "Đã xác minh khách · " : ""}${unit?.type === "climate" ? "Kiểm soát nhiệt độ" : "Kho thường"}${unit ? ` · ${unit.area} m²` : ""}`, + meta: `${ready ? "Đã xác minh khách · " : ""}${unit?.type === "climate" ? "Kho lạnh" : "Kho thường"}${unit ? ` · ${unit.area} m²` : ""}`, when: v ? `Hẹn ${slot(v.appointment)}` : "Chưa có lịch hẹn", cta: ready ? "Bàn giao" : "Xác minh trước", outline: !ready, to: ready ? `staff/handover?id=${h.id}` : `staff/verify?id=${v?.id}`, sort: v?.appointment || "", diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Checkout.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Checkout.jsx index 8c614c3..561ab0e 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Checkout.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Checkout.jsx @@ -3,7 +3,6 @@ import { Photo } from "../components/Photo"; import { Button, DetailList, Empty, Icon, LinkButton, Notice } from "../components/UI"; import PaymentQr from "../components/PaymentQr"; import { bandLabel, typeLabel } from "../lib/catalog"; -import { distanceLabel } from "../lib/format"; import { dateLabel, formatCountdown, money, rangeLabel } from "../lib/format"; import { useNow, shortName } from "../lib/hooks"; import { go } from "../lib/router"; @@ -64,7 +63,6 @@ export function Checkout({ id }) {

{facility.name}

{[facility.district, facility.city].filter(Boolean).join(", ") || facility.address} - {facility.distance_km != null && ` · Cách bạn ${distanceLabel(facility.distance_km)}`}

diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FacilityDetail.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FacilityDetail.jsx index f427a38..8efb78c 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FacilityDetail.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FacilityDetail.jsx @@ -6,7 +6,7 @@ import { Button, Empty, Field, LinkButton, Notice } from "../components/UI"; import UnitMap from "../components/UnitMap"; import { RENTAL_PLANS, UNIT_TYPES, offerTypes, pickOffer, quote } from "../lib/catalog"; import { UNIT_STATUS, unitsFor } from "../lib/units"; -import { dateLabel, distanceLabel, money, today } from "../lib/format"; +import { dateLabel, money, today } from "../lib/format"; import { go, href, qs } from "../lib/router"; import { useApp } from "../state/store"; @@ -162,8 +162,7 @@ export default function FacilityDetail({ id, query }) {

{facility.name}

- {place} - {facility.distance_km != null && ` · Cách bạn ${distanceLabel(facility.distance_km)}`} · {stockText} + {place} · {stockText}

- @@ -101,7 +97,7 @@ export default function FindList({ query }) {

{f.name}

- {f.distance_km != null ? `${f.city} · Cách bạn ${distanceLabel(f.distance_km)}` : [f.district, f.city].filter(Boolean).join(", ")} + {[f.district, f.city].filter(Boolean).join(", ")}

{compactLabel(offer.size_label)} · {typeLabel(offer.type)} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FindMap.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FindMap.jsx index c1956da..c515a7e 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FindMap.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/FindMap.jsx @@ -10,7 +10,7 @@ import { go, href, qs } from "../lib/router"; import { useApp } from "../state/store"; import { filtersFromQuery } from "./FindList"; -// Nhãn loại kho & diện tích trên thẻ / popup: "Kho thường · Kiểm soát nhiệt độ | 2 – 5 m² · 10 – 20 m²" +// Nhãn loại kho & diện tích trên thẻ / popup: "Kho thường · Kho lạnh | Cỡ M · 15 m² · Cỡ L · 30 m²" function specLabel(f) { const types = offerTypes(f).map(typeLabel).join(" · "); const sizes = [...new Set(f.offers.map((o) => o.size_label.replaceAll(" – ", "–")))].slice(0, 2).join(" · "); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Home.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Home.jsx index 9c78160..5fba6a6 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Home.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Home.jsx @@ -1,96 +1,274 @@ import React, { useState } from "react"; import { Photo } from "../components/Photo"; -import { Pagination } from "../components/Pickers"; +import { Select } from "../components/Pickers"; import { Icon, LinkButton } from "../components/UI"; -import { minRate, offerTypes, typeLabel } from "../lib/catalog"; +import { SIZE_BANDS, UNIT_TYPES, areaLabel, listAreas, minRate } from "../lib/catalog"; import { money } from "../lib/format"; +import { go, href, qs } from "../lib/router"; import { useApp } from "../state/store"; -const PER_PAGE = 9; +// Trang chủ theo Figma "START · SafeSpace / Trang chủ" (14/10): +// hero ảnh + tìm kho theo khu vực → số liệu → 4 loại kho → 3 bước → cơ sở theo khu vực → kêu gọi → footer. +// Gợi ý theo khu vực khách chọn, không theo vị trí người dùng. -const FEATURES = [ - ["bolt", "Tiện lợi", "Đặt kho, quản lý và gia hạn chỉ trong vài thao tác, mọi lúc mọi nơi."], - ["shield", "An toàn", "Giám sát 24/7, kiểm soát ra vào chặt chẽ và bảo vệ tài sản của bạn."], - ["auto", "Tự động hoá", "Theo dõi tình trạng kho, lịch hẹn và hợp đồng rõ ràng trong một tài khoản."], +const UNITS_PER_FACILITY = 12; // 8 kho thường (4 M + 4 L) + 4 kho lạnh (2 M + 2 L) +const CARDS_SHOWN = 6; + +const KINDS = [ + { type: "normal", band: "M", note: "Đồ đạc một phòng, hàng shop online, hồ sơ giấy tờ." }, + { type: "normal", band: "L", note: "Đồ chuyển nhà 2–3 phòng ngủ, hàng tồn kho số lượng lớn." }, + { type: "climate", band: "M", note: "Thiết bị điện tử, tài liệu, đồ gỗ cần tránh ẩm." }, + { type: "climate", band: "L", note: "Hàng hoá cần giữ nhiệt độ ổn định, kho hàng cho cửa hàng." }, +]; + +const STEPS = [ + ["Chọn khu vực", "Chọn quận bạn muốn gửi đồ, SafeSpace gợi ý các cơ sở trong khu vực đó."], + ["Chọn loại và cỡ kho", "Kho thường hoặc kho lạnh, cỡ M hay L. Giá hiện rõ theo tháng."], + ["Xem ô trống và đặt chỗ", "Xem sơ đồ từng ô, tiền thuê, tiền cọc và thanh toán bằng QR."], ]; +const districtOf = (area) => area.split(",")[0].trim(); +const lowest = (facilities, filter) => { + const rates = facilities.map((f) => minRate(f, filter)).filter((x) => x != null); + return rates.length ? Math.min(...rates) : null; +}; + +function HeroSearch({ facilities }) { + const [draft, setDraft] = useState({ area: "", type: "", band: "" }); + const set = (key) => (e) => setDraft({ ...draft, [key]: e.target.value }); + return ( +

{ + e.preventDefault(); + go(`find${qs(draft)}`); + }} + > + + + + +
+ ); +} + +function FacilityCard({ f }) { + const from = minRate(f); + const types = [...new Set(f.offers.map((o) => o.type))]; + return ( + + +
+ {f.district || districtOf(areaLabel(f))} +

{f.name}

+
    + {types.includes("normal") &&
  • Kho thường
  • } + {types.includes("climate") &&
  • Kho lạnh
  • } +
  • Cỡ M · L
  • +
+
+

+ Từ + {from != null ? `${money(from)} / tháng` : "Liên hệ"} +

+ Xem ô trống → +
+
+
+ ); +} + export default function Home() { const { data, authed } = useApp(); - const [page, setPage] = useState(1); - const total = data.facilities.length; - const pages = Math.ceil(total / PER_PAGE); - const from = (page - 1) * PER_PAGE; - const shown = data.facilities.slice(from, from + PER_PAGE); + const facilities = data.facilities; + const [area, setArea] = useState(""); + const areas = listAreas(facilities); + const inArea = area ? facilities.filter((f) => areaLabel(f) === area) : facilities; + const shown = inArea.slice(0, CARDS_SHOWN); + const hours = facilities[0]?.hours || "06:00–22:00"; return ( <> -
-
-
- HỆ THỐNG KHO BÃI TỰ ĐỘNG -

- Thêm không gian. -
- Thêm an tâm. -

-

Tìm kho vừa nhu cầu, đặt chỗ rõ ràng và quản lý không gian lưu trữ của bạn ở một nơi.

-
- Bắt đầu ngay - Tìm hiểu thêm -
+
+ {facilities[0] && } +
+ {facilities.length} cơ sở · TP. Hồ Chí Minh +

+ Kho riêng an toàn, +
+ gần nơi bạn cần. +

+

+ Chọn khu vực, chọn kho thường hoặc kho lạnh cỡ M hay L,{" "} +
+ xem ô còn trống và chi phí trước khi đặt. +

+ +
+
+ +
+
+

{facilities.length}cơ sở tại TP.HCM

+

{facilities.length * UNITS_PER_FACILITY}ô kho cỡ M và L

+

24/7camera giám sát

+

{hours}ra vào mỗi ngày

+
+
+ +
+
+
+ Loại kho +

Hai cỡ kho, thường hoặc lạnh

+

Mỗi cơ sở có 8 kho thường và 4 kho lạnh, chia đều cỡ M và L.

+
+
+ {KINDS.map(({ type, band, note }) => { + const size = SIZE_BANDS.find((b) => b.id === band); + const from = lowest(facilities, { type, band }); + return ( + + {type === "climate" ? "Kho lạnh" : "Kho thường"} +

{size.label}

+

{note}

+

+ Giá từ + {from != null ? `${money(from)} / tháng` : "Xem giá theo cơ sở"} +

+ Xem cơ sở còn trống → +
+ ); + })}
-
-
-
- {FEATURES.map(([icon, title, text], i) => ( -
- - - -

{title}

-

{text}

-
- ))} +
+
+
+ Cách đặt kho +

Đặt kho trong 3 bước

+
+
    + {STEPS.map(([title, text], i) => ( +
  1. + {i + 1} +

    {title}

    +

    {text}

    +
  2. + ))} +
-
-

Một không gian phù hợp, gần bạn

-

Xem hình ảnh cơ sở, diện tích và giá thuê trước khi đặt chỗ.

-
- {shown.map((f) => ( -
- -

{f.name}

-

{minRate(f) != null ? `Từ ${money(minRate(f))} / tháng` : "Liên hệ để nhận giá"}

-

{offerTypes(f).map(typeLabel).join(" · ") || "Kho thường"}

- Khám phá cơ sở -
- ))} +
+
+
+ Cơ sở +

Chọn khu vực, xem cơ sở gần đó

+
+
+ + {areas.map((a) => ( + + ))} +
+
+ {shown.map((f) => ( + + ))} +
+ + {area ? `Xem tất cả ${inArea.length} cơ sở tại ${districtOf(area)} →` : `Xem tất cả ${facilities.length} cơ sở →`} +
-
-
-

Sẵn sàng bắt đầu?

-

{authed ? "Chào mừng bạn quay lại SafeSpace." : "Khách hàng mới tạo tài khoản nhanh chóng chưa đầy 1 phút."}

-
- {authed ? ( - <> - Tìm kho mới - Xem tổng quan - - ) : ( - <> - Tạo tài khoản khách hàng - Đăng nhập - - )} +
+
+
+
+

{authed ? "Chào mừng bạn quay lại SafeSpace" : "Quản lý mọi kho thuê trong một tài khoản"}

+

Theo dõi đặt chỗ, hợp đồng, thanh toán, gia hạn và yêu cầu hỗ trợ.

+
+
+ {authed ? ( + <> + Xem tổng quan + Tìm kho mới + + ) : ( + <> + Tạo tài khoản + Đăng nhập + + )} +
+
+ + ); } diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Public.jsx b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Public.jsx index eb434c7..ceb4f20 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Public.jsx +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/pages/Public.jsx @@ -8,16 +8,21 @@ export function Pricing() { const { data } = useApp(); return (
- -
+ +
{SIZE_BANDS.map((b) => { - const rates = data.facilities.map((f) => minRate(f, { band: b.id })).filter((x) => x != null); - const min = rates.length ? Math.min(...rates) : null; + const from = (type) => { + const rates = data.facilities.map((f) => minRate(f, { band: b.id, type })).filter((x) => x != null); + return rates.length ? Math.min(...rates) : null; + }; + const normal = from("normal"); + const cold = from("climate"); return (

{b.name}

- {b.label.replaceAll(" – ", "–")} -

{min == null || b.id === "L" ? "Xem giá theo cơ sở" : `Từ ${money(min)} / tháng`}

+ {b.short} +

{normal == null ? "Xem giá theo cơ sở" : `Từ ${money(normal)} / tháng`}

+ {cold != null &&

Kho lạnh từ {money(cold)} / tháng

}

{b.note}

Tìm kho phù hợp
diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/styles/ss.css b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/styles/ss.css index 1b0843e..6a449a3 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/styles/ss.css +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/src/styles/ss.css @@ -169,21 +169,6 @@ h4 { font-size: 16px; font-weight: 700; color: var(--ink); } .pagination p { font-size: 13px; color: var(--muted); } /* ---------- Home ---------- */ -.hero { background: var(--ink); color: #fff; } -.hero__inner { max-width: 1440px; margin: 0 auto; padding: 72px var(--pad-x); display: grid; grid-template-columns: 1fr 1.15fr; gap: 56px; align-items: center; } -.hero h1 { font-size: 46px; line-height: 1.12; font-weight: 800; margin: 18px 0 16px; color: #fff; } -.hero p { color: #cbd5e1; font-size: 17px; max-width: 460px; } -.hero__actions { display: flex; gap: 12px; margin-top: 28px; } -.hero__photo { border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 10; } -.features { background: #eef1f8; padding: 44px 0; margin-bottom: 0; } -.features__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; } -.feature { padding: 22px 24px; display: grid; gap: 8px; } -.feature__icon { width: 36px; height: 36px; border-radius: 10px; background: var(--soft); color: var(--blue); display: grid; place-items: center; } -.feature__icon--dark { background: var(--ink); color: #fff; } -.feature p { color: var(--muted); font-size: 14.5px; } -.home-list { padding-top: 56px; padding-bottom: 72px; } -.home-list h2 { font-size: 26px; font-weight: 800; } -.home-list .lead { margin: 8px 0 24px; font-size: 15px; } .facility-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } .facility-card { padding: 12px 12px 20px; display: grid; gap: 6px; align-content: start; } .facility-card h3 { font-size: 19px; margin-top: 12px; } @@ -194,10 +179,6 @@ h4 { font-size: 16px; font-weight: 700; color: var(--ink); } .facility-card--compact .price { font-size: 14px; } .facility-card--compact .muted { font-size: 13px; } .facility-card .price { margin-top: 8px; } -.cta { background: var(--ink); color: #fff; text-align: center; padding: 56px 24px 64px; } -.cta h2 { color: #fff; font-size: 26px; font-weight: 800; } -.cta p { color: #cbd5e1; margin: 10px 0 22px; } -.cta__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; } /* Photos */ .photo { position: relative; overflow: hidden; border-radius: 10px; background: #dbeafe; aspect-ratio: 16 / 10; } @@ -424,6 +405,7 @@ a.cell-strong:hover { color: var(--blue); } .usermenu__btn:hover { background: var(--soft); } .usermenu__btn strong { font-size: 15px; font-weight: 500; color: var(--text); } .usermenu__btn small { font-size: 12.5px; color: var(--red); font-weight: 600; } +.usermenu__facility { font-size: 12px; color: var(--muted); font-weight: 400; } .usermenu__pop { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(16, 21, 42, 0.15); padding: 12px; min-width: 220px; z-index: 55; display: grid; gap: 10px; } .usermenu__pop p { font-size: 14px; font-weight: 600; color: var(--ink); } .usermenu__pop p span { font-weight: 400; color: var(--muted); font-size: 13px; } @@ -468,6 +450,7 @@ a.cell-strong:hover { color: var(--blue); } .inline-form { flex-direction: column; align-items: stretch; } .admin-form { padding: 22px 18px; } .usermenu__btn strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; } + .usermenu__facility { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; } } /* ---------- Responsive ---------- */ @@ -524,10 +507,11 @@ a.cell-strong:hover { color: var(--blue); } .unit-dot--service, .unit-tile--service { background: #f9e9e5; } .unit-dot--free { border-color: var(--blue); } .unit-plan { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; } -.unit-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; } -.unit-tile { border: 0; border-radius: 10px; min-height: 130px; padding: 12px 6px; display: grid; align-content: center; justify-items: center; gap: 6px; cursor: pointer; color: var(--text); font-size: 14px; box-shadow: inset 0 0 0 0 transparent; transition: transform 0.12s, box-shadow 0.12s; } +.unit-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; } +.unit-tile { border: 0; border-radius: 10px; min-height: 130px; padding: 12px 4px; text-align: center; display: grid; align-content: center; justify-items: center; gap: 6px; cursor: pointer; color: var(--text); font-size: 14px; box-shadow: inset 0 0 0 0 transparent; transition: transform 0.12s, box-shadow 0.12s; } .unit-row--tall .unit-tile { min-height: 170px; } .unit-tile strong { font-size: 22px; font-weight: 700; } +.unit-tile span { font-size: 13px; white-space: nowrap; } .unit-tile--free { color: #fff; } .unit-tile:hover { transform: translateY(-2px); } .unit-tile.is-selected { box-shadow: inset 0 0 0 4px var(--soft), 0 0 0 2px var(--blue); } @@ -677,3 +661,93 @@ label.search-input input { border: 0; outline: 0; flex: 1; font-size: 14px; back .map-empty strong { font-size: 18px; color: var(--ink); } .map-empty span { color: var(--muted); } .ops-banner { max-width: 1440px; margin: 16px auto 0; padding: 10px var(--pad-x); background: var(--amber-bg); color: var(--amber); font-size: 14px; } + +/* ---------- Trang chủ (Figma START · Trang chủ, 14/10) ---------- */ +.home-hero { position: relative; overflow: hidden; background: var(--ink); color: #fff; } +.home-hero__bg { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; z-index: 0; } +.home-hero::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, rgba(16, 21, 42, 0.94) 0%, rgba(16, 21, 42, 0.72) 55%, rgba(16, 21, 42, 0.25) 100%); } +.home-hero__inner { position: relative; z-index: 2; max-width: 1440px; margin: 0 auto; padding: 104px var(--pad-x) 72px; display: grid; gap: 20px; justify-items: start; } +.home-hero__badge { border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; letter-spacing: 0.04em; } +.home-hero h1 { font-size: 64px; line-height: 1.08; font-weight: 800; letter-spacing: -0.02em; color: #fff; } +.home-hero p { font-size: 19px; line-height: 1.5; color: rgba(255, 255, 255, 0.86); } +.home-search { margin-top: 36px; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: center; background: #fff; color: var(--text); border-radius: 20px; padding: 12px; box-shadow: 0 18px 48px rgba(10, 20, 51, 0.28); } +.home-search__field { display: grid; gap: 4px; padding: 8px 20px; border-right: 1px solid var(--line); } +.home-search__field:nth-child(3) { border-right: 0; } +.home-search__field > span { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); } +.home-search__field select { border: 0; background-color: transparent; padding-left: 0; font-size: 17px; font-weight: 600; color: var(--text); } +.home-search__submit { padding: 18px 28px; border-radius: 14px; font-size: 16px; } +.home-stats { background: var(--white); border-bottom: 1px solid var(--line); } +.home-stats__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-top: 32px; padding-bottom: 32px; } +.home-stats__grid p { display: grid; gap: 2px; padding-left: 28px; border-left: 1px solid var(--line); } +.home-stats__grid p:first-child { padding-left: 0; border-left: 0; } +.home-stats__grid strong { font-size: 30px; font-weight: 800; color: var(--ink); line-height: 1.2; } +.home-stats__grid span { color: var(--muted); font-size: 15px; } +.home-section { background: var(--white); padding: 88px 0; } +.home-section--tint { background: var(--bg); } +.home-head { display: grid; gap: 8px; margin-bottom: 36px; } +.home-head h2 { font-size: 36px; font-weight: 800; letter-spacing: -0.01em; color: var(--text); } +.home-head p { color: var(--muted); font-size: 17px; } +.home-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue); } +.home-link { color: var(--blue); font-weight: 600; font-size: 15px; } +.home-kinds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; } +.home-kind { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 24px; display: grid; gap: 12px; align-content: start; color: var(--text); transition: transform 0.15s, box-shadow 0.15s; } +.home-kind:hover, .home-facility:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(16, 21, 42, 0.1); } +.home-kind__tag { justify-self: start; background: var(--soft); color: var(--blue); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; } +.home-kind__tag--cold { background: #e0f2fe; color: #0369a1; } +.home-kind h3 { font-size: 24px; font-weight: 800; } +.home-kind__note { color: var(--muted); font-size: 15px; min-height: 45px; } +.home-kind__price { display: grid; border-top: 1px solid var(--line); padding-top: 14px; } +.home-kind__price small, .home-facility__foot small { color: var(--muted); font-size: 13px; } +.home-kind__price strong { font-size: 20px; font-weight: 700; color: var(--ink); } +.home-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; } +.home-steps li { border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: grid; gap: 12px; align-content: start; } +.home-steps__num { width: 44px; height: 44px; border-radius: 999px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; } +.home-steps h3 { font-size: 21px; font-weight: 800; } +.home-steps p { color: var(--muted); font-size: 15px; } +.home-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; } +.home-chip { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 9px 16px; font-size: 15px; font-weight: 500; cursor: pointer; color: var(--text); } +.home-chip span { color: var(--muted); margin-left: 4px; } +.home-chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; } +.home-chip.is-on span { color: rgba(255, 255, 255, 0.7); } +.home-facilities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; } +.home-facility { background: var(--white); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; display: grid; color: var(--text); transition: transform 0.15s, box-shadow 0.15s; } +.home-facility .photo { border-radius: 0; aspect-ratio: 16 / 9.2; } +.home-facility__body { padding: 20px 24px 24px; display: grid; gap: 10px; } +.home-facility h3 { font-size: 21px; font-weight: 800; } +.home-tags { display: flex; flex-wrap: wrap; gap: 8px; } +.home-tags li { background: var(--bg); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 500; } +.home-facility__foot { display: flex; justify-content: space-between; align-items: flex-end; padding-top: 6px; } +.home-facility__foot p { display: grid; } +.home-facility__foot strong { font-size: 18px; font-weight: 700; color: var(--ink); } +.home-more { margin-top: 28px; } +.home-cta { background: var(--ink); color: #fff; border-radius: 28px; padding: 56px; display: flex; justify-content: space-between; align-items: center; gap: 32px; } +.home-cta h2 { color: #fff; font-size: 32px; font-weight: 800; } +.home-cta p { color: rgba(255, 255, 255, 0.78); margin-top: 10px; font-size: 17px; } +.home-cta__actions { display: flex; gap: 12px; flex-shrink: 0; } +.home-footer { background: var(--white); border-top: 1px solid var(--line); padding: 56px 0 40px; } +.home-footer__cols { display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr; gap: 48px; } +.home-footer__cols > * { display: grid; gap: 10px; align-content: start; } +.home-footer__cols strong { font-size: 15px; color: var(--text); } +.home-footer__brand { font-size: 24px !important; font-weight: 800; color: var(--blue) !important; } +.home-footer__cols p, .home-footer__cols a { color: var(--muted); font-size: 15px; } +.home-footer__cols a:hover { color: var(--blue); } +.home-footer__copy { color: var(--muted); font-size: 13px; margin-top: 40px; } +@media (max-width: 1100px) { + .home-hero__inner { padding-top: 80px; padding-bottom: 56px; } + .home-kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .home-facilities { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .home-search { grid-template-columns: 1fr; gap: 4px; } + .home-search__field { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; } + .home-search__submit { margin-top: 8px; } +} +@media (max-width: 720px) { + .home-hero h1 { font-size: 36px; } + .home-hero p br { display: none; } + .home-stats__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } + .home-stats__grid p:nth-child(3) { padding-left: 0; border-left: 0; } + .home-section { padding: 56px 0; } + .home-head h2 { font-size: 28px; } + .home-kinds, .home-steps, .home-facilities, .home-footer__cols { grid-template-columns: 1fr; } + .home-cta { flex-direction: column; align-items: flex-start; padding: 36px 24px; } + .home-cta h2 { font-size: 26px; } +} diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/api-mappers.test.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/api-mappers.test.js index 18fac75..603b5bc 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/api-mappers.test.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/api-mappers.test.js @@ -58,8 +58,8 @@ test("danh mục: cơ sở, quận / thành phố, giờ mở cửa và gói kho assert.equal(tb.city, "TP. Hồ Chí Minh"); assert.equal(tb.hours, "07:00–22:00"); assert.deepEqual(tb.offers.map((o) => [o.unit_type_id, o.type, o.band, o.monthly_rate]), [ - [1, "normal", "S", 500000], - [2, "climate", "S", 1500000], + [1, "normal", "M", 500000], + [2, "climate", "M", 1500000], [3, "climate", "M", 3000000], ]); assert.equal(tb.offers[1].size_label, "4 m²"); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/reducer.test.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/reducer.test.js index 866afad..1ad6ab1 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/reducer.test.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/reducer.test.js @@ -44,8 +44,11 @@ test("đặt chỗ: kiểm tra đầu vào", () => { const s = createSeedData(T); assert.match(book(s, { start_date: "2026-09-20" }).error.message, /quá khứ/); assert.match(book(s, { months: 2 }).error.message, /1, 3 hoặc 6/); - assert.match(book(s, { facility_id: 8, type: "climate" }).error.message, /chưa có loại kho/); + // Figma 14/10: cơ sở nào cũng có kho lạnh → giả lập một cơ sở thiếu loại kho để kiểm tra thông báo + const noCold = { ...s, facilities: s.facilities.map((f) => (f.facility_id === 8 ? { ...f, has_climate: false, offers: f.offers.filter((o) => o.type !== "climate") } : f)) }; + assert.match(book(noCold, { facility_id: 8, type: "climate" }).error.message, /chưa có loại kho/); assert.match(book(s, { band: "X" }).error.message, /diện tích/); + assert.match(book(s, { band: "S" }).error.message, /diện tích/); // cỡ S đã bỏ, chỉ còn M và L }); test("chuyển khoản trong hạn: chờ đối soát, sinh 2 khoản thu, thông báo", () => { @@ -84,7 +87,7 @@ test("gia hạn: chỉ 1 yêu cầu chờ duyệt, chặn trả kho song song, h assert.equal(a.state.renewals[0].status, "PENDING"); assert.equal(a.state.renewals[0].new_end, addMonths(s.contracts[1].end_date, 3)); assert.equal(a.state.ledger.at(-1).status, "RENEWAL_PENDING"); - assert.equal(a.state.ledger.at(-1).amount, 3 * 500000); + assert.equal(a.state.ledger.at(-1).amount, 3 * 1380000); // B-015: kho lạnh cỡ M tại Nguyễn Lương Bằng assert.match(run(a.state, "REQUEST_RENEWAL", { contract_id: "HĐ-2026-0086", months: 1 }).error.message, /đang chờ/); assert.match(run(a.state, "REQUEST_RETURN", { contract_id: "HĐ-2026-0086", date: T, slot: "09:00–09:30" }).error.message, /gia hạn/); assert.match(run(s, "REQUEST_RENEWAL", { contract_id: "HĐ-2026-0086", months: 2 }).error.message, /1, 3 hoặc 6/); @@ -138,12 +141,12 @@ test("nhân viên đối soát: tạo hợp đồng + lịch nhận kho, khoản assert.deepEqual(mine, ["DEPOSIT_HELD", "RECONCILED"]); }); -test("tìm cơ sở: lọc khu vực Quận 7 → 3 cơ sở; kho lạnh loại bỏ cơ sở không có; sắp xếp giá", () => { +test("tìm cơ sở: lọc khu vực Quận 7 → 5 cơ sở; cả 12 cơ sở có kho lạnh; sắp xếp giá", () => { const s = createSeedData(T); const q7 = searchFacilities(s.facilities, { area: "Quận 7, TP. Hồ Chí Minh" }); - assert.deepEqual(q7.map((f) => f.facility_id), [1, 2, 3]); + assert.deepEqual(q7.map((f) => f.facility_id), [1, 2, 3, 4, 5]); const cold = searchFacilities(s.facilities, { type: "climate" }); - assert.ok(cold.every((f) => f.has_climate) && cold.length === 9); + assert.ok(cold.every((f) => f.has_climate) && cold.length === 12); const cheap = searchFacilities(s.facilities, { sort: "price" }); assert.equal(cheap[0].facility_id, 8); // Bình Chánh 790.000 assert.equal(rateFor(s.facilities[0], "normal", "M"), 1150000); diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/render.test.mjs b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/render.test.mjs index 072583d..c5c7945 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/render.test.mjs +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/render.test.mjs @@ -20,7 +20,7 @@ try { const { OPS_ACCOUNTS } = await vite.ssrLoadModule("/src/ops/data.js"); const seed = (authed, opsUser = null) => memory.set(STORAGE_KEY, JSON.stringify({ version: 5, authed, data: createSeedData(), opsUser })); - const publicRoutes = ["home", "login", "register", "pricing", "guide", "find", "find?type=climate&band=S", "find/map", "find/map?type=climate", "find/map?area=Kh%C3%B4ng%20c%C3%B3", "find/1", "find/1?view=map&unit=K02", "find/8?type=climate&view=map", "find/999", "nope"]; + const publicRoutes = ["home", "login", "register", "pricing", "guide", "find", "find?type=climate&band=M", "find/map", "find/map?type=climate", "find/map?area=Kh%C3%B4ng%20c%C3%B3", "find/1", "find/1?view=map&unit=K02", "find/8?type=climate&view=map", "find/999", "nope"]; const privateRoutes = [ "overview", "units", "units/HĐ-2026-0142", "units/HĐ-2026-0086/renew", "units/HĐ-2026-0142/return", "units/unknown", "sent?type=renew&contract=HĐ-2026-0086", "reservations", "reservations/SS-20260914-0142", "reservations/none", diff --git a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/units.test.js b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/units.test.js index a7e4a36..6852081 100644 --- a/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/units.test.js +++ b/SafeSpace-Customer-UI/SafeSpace-Customer-UI/tests/units.test.js @@ -1,38 +1,57 @@ -// Sơ đồ tình trạng ô kho (src/lib/units.js) +// Sơ đồ tình trạng ô kho (src/lib/units.js) — Figma 14/10: 12 ô mỗi cơ sở import test from "node:test"; import assert from "node:assert/strict"; import { createFacilities } from "../src/data/seed.js"; import { countBy, unitsFor } from "../src/lib/units.js"; -test("mỗi cơ sở có 10 ô, giá khớp gói kho, cơ sở đầu theo đúng Figma", () => { +const kinds = (units) => units.map((u) => `${u.row}:${u.type}`); + +test("mỗi cơ sở có 12 ô: dãy A cỡ M (4 thường + 2 lạnh), dãy B cỡ L (4 thường + 2 lạnh), giá khớp gói kho", () => { const facilities = createFacilities(); for (const f of facilities) { const units = unitsFor(f); - assert.equal(units.length, 10); + assert.equal(units.length, 12); + assert.deepEqual(kinds(units), [ + "A:normal", "A:normal", "A:normal", "A:normal", "A:climate", "A:climate", + "B:normal", "B:normal", "B:normal", "B:normal", "B:climate", "B:climate", + ]); + assert.ok(units.filter((u) => u.row === "A").every((u) => u.area === 15)); + assert.ok(units.filter((u) => u.row === "B").every((u) => u.area === 30)); for (const u of units) assert.equal(u.monthly_rate, f.offers.find((o) => o.key === u.offer_key).monthly_rate); - if (!f.has_climate) assert.ok(units.every((u) => u.type === "normal")); } const nlb = unitsFor(facilities[0]); - assert.deepEqual(countBy(nlb), { FREE: 5, RENTED: 3, HELD: 1, SERVICE: 1 }); + assert.deepEqual(countBy(nlb), { FREE: 6, RENTED: 4, HELD: 1, SERVICE: 1 }); assert.equal(nlb.find((u) => u.code === "K02").status, "RENTED"); + assert.equal(nlb.find((u) => u.code === "K12").position, "Tầng trệt · Dãy B"); }); -test("dữ liệu backend: ô kho lấy loại kho từ bảng giá, số ô trống khớp /api/availability/check", async () => { +test("dữ liệu backend: ô kho lấy đúng loại + cỡ từ bảng giá, số ô trống khớp /api/availability/check", async () => { const { mapCatalog } = await import("../src/api/mappers.js"); const unitTypes = [ - { unitTypeId: 1, typeName: "Kho Mini S", area: 1, climateControlled: false, status: "ACTIVE" }, - { unitTypeId: 2, typeName: "Kho M", area: 4, climateControlled: true, status: "ACTIVE" }, - { unitTypeId: 3, typeName: "Kho L", area: 9, climateControlled: true, status: "ACTIVE" }, + { unitTypeId: 1, typeName: "Kho thường M", area: 15, climateControlled: false, status: "ACTIVE" }, + { unitTypeId: 2, typeName: "Kho thường L", area: 30, climateControlled: false, status: "ACTIVE" }, + { unitTypeId: 3, typeName: "Kho lạnh M", area: 15, climateControlled: true, status: "ACTIVE" }, + { unitTypeId: 4, typeName: "Kho lạnh L", area: 30, climateControlled: true, status: "ACTIVE" }, ]; - const rates = [1, 2, 3].map((id) => ({ facilityId: 7, unitTypeId: id, monthlyRate: id * 500000 })); + const rates = [1, 2, 3, 4].map((id) => ({ facilityId: 7, unitTypeId: id, monthlyRate: id * 500000 })); const { facilities } = mapCatalog({ facilities: [{ facilityId: 7, name: "SafeSpace Nhà Bè", address: "Nhà Bè, TP. Hồ Chí Minh", status: "ACTIVE" }], unitTypes, rates }); const f = facilities[0]; - const units = unitsFor(f, { "ut-1": 2, "ut-2": 0, "ut-3": 1 }); - assert.equal(units.length, 10); - assert.ok(units.every((u) => f.offers.some((o) => o.key === u.offer_key)), "mỗi ô gắn với một loại kho thật"); + const units = unitsFor(f, { "ut-1": 2, "ut-2": 0, "ut-3": 1, "ut-4": 2 }); + assert.equal(units.length, 12); + assert.deepEqual(units.map((u) => u.offer_key), ["ut-1", "ut-1", "ut-1", "ut-1", "ut-3", "ut-3", "ut-2", "ut-2", "ut-2", "ut-2", "ut-4", "ut-4"]); const free = (key) => units.filter((u) => u.offer_key === key && u.status === "FREE").length; assert.equal(free("ut-1"), 2); assert.equal(free("ut-2"), 0); assert.equal(free("ut-3"), 1); - assert.equal(units.find((u) => u.offer_key === "ut-1").area_label, "1 m²"); + assert.equal(free("ut-4"), 2); + assert.equal(units.find((u) => u.offer_key === "ut-2").area_label, "30 m²"); +}); + +test("dữ liệu backend thiếu loại kho: ô vẫn gắn với một gói có thật", async () => { + const { mapCatalog } = await import("../src/api/mappers.js"); + const unitTypes = [{ unitTypeId: 9, typeName: "Kho thường M", area: 15, climateControlled: false, status: "ACTIVE" }]; + const { facilities } = mapCatalog({ facilities: [{ facilityId: 3, name: "SafeSpace Phú Xuân", address: "Quận 7, TP. Hồ Chí Minh", status: "ACTIVE" }], unitTypes, rates: [{ facilityId: 3, unitTypeId: 9, monthlyRate: 890000 }] }); + const units = unitsFor(facilities[0]); + assert.equal(units.length, 12); + assert.ok(units.every((u) => u.offer_key === "ut-9" && u.monthly_rate === 890000)); }); diff --git a/progress.md b/progress.md index 5d72e25..037d7d1 100644 --- a/progress.md +++ b/progress.md @@ -17,6 +17,26 @@ --- +## Phiên 4 — 2026-10-14 — Đồng bộ giao diện với Figma 14/10 (Claude) + +- Tính năng: F30 (sơ đồ ô kho) + trang chủ, danh mục kho, header khu vận hành. Nhánh `feature/figma-1410-sync`. Quyết định D17. +- Đã xong (chỉ frontend): + - Trang chủ mới (`pages/Home.jsx`): hero ảnh + tìm theo khu vực / loại / cỡ, dải số liệu, 4 loại kho, 3 bước, + cơ sở theo chip khu vực, khối kêu gọi, footer. Bỏ CSS trang chủ cũ không còn dùng. + - Sơ đồ 12 ô (`lib/units.js`, `UnitMap.jsx`): dãy A cỡ M, dãy B cỡ L; dữ liệu backend gắn ô theo loại + cỡ. + - Bỏ cỡ S (`lib/catalog.js`), 2 cỡ M 15 m² / L 30 m²; bảng giá P01 còn 2 thẻ, có giá kho lạnh. + - Bỏ "Gần bạn nhất", "Cách bạn … km", `distance_km`, `distanceLabel`. + - 12 cơ sở đều có kho lạnh; sửa quận Tân Thuận, Phú Mỹ Hưng về Quận 7; đơn mẫu B-015 đổi sang kho lạnh cỡ M. + - Header khu Nhân viên / Quản lý hiện tên cơ sở phụ trách dưới vai trò. +- Test đã sửa theo quy tắc mới (không phải để cho pass): `units.test.js` (10 → 12 ô), `reducer.test.js` + (Quận 7 có 5 cơ sở, cả 12 có kho lạnh, giá B-015 mới, thêm kiểm tra cỡ S bị từ chối), `api-mappers.test.js` + (loại kho ≤ 20 m² là cỡ M), `render.test.mjs` (lọc cỡ M thay cỡ S). +- Kiểm chứng: `npm test` → 39/39 pass; `npm run test:render` → 76 route PASS; `npm run build` → OK; + chụp màn hình trang chủ (1440 px và 390 px), sơ đồ 12 ô, header quản lý / nhân viên ở chế độ không backend. +- Chưa làm: dữ liệu khu vận hành (`ops/data.js`) vẫn dùng diện tích cũ và 86 ô; backend chưa đổi seed (D17); + dòng thông báo trong `OpsShell.jsx` còn chữ "dữ liệu mẫu" (trái D07/D15). +- Phiên sau nên: cập nhật `DbSeeder` theo D17, rồi chạy giao diện với backend thật. + ## Phiên 3 — 2026-10-14 — Backend khu Quản lý vận hành KD (Claude) - Tính năng: F24 (role OPERATIONS), F22 (cơ sở, chính sách, bảng giá), F23 (báo cáo + xuất CSV) — phía backend.