diff --git a/README.md b/README.md index f84a3f1..efe6b04 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,12 @@ npx drizzle-kit push ### 5. Seed ไฟล์ตัวอย่าง -ไฟล์ตัวอย่างอยู่ที่ `public/samples/` แล้ว — sync ลงตาราง `files` (idempotent รันซ้ำได้): +ไฟล์ตัวอย่างอยู่ที่ `public/samples/` แล้ว — ลงทะเบียนในตาราง `files` (รันเฉพาะเมื่อตารางว่าง ไม่งั้นข้อมูลจะซ้ำ): ```bash -npm run seed-samples +docker exec judes-note-db psql -U postgres -c "insert into files (title, pdf_url) values ('01012-672427-4f-690609-0000840227.pdf','/samples/01012-672427-4f-690609-0000840227.pdf'), ('01012-672427-1f-690609-0000840223.pdf','/samples/01012-672427-1f-690609-0000840223.pdf'), ('dashboard-report-2026-09-03.pdf','/samples/dashboard-report-2026-09-03.pdf');" ``` -> บน production ไม่ต้องรันมือ — script เดียวกัน (`scripts/seed-samples.mjs`) รันอัตโนมัติตอน container start ต่อจาก migration ไฟล์ที่หายจาก `public/samples/` จะถูกลบ row พร้อม annotation ที่ผูกอยู่ (CASCADE) - ### 6. รัน dev server ```bash diff --git a/app/page.tsx b/app/page.tsx index ab7a586..011ca7b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -4,7 +4,6 @@ import { FileText } from "lucide-react"; import { db } from "@/db"; import { files } from "@/db/schema"; -import UserPicker from "@/components/UserPicker"; export const dynamic = "force-dynamic"; @@ -12,55 +11,29 @@ export default async function HomePage() { const rows = await db.select().from(files).orderBy(asc(files.createdAt)); return ( -
-
-
- JN -
-
-

- Jude's Note -

-

- ระบบ PDF Annotation สำหรับ e-Court -

-
-
- - - -
-

เอกสาร

- {rows.length > 0 && ( - {rows.length} ไฟล์ - )} -
+
+

Jude's Note

+

+ ระบบ PDF Annotation สำหรับ e-Court +

{rows.length === 0 ? ( -
- -

- ยังไม่มีไฟล์ในระบบ -

-

- รัน /sync-db เพื่อ seed ไฟล์ตัวอย่าง -

-
+

+ ยังไม่มีไฟล์ในระบบ — รัน /sync-db เพื่อ seed ไฟล์ตัวอย่าง +

) : ( -
    +
      {rows.map((f) => (
    • -
      - -
      + - + {f.title} - + {new Date(f.createdAt).toLocaleString("th-TH")} diff --git a/components/Select.tsx b/components/Select.tsx deleted file mode 100644 index d54ee67..0000000 --- a/components/Select.tsx +++ /dev/null @@ -1,19 +0,0 @@ -"use client"; - -// ปกติทุกอย่าง (props/children) -// className ที่ส่งเข้าไปใช้กับตัว - - - ); -} diff --git a/components/UserPicker.tsx b/components/UserPicker.tsx deleted file mode 100644 index 1717fa7..0000000 --- a/components/UserPicker.tsx +++ /dev/null @@ -1,66 +0,0 @@ -"use client"; - -// เลือก mock user ที่หน้าแรกก่อนเข้า annotate — เขียนลง localStorage key เดิม -// ที่ getLocalUser() อ่าน (PDFViewer ไม่ต้องแก้อะไร) -import { useEffect, useState } from "react"; - -import Select from "./Select"; -import { - MOCK_USERS, - getStoredLocalUser, - setLocalUser, - type LocalUser, -} from "@/utils/user"; - -export default function UserPicker() { - const [current, setCurrent] = useState(null); - - // ต้องรันใน effect เพราะ SSR ไม่มี localStorage — ก่อน mount แสดงคนแรกไว้ก่อน - useEffect(() => { - const stored = getStoredLocalUser(); - if (!stored) { - // ยังไม่เคยมี identity → เริ่มด้วย mock user คนแรก - setLocalUser(MOCK_USERS[0]); - setCurrent(MOCK_USERS[0]); - return; - } - setCurrent(stored); - }, []); - - // identity สุ่มเดิมไม่อยู่ในรายการ mock → แสดงเป็น option ชั่วคราวให้เห็นว่าปัจจุบันคือใคร - const isMock = current !== null && MOCK_USERS.some((u) => u.userId === current.userId); - - const select = (userId: string) => { - const user = MOCK_USERS.find((u) => u.userId === userId); - if (!user) return; - setLocalUser(user); - setCurrent(user); - }; - - return ( -
      -

      เลือกผู้ใช้ (mock)

      -

      - annotation ทั้งหมดจะบันทึกในชื่อผู้ใช้ที่เลือก -

      - -
      - ); -} diff --git a/components/pdf/PDFViewer.tsx b/components/pdf/PDFViewer.tsx index eaa1469..8bca8fc 100644 --- a/components/pdf/PDFViewer.tsx +++ b/components/pdf/PDFViewer.tsx @@ -109,7 +109,6 @@ import InkLayer, { type InkRedaction, type InkShape, type InkStroke } from "./In import TextboxStampLayer, { type InkStamp, type InkTextbox } from "./TextboxStampLayer"; import AnnotationSelectionLayer from "./AnnotationSelectionLayer"; import AnnotationSidebar from "../sidebar/AnnotationSidebar"; -import Select from "../Select"; import { ColorSwatches, HIGHLIGHT_STYLE_BTNS, @@ -2635,7 +2634,7 @@ export default function PDFViewer({ className="mt-1.5 w-full resize-none rounded-md border border-slate-300 px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-slate-400" />

      วางที่

      - + {bookmarkError && (

      {bookmarkError} diff --git a/components/sidebar/AnnotationSidebar.tsx b/components/sidebar/AnnotationSidebar.tsx index 6285d1e..c004308 100644 --- a/components/sidebar/AnnotationSidebar.tsx +++ b/components/sidebar/AnnotationSidebar.tsx @@ -28,8 +28,6 @@ import { X, } from "lucide-react"; -import Select from "../Select"; - import { listVersions, restoreVersion, @@ -361,7 +359,7 @@ export default function AnnotationSidebar({ className="mt-1 w-full resize-none rounded border border-slate-300 p-1.5 text-[11px] focus:outline-none focus:ring-1 focus:ring-slate-400" />

      วางที่

      - +