This commit is contained in:
louiscklaw
2025-04-24 01:08:44 +08:00
parent 41cc82d54d
commit da08798b10
87 changed files with 66682 additions and 6003 deletions

View File

@@ -1,6 +1,6 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
export async function deleteCustomer(id) {
export async function deleteCustomer(id: string): Promise<boolean> {
return pb.collection(COL_CUSTOMERS).delete(id);
}

View File

@@ -1,6 +1,7 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
import { RecordModel } from 'pocketbase';
export async function getAllCustomers(options = {}) {
export async function getAllCustomers(options = {}): Promise<RecordModel[]> {
return pb.collection(COL_CUSTOMERS).getFullList(options);
}

View File

@@ -1,7 +1,7 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
export async function getAllCustomersCount() {
export async function getAllCustomersCount(): Promise<number> {
const result = await pb.collection(COL_CUSTOMERS).getList(1, 1);
return result.totalItems;
}

View File

@@ -1,6 +1,7 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
import { RecordModel } from 'pocketbase';
export async function getCustomerById(id) {
export async function getCustomerById(id: string): Promise<RecordModel> {
return pb.collection(COL_CUSTOMERS).getOne(id);
}

View File

@@ -1,9 +0,0 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
export async function getHiddenCustomersCount() {
const result = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
filter: 'hidden = true',
});
return result.totalItems;
}

View File

@@ -1,9 +0,0 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
export async function getVisibleCustomersCount() {
const result = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
filter: 'hidden = false',
});
return result.totalItems;
}

View File

@@ -1,8 +1,8 @@
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
import type { RecordModel } from 'pocketbase';
import type { CreateForm } from '@/components/dashboard/customer/type.d';
import type { EditFormProps } from '@/components/dashboard/customer/type.d';
export async function updateCustomer(id: string, data: Partial<CustomerUpdateData>): Promise<RecordModel> {
export async function updateCustomer(id: string, data: Partial<EditFormProps>): Promise<RecordModel> {
return pb.collection(COL_CUSTOMERS).update(id, data);
}

View File

@@ -0,0 +1,31 @@
# GUIDELINES
This folder contains drivers for `Customer`/`Customers` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx, GetActiveCount.tsx, GetBlockedCount.tsx, GetPendingCount.tsx)
- misc (Helloworld.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/Customers/type.d.tsx`
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
export async function createCustomer(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}
```

View File

@@ -0,0 +1,33 @@
# GUIDELINES
This folder contains drivers for `Event`/`Events` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/Events/type.d.tsx`
- Event records require special handling for:
- Date/time validation
- Location data
- Attendee management
simple template:
```typescript
import { pb } from '@/lib/pb';
export async function createEvent(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection('Events'))
}
```

View File

@@ -0,0 +1,30 @@
# GUIDELINES
This folder contains test drivers for `Helloworld` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function
- type information defined in `@/db/Helloworlds/type.d.tsx`
- This is a test collection - keep implementations simple
simple template:
```typescript
import { pb } from '@/lib/pb';
export async function createHelloworld(data: CreateFormProps) {
// Simple test implementation
return pb.collection('Helloworlds').create(data);
}
```

View File

@@ -0,0 +1,30 @@
# GUIDELINES
This folder contains drivers for `LessonCategory`/`LessonCategories` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/LessonCategories/type.d.tsx`
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_LESSON_CATEGORIES } from '@/constants';
export async function createLessonCategory(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}
```

View File

@@ -0,0 +1,30 @@
# GUIDELINES
This folder contains drivers for `LessonType`/`LessonTypes` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/LessonTypes/type.d.tsx`
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_LESSON_TYPES } from '@/constants';
export async function createLessonType(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}
```

View File

@@ -0,0 +1,33 @@
# GUIDELINES
This folder contains drivers for `Message`/`Messages` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/Messages/type.d.tsx`
- Message records require special handling for:
- Sender/receiver validation
- Timestamp management
- Read status tracking
simple template:
```typescript
import { pb } from '@/lib/pb';
export async function createMessage(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection('Messages'))
}
```

View File

@@ -0,0 +1,31 @@
# GUIDELINES
This folder contains drivers for `QuizCRCategory`/`QuizCRCategories` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/QuizCRCategories/type.d.tsx`
- Quiz categories may require additional validation logic
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
export async function createQuizCRCategory(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}
```

View File

@@ -0,0 +1,31 @@
# GUIDELINES
This folder contains drivers for `QuizLPCategory` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/QuizLPCategories/type.d.tsx`
- Quiz LP categories may require additional validation logic
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_QUIZ_LP_CATEGORIES } from '@/constants';
export async function createQuizLPCategory(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(COL_QUIZ_LP_CATEGORIES))
}
```

View File

@@ -1,18 +0,0 @@
please help to review the `tsx` file in this folder
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/QuizLPCategories`
it was clone from
`MFCategories`
please help to modify to
`LPCategories`
please also help to modify the name of
`variables`, `constants`, `functions`, `classes`, components's name, paths
the db fields structures between them are the same
do not move the files
do not create directories
keep current folder structure is important
thanks

View File

@@ -0,0 +1,34 @@
# GUIDELINES
This folder contains drivers for `QuizLPQuestion` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/QuizLPQuestions/type.d.tsx`
- Quiz LP questions require special handling for:
- Answer validation
- Question type checking
- Category association
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
export async function createQuizLPQuestion(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(COL_QUIZ_LP_QUESTIONS))
}
```

View File

@@ -0,0 +1,33 @@
# GUIDELINES
This folder contains drivers for `Subscription`/`Subscriptions` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/Subscriptions/type.d.tsx`
- Subscription records require special handling for:
- Payment status validation
- Expiration date checks
- Auto-renewal logic
simple template:
```typescript
import { pb } from '@/lib/pb';
export async function createSubscription(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection('Subscriptions'))
}
```

View File

@@ -0,0 +1,30 @@
# GUIDELINES
This folder contains drivers for `UserMeta`/`UserMetas` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
## Assumption and Requirements
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/UserMetas/type.d.tsx`
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_USER_METAS } from '@/constants';
export async function createUserMeta(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}
```

View File

@@ -1,11 +1,11 @@
# NOTES
# GUIDELINES
this folder containing driver for `Customer` / `Customers` record:
This folder contains drivers for `User`/`Users` records using PocketBase:
- create (Create.tsx)
- read (GetById.tsx)
- write (Update.tsx)
- count (GetAllCount.tsx, GetHiddenCount.tsx, GetVisibleCount.tsx)
- count (GetAllCount.tsx)
- delete (Delete.tsx)
- list (GetAll.tsx)
@@ -15,14 +15,15 @@ the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-onlin
- assume `pb` is located in `@/lib/pb`
- no need to handle error in this function, i'll handle it in the caller
- type information defined in `@/db/Users/type.d.tsx`
simple template:
```typescript
import { pb } from '@/lib/pb';
import { COL_CUSTOMERS } from '@/constants';
import { COL_USERS } from '@/constants';
export async function createCustomer(data) {
export async function createUser(data: CreateFormProps) {
// ...content
// use direct return of pb.collection (e.g. return pb.collection(xxx))
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff