เพิ่มตัวเลือก mock user 10 คนที่หน้าแรก + ปรับหน้าแรก + select ลูกศรเองทั่วแอป
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 47s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 3s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s

- utils/user.ts: MOCK_USERS (userId คงที่) + setLocalUser/getStoredLocalUser
  เขียนลง localStorage key เดิม — PDFViewer อ่าน getLocalUser() เหมือนเดิม
- components/UserPicker.tsx: dropdown เลือกผู้ใช้ก่อนเข้า annotate
  (ยังไม่มี identity = default คนแรก, identity สุ่มเดิมแสดงเป็น option ชั่วคราว)
- components/Select.tsx: select ถอดลูกศร native (ชิดขอบ) ใส่ ChevronDown เอง
  ใช้ที่ UserPicker + ตัวกรองรายคน + เลือกหัวข้อ bookmark 2 จุด
- app/page.tsx: header monogram, การ์ดไฟล์ hover, empty state ใหม่

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-09-10 18:02:01 +07:00
parent 79c9e2cc41
commit 289d735bf3
6 changed files with 162 additions and 21 deletions

View file

@ -5,7 +5,27 @@ export type LocalUser = { userId: string; userName: string };
const STORAGE_KEY = "judes-note:user";
export function getLocalUser(): LocalUser {
// mock users สำหรับเลือกที่หน้าแรก (demo ไม่มีระบบ auth) — userId คงที่
// เพื่อให้กรองรายคนและสิทธิ์ "แก้ไขได้เฉพาะของตัวเอง" ทำงานสม่ำเสมอข้าม refresh
export const MOCK_USERS: LocalUser[] = [
{ userId: "mock-user-01", userName: "ผู้พิพากษา สมชาย" },
{ userId: "mock-user-02", userName: "ผู้พิพากษา สมหญิง" },
{ userId: "mock-user-03", userName: "อัยการ วิชัย" },
{ userId: "mock-user-04", userName: "เลขานุการศาล ปิยะ" },
{ userId: "mock-user-05", userName: "ทนายโจทก์ ณัฐ" },
{ userId: "mock-user-06", userName: "ทนายจำเลย อรุณี" },
{ userId: "mock-user-07", userName: "ผู้ช่วยผู้พิพากษา กันต์" },
{ userId: "mock-user-08", userName: "พนักงานสอบสวน เดชา" },
{ userId: "mock-user-09", userName: "ผู้เชี่ยวชาญ มานะ" },
{ userId: "mock-user-10", userName: "ผู้ช่วยเลขานุการ ฝ้าย" },
];
export function setLocalUser(user: LocalUser): void {
localStorage.setItem(STORAGE_KEY, JSON.stringify(user));
}
// อ่าน identity ที่เก็บไว้โดยไม่สร้างใหม่ — ใช้แสดงค่าปัจจุบันในหน้าเลือกผู้ใช้
export function getStoredLocalUser(): LocalUser | null {
const raw = localStorage.getItem(STORAGE_KEY);
if (raw) {
try {
@ -14,9 +34,15 @@ export function getLocalUser(): LocalUser {
return parsed;
}
} catch {
// ข้อมูลเก่าเสียหาย → สร้างใหม่ต่อด้านล่าง
// ข้อมูลเก่าเสียหาย → ถือว่าไม่มีข้อมูล
}
}
return null;
}
export function getLocalUser(): LocalUser {
const stored = getStoredLocalUser();
if (stored) return stored;
const userId = crypto.randomUUID();
const userName = `ผู้ใช้ ${userId.slice(0, 4).toUpperCase()}`;