diff --git a/002_source/cms/.gitignore b/002_source/cms/.gitignore index fd8f49e..a8e10fa 100644 --- a/002_source/cms/.gitignore +++ b/002_source/cms/.gitignore @@ -12,6 +12,7 @@ **/*.log **/*.tmp **/*.del +**/*.plan **/_archive # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/BasicDetailCard.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/BasicDetailCard.tsx deleted file mode 100644 index b2dfbef..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/BasicDetailCard.tsx +++ /dev/null @@ -1,79 +0,0 @@ -'use client'; - -import * as React from 'react'; -import Avatar from '@mui/material/Avatar'; -import Card from '@mui/material/Card'; -import CardHeader from '@mui/material/CardHeader'; -import Chip from '@mui/material/Chip'; -import Divider from '@mui/material/Divider'; -import IconButton from '@mui/material/IconButton'; -import { PencilSimple as PencilSimpleIcon } from '@phosphor-icons/react/dist/ssr/PencilSimple'; -import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User'; -import { useTranslation } from 'react-i18next'; - -import { PropertyItem } from '@/components/core/property-item'; -import { PropertyList } from '@/components/core/property-list'; -import { LpQuestion } from '@/components/dashboard/lp_questions_del/type'; - -export default function BasicDetailCard({ - lpModel: model, - handleEditClick, -}: { - lpModel: LpQuestion; - handleEditClick: () => void; -}): React.JSX.Element { - const { t } = useTranslation(); - - return ( - - { - handleEditClick(); - }} - > - - - } - avatar={ - - - - } - title={t('list.basic-details')} - /> - } - orientation="vertical" - sx={{ '--PropertyItem-padding': '12px 24px' }} - > - {( - [ - { - key: 'Customer ID', - value: ( - - ), - }, - { key: 'Name', value: model.question_name }, - { key: 'Remarks', value: model.remarks }, - { key: 'Description', value: model.description }, - ] satisfies { key: string; value: React.ReactNode }[] - ).map( - (item): React.JSX.Element => ( - - ) - )} - - - ); -} diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/TitleCard.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/TitleCard.tsx deleted file mode 100644 index 19b1b53..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/TitleCard.tsx +++ /dev/null @@ -1,73 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { Button } from '@mui/material'; -import Avatar from '@mui/material/Avatar'; -import Chip from '@mui/material/Chip'; -import Stack from '@mui/material/Stack'; -import Typography from '@mui/material/Typography'; -import { CaretDown as CaretDownIcon } from '@phosphor-icons/react/dist/ssr/CaretDown'; -import { CheckCircle as CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle'; -import { useTranslation } from 'react-i18next'; - -import { LpQuestion } from '@/components/dashboard/lp_questions_del/type'; - -function getImageUrlFrRecord(record: LpQuestion): string { - return `http://127.0.0.1:8090/api/files/${record.collectionId}/${record.id}/${record.question_image}`; -} - -export default function SampleTitleCard({ lpModel }: { lpModel: LpQuestion }): React.JSX.Element { - const { t } = useTranslation(); - - return ( - <> - - - {t('empty')} - -
- - {lpModel.question_name} - - } - label={lpModel.visible} - size="small" - variant="outlined" - /> - - - {lpModel.slug} - -
-
-
- -
- - ); -} diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/page.tsx deleted file mode 100644 index d76ffa8..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/[cat_id]/page.tsx +++ /dev/null @@ -1,138 +0,0 @@ -'use client'; - -import * as React from 'react'; -import RouterLink from 'next/link'; -import { useParams, useRouter } from 'next/navigation'; -import SampleAddressCard from '@/app/dashboard/Sample/AddressCard'; -import { SampleNotifications } from '@/app/dashboard/Sample/Notifications'; -import SamplePaymentCard from '@/app/dashboard/Sample/SamplePaymentCard'; -import SampleSecurityCard from '@/app/dashboard/Sample/SampleSecurityCard'; -import { COL_QUIZ_LP_QUESTIONS } from '@/constants'; -import Box from '@mui/material/Box'; -import Link from '@mui/material/Link'; -import Stack from '@mui/material/Stack'; -import Grid from '@mui/material/Unstable_Grid2'; -import { ArrowLeft as ArrowLeftIcon } from '@phosphor-icons/react/dist/ssr/ArrowLeft'; -import type { RecordModel } from 'pocketbase'; -import { useTranslation } from 'react-i18next'; - -import { paths } from '@/paths'; -import { logger } from '@/lib/default-logger'; -import { pb } from '@/lib/pb'; -import { toast } from '@/components/core/toaster'; -import ErrorDisplay from '@/components/dashboard/error'; -import { defaultLpQuestion } from '@/components/dashboard/lp_questions_del/_constants'; -import { Notifications } from '@/components/dashboard/lp_questions_del/notifications'; -import type { LpQuestion } from '@/components/dashboard/lp_questions_del/type'; -import FormLoading from '@/components/loading'; - -import BasicDetailCard from './BasicDetailCard'; -import TitleCard from './TitleCard'; - -export default function Page(): React.JSX.Element { - const { t } = useTranslation(); - const router = useRouter(); - // - const { cat_id: catId } = useParams<{ cat_id: string }>(); - // - const [showLoading, setShowLoading] = React.useState(true); - const [showError, setShowError] = React.useState({ show: false, detail: '' }); - - // - const [showLessonQuestion, setShowLessonQuestion] = React.useState(defaultLpQuestion); - - function handleEditClick() { - router.push(paths.dashboard.lp_questions.edit(showLessonQuestion.id)); - } - - React.useEffect(() => { - if (catId) { - pb.collection(COL_QUIZ_LP_QUESTIONS) - .getOne(catId) - .then((model: RecordModel) => { - setShowLessonQuestion({ ...defaultLpQuestion, ...model }); - }) - .catch((err) => { - logger.error(err); - toast(t('list.error')); - - setShowError({ show: true, detail: JSON.stringify(err) }); - }) - .finally(() => { - setShowLoading(false); - }); - } - }, [catId]); - - if (showLoading) return ; - if (showError.show) - return ( - - ); - - return ( - - - -
- - - {t('list.title')} - -
- - - -
- - - - - - - - - - - - - - - -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/_PROMPT.md b/002_source/cms/src/app/dashboard/lp/questions.plan/_PROMPT.md deleted file mode 100644 index 6d8b030..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/_PROMPT.md +++ /dev/null @@ -1,17 +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/app/dashboard/lp/questions` - -it was clone from -`category`/`categories`, `lp_category`/`lp_categories` -please help to modify to `question`/`questions`, `lp_question`/`lp_questions` - -please also help to modify the name of -`variables`, `constants`, `functions`, `classes`, components's name, paths - -the db fields structures are the same - -do not move the files -do not create directories -keep current folder structure is important - -thanks diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/create/page.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/create/page.tsx deleted file mode 100644 index a6d48e2..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/create/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -'use client'; - -// RULES: -// T.B.A. -// -import * as React from 'react'; -import RouterLink from 'next/link'; -import Box from '@mui/material/Box'; -import Link from '@mui/material/Link'; -import Stack from '@mui/material/Stack'; -import Typography from '@mui/material/Typography'; -import { ArrowLeft as ArrowLeftIcon } from '@phosphor-icons/react/dist/ssr/ArrowLeft'; -import { useTranslation } from 'react-i18next'; - -import { paths } from '@/paths'; -import { LpQuestionCreateForm } from '@/components/dashboard/lp_questions_del/lp-question-create-form'; - -export default function Page(): React.JSX.Element { - // RULES: follow the name of page directory - const { t } = useTranslation(['lp_questions']); - - return ( - - - -
- - - {t('title')} - -
-
- {t('create.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/_PROMPT.md b/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/_PROMPT.md deleted file mode 100644 index abf4465..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/_PROMPT.md +++ /dev/null @@ -1,11 +0,0 @@ -# task - -## instruction - -with reference to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/_helloworld/page.tsx` - -with reference to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/lesson_types/edit/[typeId]/page.tsx` - -please modify `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/lesson_categories/edit/page.tsx` - -please draft a tsx for showing error to user thanks, diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/page.tsx deleted file mode 100644 index bfd52f5..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/edit/[cat_id]/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -'use client'; - -import * as React from 'react'; -import RouterLink from 'next/link'; -import Box from '@mui/material/Box'; -import Link from '@mui/material/Link'; -import Stack from '@mui/material/Stack'; -import Typography from '@mui/material/Typography'; -import { ArrowLeft as ArrowLeftIcon } from '@phosphor-icons/react/dist/ssr/ArrowLeft'; -import { useTranslation } from 'react-i18next'; - -import { paths } from '@/paths'; -import { LpQuestionEditForm } from '@/components/dashboard/lp_questions_del/lp-question-edit-form'; - -export default function Page(): React.JSX.Element { - const { t } = useTranslation(['lp_questions']); - - React.useEffect(() => { - // console.log('helloworld'); - }, []); - - return ( - - - -
- - - {t('edit.title')} - -
-
- {t('edit.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp/questions.plan/page.tsx b/002_source/cms/src/app/dashboard/lp/questions.plan/page.tsx deleted file mode 100644 index 6fa53ab..0000000 --- a/002_source/cms/src/app/dashboard/lp/questions.plan/page.tsx +++ /dev/null @@ -1,213 +0,0 @@ -'use client'; - -// RULES: -// contains list page for lp_questions (QuizLPQuestions) -// contain definition to collection only -// -import * as React from 'react'; -import { useRouter } from 'next/navigation'; -import { COL_QUIZ_LP_QUESTIONS } from '@/constants'; -import { LoadingButton } from '@mui/lab'; -import Box from '@mui/material/Box'; -import Card from '@mui/material/Card'; -import Divider from '@mui/material/Divider'; -import Stack from '@mui/material/Stack'; -import Typography from '@mui/material/Typography'; -import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus'; -import type { ListResult, RecordModel } from 'pocketbase'; -import { useTranslation } from 'react-i18next'; - -import { paths } from '@/paths'; -import { logger } from '@/lib/default-logger'; -import { pb } from '@/lib/pb'; -import { toast } from '@/components/core/toaster'; -import ErrorDisplay from '@/components/dashboard/error'; -import { defaultLpQuestion } from '@/components/dashboard/lp_questions_del/_constants'; -import { LpQuestionsFilters } from '@/components/dashboard/lp_questions_del/lp-questions-filters'; -import type { Filters } from '@/components/dashboard/lp_questions_del/lp-questions-filters'; -import { LpQuestionsPagination } from '@/components/dashboard/lp_questions_del/lp-questions-pagination'; -import { LpQuestionsSelectionProvider } from '@/components/dashboard/lp_questions_del/lp-questions-selection-context'; -import { LpQuestionsTable } from '@/components/dashboard/lp_questions_del/lp-questions-table'; -import type { LpQuestion } from '@/components/dashboard/lp_questions_del/type'; -import FormLoading from '@/components/loading'; - -export default function Page({ searchParams }: PageProps): React.JSX.Element { - const { t } = useTranslation(['lp_questions']); - const { email, phone, sortDir, status, name, visible, type } = searchParams; - const router = useRouter(); - const [lessonQuestionsData, setLessonQuestionsData] = React.useState([]); - // - - const [isLoadingAddPage, setIsLoadingAddPage] = React.useState(false); - const [showLoading, setShowLoading] = React.useState(true); - const [showError, setShowError] = React.useState({ show: false, detail: '' }); - // - const [rowsPerPage, setRowsPerPage] = React.useState(5); - const [filteredQuestions, setFilteredQuestions] = React.useState([]); - const [currentPage, setCurrentPage] = React.useState(1); - const [recordCount, setRecordCount] = React.useState(0); - const [listOption, setListOption] = React.useState({}); - const [listSort, setListSort] = React.useState({}); - - // - const sortedLessonQuestions = applySort(lessonQuestionsData, sortDir); - const filteredLessonQuestions = applyFilters(sortedLessonQuestions, { email, phone, status }); - - const reloadRows = async (): Promise => { - try { - const models: ListResult = await pb - .collection(COL_QUIZ_LP_QUESTIONS) - .getList(currentPage + 1, rowsPerPage, {}); - const { items, totalItems } = models; - const tempLessonTypes: LpQuestion[] = items.map((lt) => { - return { ...defaultLpQuestion, ...lt }; - }); - - setLessonQuestionsData(tempLessonTypes); - setRecordCount(totalItems); - setF(tempLessonTypes); - console.log({ currentPage, f }); - } catch (error) { - // - setShowError({ show: true, detail: JSON.stringify(error) }); - } finally { - setShowLoading(false); - } - }; - - React.useEffect(() => { - void reloadRows(); - }, [currentPage, rowsPerPage, listOption]); - - if (showLoading) return ; - - if (showError.show) - return ( - - ); - - return ( - - - - - {t('list.title')} - - - { - setIsLoadingAddPage(true); - router.push(paths.dashboard.lp_questions.create); - }} - startIcon={} - variant="contained" - > - {t('list.add')} - - - - - - - - - - - - - - - - - ); -} - -// Sorting and filtering has to be done on the server. - -function applySort(row: LpQuestion[], sortDir: 'asc' | 'desc' | undefined): LpQuestion[] { - return row.sort((a, b) => { - if (sortDir === 'asc') { - return a.createdAt.getTime() - b.createdAt.getTime(); - } - - return b.createdAt.getTime() - a.createdAt.getTime(); - }); -} - -function applyFilters(row: LpQuestion[], { email, phone, status, name, visible }: Filters): LpQuestion[] { - return row.filter((item) => { - if (email) { - if (!item.email?.toLowerCase().includes(email.toLowerCase())) { - return false; - } - } - - if (phone) { - if (!item.phone?.toLowerCase().includes(phone.toLowerCase())) { - return false; - } - } - - if (status) { - if (item.status !== status) { - return false; - } - } - - if (name) { - if (!item.name?.toLowerCase().includes(name.toLowerCase())) { - return false; - } - } - - if (visible) { - if (!item.visible?.toLowerCase().includes(visible.toLowerCase())) { - return false; - } - } - - return true; - }); -} - -interface PageProps { - searchParams: { - email?: string; - phone?: string; - sortDir?: 'asc' | 'desc'; - status?: string; - name?: string; - visible?: string; - type?: string; - // - }; -} diff --git a/002_source/cms/src/db/DB_AI_GUIDELINE.MD b/002_source/cms/src/db/DB_AI_GUIDELINE.MD index f2a9873..b2a12a6 100644 --- a/002_source/cms/src/db/DB_AI_GUIDELINE.MD +++ b/002_source/cms/src/db/DB_AI_GUIDELINE.MD @@ -25,8 +25,10 @@ this is the content of `@/constants` - read, remember and link up the ideas in file stated above, i will tell them the task afterwards -The software engineer will provide solutions, while QA engineer will feedback the opinion. +--- +The software engineer will provide solutions, +while QA engineer will feedback the opinion. this is now not in debug phase, so, no need to reply me what they are going on or their insight throught the prompt. diff --git a/002_source/cms/src/db/QuizLPCategories/Create.tsx b/002_source/cms/src/db/QuizLPCategories/Create.tsx index 999b21a..d900655 100644 --- a/002_source/cms/src/db/QuizLPCategories/Create.tsx +++ b/002_source/cms/src/db/QuizLPCategories/Create.tsx @@ -2,11 +2,8 @@ import { COL_QUIZ_LP_CATEGORIES } from '@/constants'; import type { RecordModel } from 'pocketbase'; import { pb } from '@/lib/pb'; +import { CreateFormProps } from '@/components/dashboard/lp_categories/type'; -interface CreateForm { - // TODO: Add QuizLPCategories fields -} - -export default function createQuizLPCategory(data: CreateForm): Promise { +export default function createQuizLPCategory(data: CreateFormProps): Promise { return pb.collection(COL_QUIZ_LP_CATEGORIES).create(data); }