This commit is contained in:
louiscklaw
2025-04-21 12:15:25 +08:00
parent ac7d3883fd
commit 00a978e55a
67 changed files with 3423 additions and 136 deletions

View File

@@ -0,0 +1,12 @@
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
interface CreateForm {
// TODO: Add QuizLPQuestions fields
}
export default function createQuizLPQuestion(data: CreateForm): Promise<RecordModel> {
return pb.collection(COL_QUIZ_LP_QUESTIONS).create(data);
}

View File

@@ -0,0 +1,7 @@
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import { pb } from '@/lib/pb';
export default function deleteQuizLPQuestions(id: string): Promise<boolean> {
return pb.collection(COL_QUIZ_LP_QUESTIONS).delete(id);
}

View File

@@ -0,0 +1,8 @@
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
export default function getAllQuizLPQuestions(): Promise<RecordModel[]> {
return pb.collection(COL_QUIZ_LP_QUESTIONS).getFullList();
}

View File

@@ -0,0 +1,9 @@
// REQ0006
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import { pb } from '@/lib/pb';
export default async function GetAllCount(): Promise<number> {
const { totalItems: count } = await pb.collection(COL_QUIZ_LP_QUESTIONS).getList(1, 9999, {});
return count;
}

View File

@@ -0,0 +1,8 @@
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
export default function getQuizLPQuestionById(id: string): Promise<RecordModel> {
return pb.collection(COL_QUIZ_LP_QUESTIONS).getOne(id);
}

View File

@@ -0,0 +1,14 @@
// REQ0006
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import { pb } from '@/lib/pb';
export default async function getHiddenQuizLPQuestionsCount(): Promise<number> {
try {
const result = await pb.collection(COL_QUIZ_LP_QUESTIONS).getList(1, 9999, { filter: 'visible = "hidden"' });
const { totalItems: count } = result;
return count;
} catch (error) {
return 0;
}
}

View File

@@ -0,0 +1,14 @@
// REQ0006
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
import { pb } from '@/lib/pb';
export default async function getVisibleQuizLPQuestionsCount(): Promise<number> {
try {
const result = await pb.collection(COL_QUIZ_LP_QUESTIONS).getList(1, 9999, { filter: 'visible = "visible"' });
const { totalItems: count } = result;
return count;
} catch (error) {
return 0;
}
}

View File

@@ -0,0 +1,9 @@
import { COL_QUIZ_LP_CATEGORIES } from '@/constants';
import type { RecordModel } from 'pocketbase';
import { pb } from '@/lib/pb';
import type { CreateFormProps } from '@/components/dashboard/lp_categories/type';
export default function updateQuizLPCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
return pb.collection(COL_QUIZ_LP_CATEGORIES).update(id, data);
}

View File

@@ -0,0 +1,18 @@
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/QuizLPQuestions`
it was clone from
`LPCategories`
please help to modify to
`LPQuestions`
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