diff --git a/src/lib/components/List/List.svelte b/src/lib/components/List/List.svelte index 70d8c5d..835fd1d 100644 --- a/src/lib/components/List/List.svelte +++ b/src/lib/components/List/List.svelte @@ -22,24 +22,23 @@
{title}
-
+
{formatDate(createdAt)} โดย {createdBy}
diff --git a/src/lib/components/MaxWidthWrapper.svelte b/src/lib/components/MaxWidthWrapper.svelte new file mode 100644 index 0000000..f9c0c50 --- /dev/null +++ b/src/lib/components/MaxWidthWrapper.svelte @@ -0,0 +1,15 @@ + + +
+ +
diff --git a/src/lib/mock/document.ts b/src/lib/mock/document.ts new file mode 100644 index 0000000..4f552a1 --- /dev/null +++ b/src/lib/mock/document.ts @@ -0,0 +1,91 @@ +import { DocumentType, Role, type Document, type User } from '$lib/types'; +import dayjs from 'dayjs'; +import buddhistEra from 'dayjs/plugin/buddhistEra'; + +dayjs.extend(buddhistEra); +export // * mock data +const created_at_1 = '2022-01-01'; +const created_at_2 = '2023-01-01'; +const created_at_3 = '2024-01-01'; +const created_at_4 = '2025-01-01'; +const updated_at = '2030-02-01'; + +const sgcu_admin: User = { + id: '6000000000', + first_name: 'Admin', + last_name: 'Admin', + role: Role.SGCU_SUPERADMIN, + created_at: created_at_1, + updated_at +}; +const sccu_admin: User = { + id: '6000000001', + first_name: 'Admin', + last_name: 'Admin', + role: Role.SCCU_SUPERADMIN, + created_at: created_at_2, + updated_at +}; + +export const documents: Document[] = [ + { + id: 'DOC-09649054', + title: 'เอกสารลับจากดัมเบิลดอร์', + content: 'เนื้อหาของเอกสารลับจากดัมเบิลดอร์', + user_id: sgcu_admin.id, + type_id: DocumentType.ANNOUNCEMENT, + created_at: created_at_3, + updated_at, + author: sgcu_admin + }, + { + id: 'DOC-09649055', + title: 'ประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต 00', + content: 'เนื้อหาของประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต', + user_id: sccu_admin.id, + type_id: DocumentType.ANNOUNCEMENT, + created_at: created_at_4, + updated_at, + author: sccu_admin + }, + { + id: 'DOC-09649056', + title: 'ประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต 01', + content: 'เนื้อหาของประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต', + user_id: sgcu_admin.id, + type_id: DocumentType.ANNOUNCEMENT, + created_at: created_at_4, + updated_at, + author: sgcu_admin + }, + { + id: 'DOC-09649056', + title: 'ประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต 02', + content: 'เนื้อหาของประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต', + user_id: sccu_admin.id, + type_id: DocumentType.BUDGET, + created_at: created_at_1, + updated_at, + author: sccu_admin + }, + { + id: 'DOC-09649058', + title: 'ประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต 03', + content: 'เนื้อหาของประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต', + user_id: sccu_admin.id, + type_id: DocumentType.STATISTIC, + created_at: created_at_1, + updated_at, + author: sgcu_admin + }, + { + id: 'DOC-09649060', + title: 'ประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต 04', + content: 'เนื้อหาของประกาศรับสมัครคณะกรรมาธิการวิสามัญพิจารณางบประมาณสโมสรนิสิต', + user_id: sccu_admin.id, + type_id: DocumentType.STATISTIC, + created_at: created_at_1, + updated_at, + author: sgcu_admin + } +]; diff --git a/src/lib/types/document.ts b/src/lib/types/document.ts new file mode 100644 index 0000000..32c52e1 --- /dev/null +++ b/src/lib/types/document.ts @@ -0,0 +1,23 @@ +import type { User } from './user'; + +export type Document = { + id: string; + title: string; + content: string; + banner?: string; + cover?: string; + user_id: string; + type_id: string; + created_at: string; + updated_at: string; + + author: User; + // images: Attachment[]; + // docs: Attachment[]; +}; + +export enum DocumentType { + ANNOUNCEMENT = 'ANNOUNCEMENT', + BUDGET = 'BUDGET', + STATISTIC = 'STATISTIC' +} diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts new file mode 100644 index 0000000..f4d5538 --- /dev/null +++ b/src/lib/types/index.ts @@ -0,0 +1,3 @@ +export * from './document'; +export * from './role'; +export * from './user'; diff --git a/src/lib/types/role.ts b/src/lib/types/role.ts new file mode 100644 index 0000000..d477eb7 --- /dev/null +++ b/src/lib/types/role.ts @@ -0,0 +1,6 @@ +export enum Role { + SGCU_ADMIN = 'SGCU_ADMIN', + SGCU_SUPERADMIN = 'SGCU_SUPERADMIN', + SCCU_ADMIN = 'SCCU_ADMIN', + SCCU_SUPERADMIN = 'SCCU_SUPERADMIN' +} diff --git a/src/lib/types/user.ts b/src/lib/types/user.ts new file mode 100644 index 0000000..89032b2 --- /dev/null +++ b/src/lib/types/user.ts @@ -0,0 +1,10 @@ +import type { Role } from './role'; + +export type User = { + id: string; + first_name: string; + last_name: string; + role: Role; + created_at: string; + updated_at: string; +}; diff --git a/src/routes/document/+page.svelte b/src/routes/document/+page.svelte new file mode 100644 index 0000000..e098535 --- /dev/null +++ b/src/routes/document/+page.svelte @@ -0,0 +1,176 @@ + + + +
+
+ +

เอกสาร

+
+

+ เอกสารทั้งหมดในนามสโมสรนิสิตจุฬาฯ อบจ. และสภานิสิตจุฬาฯ ซึ่งเปิดเผยให้นิสิตได้อ่านโดยทั่วกัน +

+
+ + + + + + ทั้งหมด + อบจ. + สภานิสิต + + +
+ {#each tabCapsules as tab, i} + toggle(i)} /> + {/each} +
+ + + changePage(variant, direction)} + documents={paginatedAll} + totalPages={totalPages.all} + variantKey="all" + /> + + + + changePage(variant, direction)} + documents={paginatedSGCU} + totalPages={totalPages.sgcu} + variantKey="sgcu" + /> + + + + changePage(variant, direction)} + documents={paginatedSCCU} + totalPages={totalPages.sccu} + variantKey="sccu" + /> + +
+
diff --git a/src/routes/document/+page.ts b/src/routes/document/+page.ts new file mode 100644 index 0000000..ee340fb --- /dev/null +++ b/src/routes/document/+page.ts @@ -0,0 +1,9 @@ +import type { PageLoad } from './$types'; +import 'dayjs/locale/th'; +import { documents } from '$lib/mock/document'; + +export const load: PageLoad = async () => { + return { + documents + }; +}; diff --git a/src/routes/document/DocumentList.svelte b/src/routes/document/DocumentList.svelte new file mode 100644 index 0000000..4f76667 --- /dev/null +++ b/src/routes/document/DocumentList.svelte @@ -0,0 +1,46 @@ + + +{#if documents.length === 0} +

No documents available.

+{:else} + {#each documents as document, i} + + {/each} +{/if} + +
+ + +
diff --git a/src/styles/tailwind/list.ts b/src/styles/tailwind/list.ts index f1eaade..088a88c 100644 --- a/src/styles/tailwind/list.ts +++ b/src/styles/tailwind/list.ts @@ -1,11 +1,11 @@ import { tv, type VariantProps } from 'tailwind-variants'; export const listVariants = tv({ - base: 'rounded-lg p-4', + base: 'rounded-xs p-4', variants: { variant: { pink: 'bg-sucu-pink-05', - grey: 'bg-sucu-gray-light', + grey: 'bg-[#f7f7f7]', default: 'bg-white' } },