refactor Student and UserMeta type definitions to deprecate obsolete fields, standardize structure, and update billing address format
```
This commit is contained in:
louiscklaw
2025-05-15 11:13:15 +08:00
parent af15a6bce0
commit c83e8c1b6e
2 changed files with 63 additions and 25 deletions

View File

@@ -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<string, never>;
// 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;

View File

@@ -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;