diff --git a/002_source/cms/src/app/dashboard/lp_categories/[cat_id]/BasicDetailCard.tsx b/002_source/cms/src/app/dashboard/lp_categories/[cat_id]/BasicDetailCard.tsx deleted file mode 100644 index 176fc8c..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/[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 { LpCategory } from '@/components/dashboard/lp_categories/type'; - -export default function BasicDetailCard({ - lpModel: model, - handleEditClick, -}: { - lpModel: LpCategory; - 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.cat_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_categories/[cat_id]/TitleCard.tsx b/002_source/cms/src/app/dashboard/lp_categories/[cat_id]/TitleCard.tsx deleted file mode 100644 index f1ad1bc..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/[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 { LpCategory } from '@/components/dashboard/lp_categories/type'; - -function getImageUrlFrRecord(record: LpCategory): string { - return `http://127.0.0.1:8090/api/files/${record.collectionId}/${record.id}/${record.cat_image}`; -} - -export default function SampleTitleCard({ lpModel }: { lpModel: LpCategory }): React.JSX.Element { - const { t } = useTranslation(); - - return ( - <> - - - {t('empty')} - -
- - {lpModel.cat_name} - - } - label={lpModel.visible} - size="small" - variant="outlined" - /> - - - {lpModel.slug} - -
-
-
- -
- - ); -} diff --git a/002_source/cms/src/app/dashboard/lp_categories/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp_categories/[cat_id]/page.tsx deleted file mode 100644 index 366c535..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/[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_CATEGORIES } 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 { defaultLpCategory } from '@/components/dashboard/lp_categories/_constants.ts'; -import { Notifications } from '@/components/dashboard/lp_categories/notifications'; -import type { LpCategory } from '@/components/dashboard/lp_categories/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 [showLessonCategory, setShowLessonCategory] = React.useState(defaultLpCategory); - - function handleEditClick() { - router.push(paths.dashboard.lp_categories.edit(showLessonCategory.id)); - } - - React.useEffect(() => { - if (catId) { - pb.collection(COL_QUIZ_LP_CATEGORIES) - .getOne(catId) - .then((model: RecordModel) => { - setShowLessonCategory({ ...defaultLpCategory, ...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_categories/create/page.tsx b/002_source/cms/src/app/dashboard/lp_categories/create/page.tsx deleted file mode 100644 index a3e7882..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/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 { LpCategoryCreateForm } from '@/components/dashboard/lp_categories/lp-category-create-form'; - -export default function Page(): React.JSX.Element { - // RULES: follow the name of page directory - const { t } = useTranslation(['lp_categories']); - - return ( - - - -
- - - {t('title')} - -
-
- {t('create.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp_categories/edit/[cat_id]/_PROMPT.md b/002_source/cms/src/app/dashboard/lp_categories/edit/[cat_id]/_PROMPT.md deleted file mode 100644 index abf4465..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/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_categories/edit/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp_categories/edit/[cat_id]/page.tsx deleted file mode 100644 index 9f7f258..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/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 { LpCategoryEditForm } from '@/components/dashboard/lp_categories/lp-category-edit-form'; - -export default function Page(): React.JSX.Element { - const { t } = useTranslation(['lp_categories']); - - React.useEffect(() => { - // console.log('helloworld'); - }, []); - - return ( - - - -
- - - {t('edit.title')} - -
-
- {t('edit.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp_categories/lp-categories-sample-data.tsx b/002_source/cms/src/app/dashboard/lp_categories/lp-categories-sample-data.tsx deleted file mode 100644 index 0c1aa79..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/lp-categories-sample-data.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { dayjs } from '@/lib/dayjs'; -import { LessonCategory } from '@/components/dashboard/lesson_category/type'; - -export const LpCategoriesSampleData = [ - { - id: 'USR-005', - name: 'Fran Perez', - avatar: '/assets/avatar-5.png', - email: 'fran.perez@domain.com', - phone: '(815) 704-0045', - quota: 50, - status: 'active', - createdAt: dayjs().subtract(1, 'hour').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-004', - name: 'Penjani Inyene', - avatar: '/assets/avatar-4.png', - email: 'penjani.inyene@domain.com', - phone: '(803) 937-8925', - quota: 100, - status: 'active', - createdAt: dayjs().subtract(3, 'hour').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-003', - name: 'Carson Darrin', - avatar: '/assets/avatar-3.png', - email: 'carson.darrin@domain.com', - phone: '(715) 278-5041', - quota: 10, - status: 'blocked', - createdAt: dayjs().subtract(1, 'hour').subtract(1, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-002', - name: 'Siegbert Gottfried', - avatar: '/assets/avatar-2.png', - email: 'siegbert.gottfried@domain.com', - phone: '(603) 766-0431', - quota: 0, - status: 'pending', - createdAt: dayjs().subtract(7, 'hour').subtract(1, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-001', - name: 'Miron Vitold', - avatar: '/assets/avatar-1.png', - email: 'miron.vitold@domain.com', - phone: '(425) 434-5535', - quota: 50, - status: 'active', - createdAt: dayjs().subtract(2, 'hour').subtract(2, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, -] satisfies LessonCategory[]; diff --git a/002_source/cms/src/app/dashboard/lp_categories/page.tsx b/002_source/cms/src/app/dashboard/lp_categories/page.tsx deleted file mode 100644 index 24a908c..0000000 --- a/002_source/cms/src/app/dashboard/lp_categories/page.tsx +++ /dev/null @@ -1,213 +0,0 @@ -'use client'; - -// RULES: -// contains list page for lp_categories (QuizLPCategories) -// contain definition to collection only -// -import * as React from 'react'; -import { useRouter } from 'next/navigation'; -import { COL_QUIZ_LP_CATEGORIES } 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 { defaultLpCategory } from '@/components/dashboard/lp_categories/_constants'; -import { LpCategoriesFilters } from '@/components/dashboard/lp_categories/lp-categories-filters'; -import type { Filters } from '@/components/dashboard/lp_categories/lp-categories-filters'; -import { LpCategoriesPagination } from '@/components/dashboard/lp_categories/lp-categories-pagination'; -import { LpCategoriesSelectionProvider } from '@/components/dashboard/lp_categories/lp-categories-selection-context'; -import { LpCategoriesTable } from '@/components/dashboard/lp_categories/lp-categories-table'; -import type { LpCategory } from '@/components/dashboard/lp_categories/type'; -import FormLoading from '@/components/loading'; - -export default function Page({ searchParams }: PageProps): React.JSX.Element { - const { t } = useTranslation(['lp_categories']); - const { email, phone, sortDir, status, name, visible, type } = searchParams; - const router = useRouter(); - const [lessonCategoriesData, setLessonCategoriesData] = 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 [f, setF] = 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 sortedLessonCategories = applySort(lessonCategoriesData, sortDir); - const filteredLessonCategories = applyFilters(sortedLessonCategories, { email, phone, status }); - - const reloadRows = async (): Promise => { - try { - const models: ListResult = await pb - .collection(COL_QUIZ_LP_CATEGORIES) - .getList(currentPage + 1, rowsPerPage, {}); - const { items, totalItems } = models; - const tempLessonTypes: LpCategory[] = items.map((lt) => { - return { ...defaultLpCategory, ...lt }; - }); - - setLessonCategoriesData(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_categories.create); - }} - startIcon={} - variant="contained" - > - {t('list.add')} - - - - - - - - - - - - - - - - - ); -} - -// Sorting and filtering has to be done on the server. - -function applySort(row: LpCategory[], sortDir: 'asc' | 'desc' | undefined): LpCategory[] { - 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: LpCategory[], { email, phone, status, name, visible }: Filters): LpCategory[] { - 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/app/dashboard/lp_questions/[cat_id]/BasicDetailCard.tsx b/002_source/cms/src/app/dashboard/lp_questions/[cat_id]/BasicDetailCard.tsx deleted file mode 100644 index 176fc8c..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/[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 { LpCategory } from '@/components/dashboard/lp_categories/type'; - -export default function BasicDetailCard({ - lpModel: model, - handleEditClick, -}: { - lpModel: LpCategory; - 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.cat_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/[cat_id]/TitleCard.tsx b/002_source/cms/src/app/dashboard/lp_questions/[cat_id]/TitleCard.tsx deleted file mode 100644 index f1ad1bc..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/[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 { LpCategory } from '@/components/dashboard/lp_categories/type'; - -function getImageUrlFrRecord(record: LpCategory): string { - return `http://127.0.0.1:8090/api/files/${record.collectionId}/${record.id}/${record.cat_image}`; -} - -export default function SampleTitleCard({ lpModel }: { lpModel: LpCategory }): React.JSX.Element { - const { t } = useTranslation(); - - return ( - <> - - - {t('empty')} - -
- - {lpModel.cat_name} - - } - label={lpModel.visible} - size="small" - variant="outlined" - /> - - - {lpModel.slug} - -
-
-
- -
- - ); -} diff --git a/002_source/cms/src/app/dashboard/lp_questions/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp_questions/[cat_id]/page.tsx deleted file mode 100644 index 366c535..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/[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_CATEGORIES } 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 { defaultLpCategory } from '@/components/dashboard/lp_categories/_constants.ts'; -import { Notifications } from '@/components/dashboard/lp_categories/notifications'; -import type { LpCategory } from '@/components/dashboard/lp_categories/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 [showLessonCategory, setShowLessonCategory] = React.useState(defaultLpCategory); - - function handleEditClick() { - router.push(paths.dashboard.lp_categories.edit(showLessonCategory.id)); - } - - React.useEffect(() => { - if (catId) { - pb.collection(COL_QUIZ_LP_CATEGORIES) - .getOne(catId) - .then((model: RecordModel) => { - setShowLessonCategory({ ...defaultLpCategory, ...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/create/page.tsx b/002_source/cms/src/app/dashboard/lp_questions/create/page.tsx deleted file mode 100644 index a3e7882..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/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 { LpCategoryCreateForm } from '@/components/dashboard/lp_categories/lp-category-create-form'; - -export default function Page(): React.JSX.Element { - // RULES: follow the name of page directory - const { t } = useTranslation(['lp_categories']); - - return ( - - - -
- - - {t('title')} - -
-
- {t('create.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp_questions/edit/[cat_id]/_PROMPT.md b/002_source/cms/src/app/dashboard/lp_questions/edit/[cat_id]/_PROMPT.md deleted file mode 100644 index abf4465..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/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/edit/[cat_id]/page.tsx b/002_source/cms/src/app/dashboard/lp_questions/edit/[cat_id]/page.tsx deleted file mode 100644 index 9f7f258..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/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 { LpCategoryEditForm } from '@/components/dashboard/lp_categories/lp-category-edit-form'; - -export default function Page(): React.JSX.Element { - const { t } = useTranslation(['lp_categories']); - - React.useEffect(() => { - // console.log('helloworld'); - }, []); - - return ( - - - -
- - - {t('edit.title')} - -
-
- {t('edit.title')} -
-
- -
-
- ); -} diff --git a/002_source/cms/src/app/dashboard/lp_questions/lp-categories-sample-data.tsx b/002_source/cms/src/app/dashboard/lp_questions/lp-categories-sample-data.tsx deleted file mode 100644 index 0c1aa79..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/lp-categories-sample-data.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { dayjs } from '@/lib/dayjs'; -import { LessonCategory } from '@/components/dashboard/lesson_category/type'; - -export const LpCategoriesSampleData = [ - { - id: 'USR-005', - name: 'Fran Perez', - avatar: '/assets/avatar-5.png', - email: 'fran.perez@domain.com', - phone: '(815) 704-0045', - quota: 50, - status: 'active', - createdAt: dayjs().subtract(1, 'hour').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-004', - name: 'Penjani Inyene', - avatar: '/assets/avatar-4.png', - email: 'penjani.inyene@domain.com', - phone: '(803) 937-8925', - quota: 100, - status: 'active', - createdAt: dayjs().subtract(3, 'hour').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-003', - name: 'Carson Darrin', - avatar: '/assets/avatar-3.png', - email: 'carson.darrin@domain.com', - phone: '(715) 278-5041', - quota: 10, - status: 'blocked', - createdAt: dayjs().subtract(1, 'hour').subtract(1, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-002', - name: 'Siegbert Gottfried', - avatar: '/assets/avatar-2.png', - email: 'siegbert.gottfried@domain.com', - phone: '(603) 766-0431', - quota: 0, - status: 'pending', - createdAt: dayjs().subtract(7, 'hour').subtract(1, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, - { - id: 'USR-001', - name: 'Miron Vitold', - avatar: '/assets/avatar-1.png', - email: 'miron.vitold@domain.com', - phone: '(425) 434-5535', - quota: 50, - status: 'active', - createdAt: dayjs().subtract(2, 'hour').subtract(2, 'day').toDate(), - collectionId: '0000000001', - cat_name: '', - pos: 99, - visible: 'visible', - lesson_id: 'lid_00001', - description: '', - remarks: '', - }, -] satisfies LessonCategory[]; diff --git a/002_source/cms/src/app/dashboard/lp_questions/page.tsx b/002_source/cms/src/app/dashboard/lp_questions/page.tsx deleted file mode 100644 index 24a908c..0000000 --- a/002_source/cms/src/app/dashboard/lp_questions/page.tsx +++ /dev/null @@ -1,213 +0,0 @@ -'use client'; - -// RULES: -// contains list page for lp_categories (QuizLPCategories) -// contain definition to collection only -// -import * as React from 'react'; -import { useRouter } from 'next/navigation'; -import { COL_QUIZ_LP_CATEGORIES } 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 { defaultLpCategory } from '@/components/dashboard/lp_categories/_constants'; -import { LpCategoriesFilters } from '@/components/dashboard/lp_categories/lp-categories-filters'; -import type { Filters } from '@/components/dashboard/lp_categories/lp-categories-filters'; -import { LpCategoriesPagination } from '@/components/dashboard/lp_categories/lp-categories-pagination'; -import { LpCategoriesSelectionProvider } from '@/components/dashboard/lp_categories/lp-categories-selection-context'; -import { LpCategoriesTable } from '@/components/dashboard/lp_categories/lp-categories-table'; -import type { LpCategory } from '@/components/dashboard/lp_categories/type'; -import FormLoading from '@/components/loading'; - -export default function Page({ searchParams }: PageProps): React.JSX.Element { - const { t } = useTranslation(['lp_categories']); - const { email, phone, sortDir, status, name, visible, type } = searchParams; - const router = useRouter(); - const [lessonCategoriesData, setLessonCategoriesData] = 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 [f, setF] = 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 sortedLessonCategories = applySort(lessonCategoriesData, sortDir); - const filteredLessonCategories = applyFilters(sortedLessonCategories, { email, phone, status }); - - const reloadRows = async (): Promise => { - try { - const models: ListResult = await pb - .collection(COL_QUIZ_LP_CATEGORIES) - .getList(currentPage + 1, rowsPerPage, {}); - const { items, totalItems } = models; - const tempLessonTypes: LpCategory[] = items.map((lt) => { - return { ...defaultLpCategory, ...lt }; - }); - - setLessonCategoriesData(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_categories.create); - }} - startIcon={} - variant="contained" - > - {t('list.add')} - - - - - - - - - - - - - - - - - ); -} - -// Sorting and filtering has to be done on the server. - -function applySort(row: LpCategory[], sortDir: 'asc' | 'desc' | undefined): LpCategory[] { - 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: LpCategory[], { email, phone, status, name, visible }: Filters): LpCategory[] { - 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; - // - }; -}