Add application codebase: PDF annotation for e-Court
Next.js 14 + Drizzle/PostgreSQL + SSE realtime sync — highlight, freehand, comment, bookmark + ฟีเจอร์ต่อยอด F1–F19 (edit/move, undo/redo, shapes, redaction, export PDF/CSV, reply, resolve, search, summary, textbox, stamp, version history) Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
6fd0c3174f
commit
eddcec28c7
60 changed files with 15055 additions and 0 deletions
25
utils/user.ts
Normal file
25
utils/user.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// anonymous identity เก็บใน localStorage สร้างครั้งเดียวต่อ browser (PLAN.md §0 A4)
|
||||
// ใช้เติม field userId/userName ในตาราง annotations/bookmarks — ไม่มีระบบ auth
|
||||
|
||||
export type LocalUser = { userId: string; userName: string };
|
||||
|
||||
const STORAGE_KEY = "judes-note:user";
|
||||
|
||||
export function getLocalUser(): LocalUser {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as LocalUser;
|
||||
if (typeof parsed.userId === "string" && typeof parsed.userName === "string") {
|
||||
return parsed;
|
||||
}
|
||||
} catch {
|
||||
// ข้อมูลเก่าเสียหาย → สร้างใหม่ต่อด้านล่าง
|
||||
}
|
||||
}
|
||||
|
||||
const userId = crypto.randomUUID();
|
||||
const userName = `ผู้ใช้ ${userId.slice(0, 4).toUpperCase()}`;
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ userId, userName }));
|
||||
return { userId, userName };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue