From c83e8c1b6e4906974c23aa5e2afca7311ca2e8b3 Mon Sep 17 00:00:00 2001 From: louiscklaw Date: Thu, 15 May 2025 11:13:15 +0800 Subject: [PATCH] ``` refactor Student and UserMeta type definitions to deprecate obsolete fields, standardize structure, and update billing address format ``` --- .../student/{type.d.tsx => type.d.ts} | 56 ++++++++++++++++++- .../user_meta/{type.d.tsx => type.d.ts} | 32 ++++------- 2 files changed, 63 insertions(+), 25 deletions(-) rename 002_source/cms/src/components/dashboard/student/{type.d.tsx => type.d.ts} (60%) rename 002_source/cms/src/components/dashboard/user_meta/{type.d.tsx => type.d.ts} (81%) diff --git a/002_source/cms/src/components/dashboard/student/type.d.tsx b/002_source/cms/src/components/dashboard/student/type.d.ts similarity index 60% rename from 002_source/cms/src/components/dashboard/student/type.d.tsx rename to 002_source/cms/src/components/dashboard/student/type.d.ts index 84b7a8b..a9a2295 100644 --- a/002_source/cms/src/components/dashboard/student/type.d.tsx +++ b/002_source/cms/src/components/dashboard/student/type.d.ts @@ -1,20 +1,67 @@ -'use client'; +// src/components/dashboard/student/type.d.tsx // RULES: sorting direction for student lists +import type { BillingAddress } from '@/db/billingAddress/type'; + +// RULES: sorting direction for teacher lists export type SortDir = 'asc' | 'desc'; +export interface DBStudent { + name: string; + // + // NOTE: obslete "avatar" and use "avatar_file" + avatar?: string; + avatar_file?: string; + // + email: string; + phone: string; + quota: number; + company: string; + // + // billingAddress: BillingAddress[] | []; + expand: { billingAddress?: BillingAddress[] }; + + // status is obsoleted, replace by state + status: 'pending' | 'active' | 'blocked'; + state: 'pending' | 'active' | 'blocked'; + // + timezone: string; + language: string; + currency: string; + // + id: string; + created: string; + updated?: string; + collectionId: string; +} + // RULES: core student data structure export interface Student { - id: string; - collectionId: string; name: string; + // + // NOTE: obslete "avatar" and use "avatar_file" avatar?: string; + avatar_file?: string; + // email: string; phone?: string; quota: number; + company?: string; + // + billingAddress: BillingAddress | Record; + + // status is obsoleted, replace by state status: 'pending' | 'active' | 'blocked'; + state: 'pending' | 'active' | 'blocked'; + // + timezone: string; + language: string; + currency: string; + // + id: string; createdAt: Date; updatedAt?: Date; + collectionId: string; } // RULES: form data structure for creating new student @@ -23,6 +70,7 @@ export interface CreateFormProps { email: string; phone?: string; company?: string; + // // handle seperately // billingAddress?: { // country: string; @@ -32,6 +80,7 @@ export interface CreateFormProps { // line1: string; // line2?: string; // }; + // taxId?: string; timezone: string; language: string; @@ -64,6 +113,7 @@ export interface EditFormProps { // quota?: number; // status?: 'pending' | 'active' | 'blocked'; } + // RULES: filter props for student search and filtering export interface CustomersFiltersProps { filters?: Filters; diff --git a/002_source/cms/src/components/dashboard/user_meta/type.d.tsx b/002_source/cms/src/components/dashboard/user_meta/type.d.ts similarity index 81% rename from 002_source/cms/src/components/dashboard/user_meta/type.d.tsx rename to 002_source/cms/src/components/dashboard/user_meta/type.d.ts index 231568a..b21dd22 100644 --- a/002_source/cms/src/components/dashboard/user_meta/type.d.tsx +++ b/002_source/cms/src/components/dashboard/user_meta/type.d.ts @@ -1,26 +1,11 @@ -'use client'; +// src/components/dashboard/user_meta/type.d.tsx +// RULES: sorting direction for user meta lists import type { BillingAddress } from '@/db/billingAddress/type'; // RULES: sorting direction for teacher lists export type SortDir = 'asc' | 'desc'; -// obsoleted -// export interface BillingAddress { -// city: string; -// country: string; -// line1: string; -// line2: string; -// state: string; -// zipCode: string; -// // -// id: string; -// collectionId: string; -// collectionName: string; -// updated: string; -// created: string; -// } - export interface DBUserMeta { name: string; // @@ -50,7 +35,7 @@ export interface DBUserMeta { collectionId: string; } -// RULES: core teacher data structure +// RULES: core user meta data structure export interface UserMeta { name: string; // @@ -72,7 +57,6 @@ export interface UserMeta { timezone: string; language: string; currency: string; - // id: string; createdAt: Date; @@ -80,12 +64,14 @@ export interface UserMeta { collectionId: string; } -// RULES: form data structure for creating new teacher +// RULES: form data structure for creating new user meta export interface CreateFormProps { name: string; email: string; phone?: string; company?: string; + // + // handle seperately ? billingAddress?: { country: string; state: string; @@ -94,6 +80,7 @@ export interface CreateFormProps { line1: string; line2?: string; }; + // taxId?: string; timezone: string; language: string; @@ -103,7 +90,7 @@ export interface CreateFormProps { // status?: 'pending' | 'active' | 'blocked'; } -// RULES: form data structure for editing existing teacher +// RULES: form data structure for editing existing user meta export interface EditFormProps { name: string; email: string; @@ -126,12 +113,13 @@ export interface EditFormProps { // status?: 'pending' | 'active' | 'blocked'; } -// RULES: filter props for teacher search and filtering +// RULES: filter props for user meta search and filtering export interface UserMetasFiltersProps { filters?: Filters; sortDir?: SortDir; fullData: UserMeta[]; } +// RULES: available filter options for user meta data export interface Filters { email?: string; phone?: string;