update user-meta,
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
// src/app/dashboard/students/edit/[customerId]/page.tsx
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import RouterLink from 'next/link';
|
import RouterLink from 'next/link';
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/teachers/view/[id]/TitleCard.tsx.draft` to handle `Teacher` record thanks, modify comments/variables/paths/functions name please
|
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/user_metas/edit/[id]/page.tsx.draft` to handle `UserMeta` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
e.g. why `lessonCategories` still exist ?
|
e.g. why `lessonCategories` still exist ?
|
@@ -1,4 +1,5 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
// src/app/dashboard/user_metas/edit/[id]/page.tsx
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import RouterLink from 'next/link';
|
import RouterLink from 'next/link';
|
||||||
@@ -11,7 +12,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import { paths } from '@/paths';
|
import { paths } from '@/paths';
|
||||||
import { CrCategoryEditForm } from '@/components/dashboard/cr/categories/cr-category-edit-form';
|
import { CrCategoryEditForm } from '@/components/dashboard/cr/categories/cr-category-edit-form';
|
||||||
import { TeacherEditForm } from '@/components/dashboard/teacher/teacher-edit-form';
|
import { UserMetaEditForm } from '@/components/dashboard/user_meta/user-meta-edit-form';
|
||||||
|
|
||||||
export default function Page(): React.JSX.Element {
|
export default function Page(): React.JSX.Element {
|
||||||
const { t } = useTranslation(['lp_categories']);
|
const { t } = useTranslation(['lp_categories']);
|
||||||
@@ -35,7 +36,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
<Link
|
<Link
|
||||||
color="text.primary"
|
color="text.primary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.teachers.list}
|
href={paths.dashboard.user_metas.list}
|
||||||
sx={{ alignItems: 'center', display: 'inline-flex', gap: 1 }}
|
sx={{ alignItems: 'center', display: 'inline-flex', gap: 1 }}
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
>
|
>
|
||||||
@@ -47,7 +48,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
<Typography variant="h4">{t('edit.title')}</Typography>
|
<Typography variant="h4">{t('edit.title')}</Typography>
|
||||||
</div>
|
</div>
|
||||||
</Stack>
|
</Stack>
|
||||||
<TeacherEditForm />
|
<UserMetaEditForm />
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
@@ -1,3 +1,3 @@
|
|||||||
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/teachers/list/page.tsx.draft` to handle `Teacher` record thanks, modify comments/variables/paths/functions name please
|
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/user_metas/list/page.tsx.draft` to handle `UserMeta` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
e.g. why `lessonCategories` still exist ?
|
e.g. why `lessonCategories` still exist ?
|
@@ -1,8 +1,8 @@
|
|||||||
// src/app/dashboard/teachers/list/page.tsx
|
// src/app/dashboard/user_metas/list/page.tsx
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
// RULES:
|
// RULES:
|
||||||
// contains list page for teachers (Teachers)
|
// contains list page for user metas (UserMetas)
|
||||||
//
|
//
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
@@ -16,11 +16,11 @@ import Typography from '@mui/material/Typography';
|
|||||||
import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus';
|
import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus';
|
||||||
import type { ListResult, RecordModel } from 'pocketbase';
|
import type { ListResult, RecordModel } from 'pocketbase';
|
||||||
|
|
||||||
import { TeachersFilters } from '@/components/dashboard/teacher/teachers-filters';
|
import { UserMetasFilters } from '@/components/dashboard/user_meta/user-metas-filters';
|
||||||
import { TeachersPagination } from '@/components/dashboard/teacher/teachers-pagination';
|
import { UserMetasPagination } from '@/components/dashboard/user_meta/user-metas-pagination';
|
||||||
import { TeachersSelectionProvider } from '@/components/dashboard/teacher/teachers-selection-context';
|
import { UserMetasSelectionProvider } from '@/components/dashboard/user_meta/user-metas-selection-context';
|
||||||
import { TeachersTable } from '@/components/dashboard/teacher/teachers-table';
|
import { UserMetasTable } from '@/components/dashboard/user_meta/user-metas-table';
|
||||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
import type { UserMeta } from '@/components/dashboard/user_meta/type.d';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { paths } from '@/paths';
|
import { paths } from '@/paths';
|
||||||
@@ -28,7 +28,7 @@ import isDevelopment from '@/lib/check-is-development';
|
|||||||
import { logger } from '@/lib/default-logger';
|
import { logger } from '@/lib/default-logger';
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import ErrorDisplay from '@/components/dashboard/error';
|
import ErrorDisplay from '@/components/dashboard/error';
|
||||||
import { defaultTeacher } from '@/components/dashboard/teacher/_constants';
|
import { defaultUserMeta } from '@/components/dashboard/user_meta/_constants';
|
||||||
import FormLoading from '@/components/loading';
|
import FormLoading from '@/components/loading';
|
||||||
|
|
||||||
export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||||
@@ -37,7 +37,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
|
|
||||||
const { email, phone, sortDir, status } = searchParams;
|
const { email, phone, sortDir, status } = searchParams;
|
||||||
|
|
||||||
const [teacherData, setTeacherData] = React.useState<Teacher[]>([]);
|
const [userMetaData, setUserMetaData] = React.useState<UserMeta[]>([]);
|
||||||
|
|
||||||
const [isLoadingAddPage, setIsLoadingAddPage] = React.useState<boolean>(false);
|
const [isLoadingAddPage, setIsLoadingAddPage] = React.useState<boolean>(false);
|
||||||
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
||||||
@@ -45,7 +45,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
//
|
//
|
||||||
const [rowsPerPage, setRowsPerPage] = React.useState<number>(5);
|
const [rowsPerPage, setRowsPerPage] = React.useState<number>(5);
|
||||||
//
|
//
|
||||||
const [f, setF] = React.useState<Teacher[]>([]);
|
const [f, setF] = React.useState<UserMeta[]>([]);
|
||||||
const [currentPage, setCurrentPage] = React.useState<number>(0);
|
const [currentPage, setCurrentPage] = React.useState<number>(0);
|
||||||
//
|
//
|
||||||
const [recordCount, setRecordCount] = React.useState<number>(0);
|
const [recordCount, setRecordCount] = React.useState<number>(0);
|
||||||
@@ -58,23 +58,17 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
//
|
//
|
||||||
const reloadRows = async (): Promise<void> => {
|
const reloadRows = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const listOptionTeacherOnly = isListOptionChanged()
|
|
||||||
? { filter: `role = "teacher"` }
|
|
||||||
: { filter: [listOption.filter, `role = "teacher"`].join(' && ') };
|
|
||||||
|
|
||||||
console.log({ listOptionTeacherOnly });
|
|
||||||
|
|
||||||
const models: ListResult<RecordModel> = await pb
|
const models: ListResult<RecordModel> = await pb
|
||||||
.collection(COL_USER_METAS)
|
.collection(COL_USER_METAS)
|
||||||
.getList(currentPage + 1, rowsPerPage, listOptionTeacherOnly);
|
.getList(currentPage + 1, rowsPerPage, listOption);
|
||||||
const { items, totalItems } = models;
|
const { items, totalItems } = models;
|
||||||
const tempTeacher: Teacher[] = items.map((lt) => {
|
const tempUserMeta: UserMeta[] = items.map((lt) => {
|
||||||
return { ...defaultTeacher, ...lt };
|
return { ...defaultUserMeta, ...lt };
|
||||||
});
|
});
|
||||||
|
|
||||||
setTeacherData(tempTeacher);
|
setUserMetaData(tempUserMeta);
|
||||||
setRecordCount(totalItems);
|
setRecordCount(totalItems);
|
||||||
setF(tempTeacher);
|
setF(tempUserMeta);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
setShowError({
|
setShowError({
|
||||||
@@ -166,7 +160,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
loading={isLoadingAddPage}
|
loading={isLoadingAddPage}
|
||||||
onClick={(): void => {
|
onClick={(): void => {
|
||||||
setIsLoadingAddPage(true);
|
setIsLoadingAddPage(true);
|
||||||
router.push(paths.dashboard.teachers.create);
|
router.push(paths.dashboard.user_metas.create);
|
||||||
}}
|
}}
|
||||||
startIcon={<PlusIcon />}
|
startIcon={<PlusIcon />}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@@ -175,22 +169,22 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<TeachersSelectionProvider teachers={f}>
|
<UserMetasSelectionProvider userMetas={f}>
|
||||||
<Card>
|
<Card>
|
||||||
<TeachersFilters
|
<UserMetasFilters
|
||||||
filters={{ email, phone, status }}
|
filters={{ email, phone, status }}
|
||||||
fullData={teacherData}
|
fullData={userMetaData}
|
||||||
sortDir={sortDir}
|
sortDir={sortDir}
|
||||||
/>
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Box sx={{ overflowX: 'auto' }}>
|
<Box sx={{ overflowX: 'auto' }}>
|
||||||
<TeachersTable
|
<UserMetasTable
|
||||||
reloadRows={reloadRows}
|
reloadRows={reloadRows}
|
||||||
rows={f}
|
rows={f}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Divider />
|
<Divider />
|
||||||
<TeachersPagination
|
<UserMetasPagination
|
||||||
count={recordCount}
|
count={recordCount}
|
||||||
page={currentPage}
|
page={currentPage}
|
||||||
rowsPerPage={rowsPerPage}
|
rowsPerPage={rowsPerPage}
|
||||||
@@ -198,7 +192,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
setRowsPerPage={setRowsPerPage}
|
setRowsPerPage={setRowsPerPage}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</TeachersSelectionProvider>
|
</UserMetasSelectionProvider>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box sx={{ display: isDevelopment ? 'block' : 'none' }}>
|
<Box sx={{ display: isDevelopment ? 'block' : 'none' }}>
|
||||||
<pre>{JSON.stringify(f, null, 2)}</pre>
|
<pre>{JSON.stringify(f, null, 2)}</pre>
|
@@ -14,13 +14,13 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { PropertyItem } from '@/components/core/property-item';
|
import { PropertyItem } from '@/components/core/property-item';
|
||||||
import { PropertyList } from '@/components/core/property-list';
|
import { PropertyList } from '@/components/core/property-list';
|
||||||
// import { CrCategory } from '@/components/dashboard/cr/categories/type';
|
// import { CrCategory } from '@/components/dashboard/cr/categories/type';
|
||||||
import type { Customer } from '@/components/dashboard/customer/type.d';
|
import type { UserMeta } from '@/components/dashboard/user_meta/type.d';
|
||||||
|
|
||||||
export default function BasicDetailCard({
|
export default function BasicDetailCard({
|
||||||
lpModel: model,
|
userMeta,
|
||||||
handleEditClick,
|
handleEditClick,
|
||||||
}: {
|
}: {
|
||||||
lpModel: Customer;
|
userMeta: UserMeta;
|
||||||
handleEditClick: () => void;
|
handleEditClick: () => void;
|
||||||
}): React.JSX.Element {
|
}): React.JSX.Element {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -55,15 +55,15 @@ export default function BasicDetailCard({
|
|||||||
key: 'Customer ID',
|
key: 'Customer ID',
|
||||||
value: (
|
value: (
|
||||||
<Chip
|
<Chip
|
||||||
label={model.id}
|
label={userMeta.id}
|
||||||
size="small"
|
size="small"
|
||||||
variant="soft"
|
variant="soft"
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ key: 'Email', value: model.email },
|
{ key: 'Email', value: userMeta.email },
|
||||||
{ key: 'Quota', value: model.quota },
|
{ key: 'Quota', value: userMeta.quota },
|
||||||
{ key: 'Status', value: model.status },
|
{ key: 'Status', value: userMeta.status },
|
||||||
] satisfies { key: string; value: React.ReactNode }[]
|
] satisfies { key: string; value: React.ReactNode }[]
|
||||||
).map(
|
).map(
|
||||||
(item): React.JSX.Element => (
|
(item): React.JSX.Element => (
|
@@ -0,0 +1,7 @@
|
|||||||
|
working file: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/user_metas/view/[id]/page.tsx.draft`
|
||||||
|
|
||||||
|
this file is clone from elsewhere, please understand, modify and update the content of working file to handle `UserMeta` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
restrict your modifications in this file only
|
||||||
|
|
||||||
|
e.g. why `lessonCategories` still exist ?
|
@@ -24,12 +24,12 @@ import { toast } from '@/components/core/toaster';
|
|||||||
|
|
||||||
import ErrorDisplay from '@/components/dashboard/error';
|
import ErrorDisplay from '@/components/dashboard/error';
|
||||||
|
|
||||||
import { Notifications } from '@/components/dashboard/teacher/notifications';
|
import { Notifications } from '@/components/dashboard/user_meta/notifications';
|
||||||
import FormLoading from '@/components/loading';
|
import FormLoading from '@/components/loading';
|
||||||
import BasicDetailCard from './BasicDetailCard';
|
import BasicDetailCard from './BasicDetailCard';
|
||||||
import TitleCard from './TitleCard';
|
import TitleCard from './TitleCard';
|
||||||
import { defaultTeacher } from '@/components/dashboard/teacher/_constants';
|
import { defaultUserMeta } from '@/components/dashboard/user_meta/_constants';
|
||||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
import type { UserMeta } from '@/components/dashboard/user_meta/type.d';
|
||||||
import { COL_USER_METAS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
|
|
||||||
export default function Page(): React.JSX.Element {
|
export default function Page(): React.JSX.Element {
|
||||||
@@ -41,10 +41,10 @@ export default function Page(): React.JSX.Element {
|
|||||||
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
||||||
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
||||||
//
|
//
|
||||||
const [showLessonCategory, setShowLessonCategory] = React.useState<Teacher>(defaultTeacher);
|
const [userMeta, setUserMeta] = React.useState<UserMeta>(defaultUserMeta);
|
||||||
|
|
||||||
function handleEditClick(): void {
|
function handleEditClick(): void {
|
||||||
router.push(paths.dashboard.teachers.edit(showLessonCategory.id));
|
router.push(paths.dashboard.user_metas.edit(userMeta.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -52,7 +52,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
pb.collection(COL_USER_METAS)
|
pb.collection(COL_USER_METAS)
|
||||||
.getOne(id)
|
.getOne(id)
|
||||||
.then((model: RecordModel) => {
|
.then((model: RecordModel) => {
|
||||||
setShowLessonCategory({ ...defaultTeacher, ...model });
|
setUserMeta({ ...defaultUserMeta, ...model });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
@@ -94,12 +94,12 @@ export default function Page(): React.JSX.Element {
|
|||||||
<Link
|
<Link
|
||||||
color="text.primary"
|
color="text.primary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.teachers.list}
|
href={paths.dashboard.user_metas.list}
|
||||||
sx={{ alignItems: 'center', display: 'inline-flex', gap: 1 }}
|
sx={{ alignItems: 'center', display: 'inline-flex', gap: 1 }}
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
>
|
>
|
||||||
<ArrowLeftIcon fontSize="var(--icon-fontSize-md)" />
|
<ArrowLeftIcon fontSize="var(--icon-fontSize-md)" />
|
||||||
Teachers
|
User Metas
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -107,7 +107,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
spacing={3}
|
spacing={3}
|
||||||
sx={{ alignItems: 'flex-start' }}
|
sx={{ alignItems: 'flex-start' }}
|
||||||
>
|
>
|
||||||
<TitleCard teacherRecord={showLessonCategory} />
|
<TitleCard teacherRecord={userMeta} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Grid
|
<Grid
|
||||||
@@ -120,7 +120,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
>
|
>
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<BasicDetailCard
|
<BasicDetailCard
|
||||||
lpModel={showLessonCategory}
|
userMeta={userMeta}
|
||||||
handleEditClick={handleEditClick}
|
handleEditClick={handleEditClick}
|
||||||
/>
|
/>
|
||||||
<SampleSecurityCard />
|
<SampleSecurityCard />
|
@@ -1,216 +0,0 @@
|
|||||||
// src/app/dashboard/teachers/list/page.tsx
|
|
||||||
'use client';
|
|
||||||
|
|
||||||
// RULES:
|
|
||||||
// contains list page for teachers (Teachers)
|
|
||||||
//
|
|
||||||
import * as React from 'react';
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import { COL_USER_METAS } 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 { TeachersFilters } from '@/components/dashboard/teacher/teachers-filters';
|
|
||||||
import { TeachersPagination } from '@/components/dashboard/teacher/teachers-pagination';
|
|
||||||
import { TeachersSelectionProvider } from '@/components/dashboard/teacher/teachers-selection-context';
|
|
||||||
import { TeachersTable } from '@/components/dashboard/teacher/teachers-table';
|
|
||||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { paths } from '@/paths';
|
|
||||||
import isDevelopment from '@/lib/check-is-development';
|
|
||||||
import { logger } from '@/lib/default-logger';
|
|
||||||
import { pb } from '@/lib/pb';
|
|
||||||
import ErrorDisplay from '@/components/dashboard/error';
|
|
||||||
import { defaultTeacher } from '@/components/dashboard/teacher/_constants';
|
|
||||||
import FormLoading from '@/components/loading';
|
|
||||||
|
|
||||||
export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|
||||||
const { t } = useTranslation(['teachers']);
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const { email, phone, sortDir, status } = searchParams;
|
|
||||||
|
|
||||||
const [teacherData, setTeacherData] = React.useState<Teacher[]>([]);
|
|
||||||
|
|
||||||
const [isLoadingAddPage, setIsLoadingAddPage] = React.useState<boolean>(false);
|
|
||||||
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
|
||||||
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
|
||||||
//
|
|
||||||
const [rowsPerPage, setRowsPerPage] = React.useState<number>(5);
|
|
||||||
//
|
|
||||||
const [f, setF] = React.useState<Teacher[]>([]);
|
|
||||||
const [currentPage, setCurrentPage] = React.useState<number>(0);
|
|
||||||
//
|
|
||||||
const [recordCount, setRecordCount] = React.useState<number>(0);
|
|
||||||
const [listOption, setListOption] = React.useState({ filter: '' });
|
|
||||||
const [listSort, setListSort] = React.useState({});
|
|
||||||
|
|
||||||
function isListOptionChanged() {
|
|
||||||
return JSON.stringify(listOption) === '{}';
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const reloadRows = async (): Promise<void> => {
|
|
||||||
try {
|
|
||||||
const listOptionTeacherOnly = isListOptionChanged()
|
|
||||||
? { filter: `role = "teacher"` }
|
|
||||||
: { filter: [listOption.filter, `role = "teacher"`].join(' && ') };
|
|
||||||
|
|
||||||
const models: ListResult<RecordModel> = await pb
|
|
||||||
.collection(COL_USER_METAS)
|
|
||||||
.getList(currentPage + 1, rowsPerPage, listOptionTeacherOnly);
|
|
||||||
const { items, totalItems } = models;
|
|
||||||
const tempTeacher: Teacher[] = items.map((lt) => {
|
|
||||||
return { ...defaultTeacher, ...lt };
|
|
||||||
});
|
|
||||||
|
|
||||||
setTeacherData(tempTeacher);
|
|
||||||
setRecordCount(totalItems);
|
|
||||||
setF(tempTeacher);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(error);
|
|
||||||
setShowError({
|
|
||||||
//
|
|
||||||
show: true,
|
|
||||||
detail: JSON.stringify(error, null, 2),
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setShowLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const [lastListOption, setLastListOption] = React.useState({});
|
|
||||||
const isFirstRun = React.useRef(false);
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (!isFirstRun.current) {
|
|
||||||
isFirstRun.current = true;
|
|
||||||
} else if (JSON.stringify(listOption) !== JSON.stringify(lastListOption)) {
|
|
||||||
// reset page number as tab changes
|
|
||||||
setLastListOption(listOption);
|
|
||||||
setCurrentPage(0);
|
|
||||||
void reloadRows();
|
|
||||||
} else {
|
|
||||||
void reloadRows();
|
|
||||||
}
|
|
||||||
}, [currentPage, rowsPerPage, listOption]);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
const tempFilter = [];
|
|
||||||
let tempSortDir = '';
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
tempFilter.push(`status = "${status}"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sortDir) {
|
|
||||||
tempSortDir = `-created`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (email) {
|
|
||||||
tempFilter.push(`email ~ "%${email}%"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (phone) {
|
|
||||||
tempFilter.push(`phone ~ "%${phone}%"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let preFinalListOption = { filter: '' };
|
|
||||||
if (tempFilter.length > 0) {
|
|
||||||
preFinalListOption = { filter: tempFilter.join(' && ') };
|
|
||||||
}
|
|
||||||
if (tempSortDir.length > 0) {
|
|
||||||
preFinalListOption = { ...preFinalListOption, sort: tempSortDir };
|
|
||||||
}
|
|
||||||
setListOption(preFinalListOption);
|
|
||||||
}, [sortDir, email, phone, status]);
|
|
||||||
|
|
||||||
if (showLoading) return <FormLoading />;
|
|
||||||
|
|
||||||
if (showError.show)
|
|
||||||
return (
|
|
||||||
<ErrorDisplay
|
|
||||||
message={t('error.unable-to-process-request')}
|
|
||||||
code={-1}
|
|
||||||
details={showError.detail}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
maxWidth: 'var(--Content-maxWidth)',
|
|
||||||
m: 'var(--Content-margin)',
|
|
||||||
p: 'var(--Content-padding)',
|
|
||||||
width: 'var(--Content-width)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack spacing={4}>
|
|
||||||
<Stack
|
|
||||||
direction={{ xs: 'column', sm: 'row' }}
|
|
||||||
spacing={3}
|
|
||||||
sx={{ alignItems: 'flex-start' }}
|
|
||||||
>
|
|
||||||
<Box sx={{ flex: '1 1 auto' }}>
|
|
||||||
<Typography variant="h4">{t('list.title')}</Typography>
|
|
||||||
</Box>
|
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
||||||
<LoadingButton
|
|
||||||
loading={isLoadingAddPage}
|
|
||||||
onClick={(): void => {
|
|
||||||
setIsLoadingAddPage(true);
|
|
||||||
router.push(paths.dashboard.teachers.create);
|
|
||||||
}}
|
|
||||||
startIcon={<PlusIcon />}
|
|
||||||
variant="contained"
|
|
||||||
>
|
|
||||||
{t('list.add')}
|
|
||||||
</LoadingButton>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
<TeachersSelectionProvider teachers={f}>
|
|
||||||
<Card>
|
|
||||||
<TeachersFilters
|
|
||||||
filters={{ email, phone, status }}
|
|
||||||
fullData={teacherData}
|
|
||||||
sortDir={sortDir}
|
|
||||||
/>
|
|
||||||
<Divider />
|
|
||||||
<Box sx={{ overflowX: 'auto' }}>
|
|
||||||
<TeachersTable
|
|
||||||
reloadRows={reloadRows}
|
|
||||||
rows={f}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Divider />
|
|
||||||
<TeachersPagination
|
|
||||||
count={recordCount}
|
|
||||||
page={currentPage}
|
|
||||||
rowsPerPage={rowsPerPage}
|
|
||||||
setPage={setCurrentPage}
|
|
||||||
setRowsPerPage={setRowsPerPage}
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
</TeachersSelectionProvider>
|
|
||||||
</Stack>
|
|
||||||
<Box sx={{ display: isDevelopment ? 'block' : 'none' }}>
|
|
||||||
<pre>{JSON.stringify(f, null, 2)}</pre>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PageProps {
|
|
||||||
searchParams: {
|
|
||||||
email?: string;
|
|
||||||
phone?: string;
|
|
||||||
sortDir?: 'asc' | 'desc';
|
|
||||||
status?: string;
|
|
||||||
//
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,143 +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/PaymentCard';
|
|
||||||
import SampleSecurityCard from '@/app/dashboard/Sample/SecurityCard';
|
|
||||||
|
|
||||||
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 { config } from '@/config';
|
|
||||||
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 { Notifications } from '@/components/dashboard/teacher/notifications';
|
|
||||||
import FormLoading from '@/components/loading';
|
|
||||||
import BasicDetailCard from './BasicDetailCard';
|
|
||||||
import TitleCard from './TitleCard';
|
|
||||||
import { defaultTeacher } from '@/components/dashboard/teacher/_constants';
|
|
||||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
|
||||||
import { COL_USER_METAS } from '@/constants';
|
|
||||||
|
|
||||||
export default function Page(): React.JSX.Element {
|
|
||||||
const { t } = useTranslation(['teachers']);
|
|
||||||
const router = useRouter();
|
|
||||||
//
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
//
|
|
||||||
const [showLoading, setShowLoading] = React.useState<boolean>(true);
|
|
||||||
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
|
||||||
//
|
|
||||||
const [teacherData, setTeacherData] = React.useState<Teacher>(defaultTeacher);
|
|
||||||
|
|
||||||
function handleEditClick(): void {
|
|
||||||
router.push(paths.dashboard.teachers.edit(teacherData.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (id) {
|
|
||||||
pb.collection(COL_USER_METAS)
|
|
||||||
.getOne(id)
|
|
||||||
.then((model: RecordModel) => {
|
|
||||||
setTeacherData({ ...defaultTeacher, ...model });
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
logger.error(err);
|
|
||||||
toast(t('list.error'));
|
|
||||||
|
|
||||||
setShowError({ show: true, detail: JSON.stringify(err) });
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setShowLoading(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [id]);
|
|
||||||
|
|
||||||
// return <>{JSON.stringify({ showError, showLessonCategory }, null, 2)}</>;
|
|
||||||
|
|
||||||
if (showLoading) return <FormLoading />;
|
|
||||||
if (showError.show)
|
|
||||||
return (
|
|
||||||
<ErrorDisplay
|
|
||||||
message={t('error.unable-to-process-request')}
|
|
||||||
code="500"
|
|
||||||
details={showError.detail}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
maxWidth: 'var(--Content-maxWidth)',
|
|
||||||
m: 'var(--Content-margin)',
|
|
||||||
p: 'var(--Content-padding)',
|
|
||||||
width: 'var(--Content-width)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack spacing={4}>
|
|
||||||
<Stack spacing={3}>
|
|
||||||
<div>
|
|
||||||
<Link
|
|
||||||
color="text.primary"
|
|
||||||
component={RouterLink}
|
|
||||||
href={paths.dashboard.teachers.list}
|
|
||||||
sx={{ alignItems: 'center', display: 'inline-flex', gap: 1 }}
|
|
||||||
variant="subtitle2"
|
|
||||||
>
|
|
||||||
<ArrowLeftIcon fontSize="var(--icon-fontSize-md)" />
|
|
||||||
{t('back-to-list')}
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
<Stack
|
|
||||||
direction={{ xs: 'column', sm: 'row' }}
|
|
||||||
spacing={3}
|
|
||||||
sx={{ alignItems: 'flex-start' }}
|
|
||||||
>
|
|
||||||
<TitleCard lpModel={teacherData} />
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
spacing={4}
|
|
||||||
>
|
|
||||||
<Grid
|
|
||||||
lg={4}
|
|
||||||
xs={12}
|
|
||||||
>
|
|
||||||
<Stack spacing={4}>
|
|
||||||
<BasicDetailCard
|
|
||||||
lpModel={teacherData}
|
|
||||||
handleEditClick={handleEditClick}
|
|
||||||
/>
|
|
||||||
<SampleSecurityCard />
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
<Grid
|
|
||||||
lg={8}
|
|
||||||
xs={12}
|
|
||||||
>
|
|
||||||
<Stack spacing={4}>
|
|
||||||
<SamplePaymentCard />
|
|
||||||
<SampleAddressCard />
|
|
||||||
<Notifications notifications={SampleNotifications} />
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
@@ -116,9 +116,9 @@ export const layoutConfig = {
|
|||||||
title: 'users',
|
title: 'users',
|
||||||
icon: 'users',
|
icon: 'users',
|
||||||
items: [
|
items: [
|
||||||
{ key: 'users', title: 'List users', href: paths.dashboard.users.list },
|
{ key: 'users', title: 'List users', href: paths.dashboard.user_metas.list },
|
||||||
{ key: 'users:create', title: 'Create user', href: paths.dashboard.users.create },
|
{ key: 'users:create', title: 'Create user', href: paths.dashboard.user_metas.create },
|
||||||
{ key: 'users:details', title: 'User details', href: paths.dashboard.users.view('1') },
|
{ key: 'users:details', title: 'User details', href: paths.dashboard.user_metas.view('1') },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -6,6 +6,7 @@ export type SortDir = 'asc' | 'desc';
|
|||||||
// RULES: core student data structure
|
// RULES: core student data structure
|
||||||
export interface Student {
|
export interface Student {
|
||||||
id: string;
|
id: string;
|
||||||
|
collectionId: string;
|
||||||
name: string;
|
name: string;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
@@ -104,7 +104,7 @@ export function UserCreateForm(): React.JSX.Element {
|
|||||||
// Use standard create method from db/Customers/Create
|
// Use standard create method from db/Customers/Create
|
||||||
const record = await createUser(values);
|
const record = await createUser(values);
|
||||||
toast.success('User created successfully');
|
toast.success('User created successfully');
|
||||||
router.push(paths.dashboard.users.details(record.id));
|
router.push(paths.dashboard.user_metas.details(record.id));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
toast.error('Failed to create user. Please try again.');
|
toast.error('Failed to create user. Please try again.');
|
||||||
@@ -509,7 +509,7 @@ export function UserCreateForm(): React.JSX.Element {
|
|||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.users.list}
|
href={paths.dashboard.user_metas.list}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -125,7 +125,7 @@ export function UserEditForm(): React.JSX.Element {
|
|||||||
try {
|
try {
|
||||||
await pb.collection(COL_USERS).update(userId, updateData);
|
await pb.collection(COL_USERS).update(userId, updateData);
|
||||||
toast.success('User updated successfully');
|
toast.success('User updated successfully');
|
||||||
router.push(paths.dashboard.users.list);
|
router.push(paths.dashboard.user_metas.list);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
toast.error('Failed to update user');
|
toast.error('Failed to update user');
|
||||||
@@ -581,7 +581,7 @@ export function UserEditForm(): React.JSX.Element {
|
|||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.users.list}
|
href={paths.dashboard.user_metas.list}
|
||||||
>
|
>
|
||||||
{t('edit.cancelButton')}
|
{t('edit.cancelButton')}
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -44,7 +44,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<User>[]
|
|||||||
<Link
|
<Link
|
||||||
color="inherit"
|
color="inherit"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.users.view(row.id)}
|
href={paths.dashboard.user_metas.view(row.id)}
|
||||||
sx={{ whiteSpace: 'nowrap' }}
|
sx={{ whiteSpace: 'nowrap' }}
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
>
|
>
|
||||||
@@ -143,7 +143,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<User>[]
|
|||||||
//
|
//
|
||||||
color="secondary"
|
color="secondary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.users.view(row.id)}
|
href={paths.dashboard.user_metas.view(row.id)}
|
||||||
>
|
>
|
||||||
<PencilSimpleIcon size={24} />
|
<PencilSimpleIcon size={24} />
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
# GUIDELINES & KEY COMPONENTS
|
|
||||||
|
|
||||||
- `_constants.ts` contains the constant for
|
|
||||||
|
|
||||||
- default value (defaultValue)
|
|
||||||
- empty value (emptyValue)
|
|
||||||
|
|
||||||
- `teachers-table.tsx`
|
|
||||||
|
|
||||||
- `confirm-delete-modal.tsx` - delete modal component when click delete button on list
|
|
||||||
|
|
||||||
- `teachers-filters.tsx`
|
|
||||||
- `teachers-pagination.tsx`
|
|
||||||
- `email-filter-popover.tsx`
|
|
||||||
- `phone-filter-popover.tsx`
|
|
||||||
- `teachers-selection-context.tsx`
|
|
||||||
|
|
||||||
- `teacher-create-form.tsx` - form to create a new teacher
|
|
||||||
- `teacher-edit-form.tsx` - form to edit an existing teacher
|
|
||||||
|
|
||||||
- `type.d.tsx` - contains type definition
|
|
||||||
|
|
||||||
- `notifications.tsx` - constants used for demonstration
|
|
||||||
- `payments.tsx` - constants used for demonstration
|
|
||||||
- `shipping-address.tsx` - constants used for demonstration
|
|
@@ -1,43 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import { useSelection } from '@/hooks/use-selection';
|
|
||||||
import type { Selection } from '@/hooks/use-selection';
|
|
||||||
|
|
||||||
import type { Teacher } from './type.d';
|
|
||||||
|
|
||||||
function noop(): void {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CustomersSelectionContextValue extends Selection {}
|
|
||||||
|
|
||||||
export const CustomersSelectionContext = React.createContext<CustomersSelectionContextValue>({
|
|
||||||
deselectAll: noop,
|
|
||||||
deselectOne: noop,
|
|
||||||
selectAll: noop,
|
|
||||||
selectOne: noop,
|
|
||||||
selected: new Set(),
|
|
||||||
selectedAny: false,
|
|
||||||
selectedAll: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
interface CustomersSelectionProviderProps {
|
|
||||||
children: React.ReactNode;
|
|
||||||
teachers: Teacher[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TeachersSelectionProvider({
|
|
||||||
children,
|
|
||||||
teachers = [],
|
|
||||||
}: CustomersSelectionProviderProps): React.JSX.Element {
|
|
||||||
const customerIds = React.useMemo(() => teachers.map((customer) => customer.id), [teachers]);
|
|
||||||
const selection = useSelection(customerIds);
|
|
||||||
|
|
||||||
return <CustomersSelectionContext.Provider value={{ ...selection }}>{children}</CustomersSelectionContext.Provider>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useTeachersSelection(): CustomersSelectionContextValue {
|
|
||||||
return React.useContext(CustomersSelectionContext);
|
|
||||||
}
|
|
@@ -0,0 +1,26 @@
|
|||||||
|
# USER META GUIDELINES & KEY COMPONENTS
|
||||||
|
|
||||||
|
## Core Files
|
||||||
|
|
||||||
|
- `_constants.ts` - Contains default and empty values for UserMeta records
|
||||||
|
- `user-meta-table.tsx` - Main table component for displaying UserMeta records
|
||||||
|
- `type.d.tsx` - Type definitions for UserMeta
|
||||||
|
|
||||||
|
## CRUD Components
|
||||||
|
|
||||||
|
- `confirm-delete-modal.tsx` - Delete confirmation modal
|
||||||
|
- `user-meta-create-form.tsx` - Form for creating new UserMeta records
|
||||||
|
- `user-meta-edit-form.tsx` - Form for editing existing UserMeta records
|
||||||
|
|
||||||
|
## Supporting Components
|
||||||
|
|
||||||
|
- `user-meta-filters.tsx` - Filter controls for the table
|
||||||
|
- `user-meta-pagination.tsx` - Pagination controls
|
||||||
|
- `user-meta-selection-context.tsx` - Context for selected records
|
||||||
|
|
||||||
|
## Implementation Notes
|
||||||
|
|
||||||
|
1. All components should work with the UserMeta type from `type.d.tsx`
|
||||||
|
2. Follow existing patterns for API calls and state management
|
||||||
|
3. Ensure proper validation for all UserMeta fields
|
||||||
|
4. Maintain consistent naming conventions (userMeta prefix for components)
|
@@ -0,0 +1,3 @@
|
|||||||
|
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/components/dashboard/user_meta/confirm-delete-modal.tsx.draft` to handle `UserMeta` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
e.g. why `lessonCategories` still exist ?
|
@@ -3,9 +3,9 @@
|
|||||||
// empty valur for customer
|
// empty valur for customer
|
||||||
|
|
||||||
import { dayjs } from '@/lib/dayjs';
|
import { dayjs } from '@/lib/dayjs';
|
||||||
import type { Teacher } from './type.d';
|
import type { UserMeta } from './type.d';
|
||||||
|
|
||||||
export const defaultTeacher: Teacher = {
|
export const defaultUserMeta: UserMeta = {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
avatar: undefined,
|
avatar: undefined,
|
||||||
@@ -16,6 +16,6 @@ export const defaultTeacher: Teacher = {
|
|||||||
createdAt: dayjs().toDate(),
|
createdAt: dayjs().toDate(),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const emptyLpCategory: Teacher = {
|
export const emptyLpCategory: UserMeta = {
|
||||||
...defaultTeacher,
|
...defaultUserMeta,
|
||||||
};
|
};
|
@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import { logger } from '@/lib/default-logger';
|
import { logger } from '@/lib/default-logger';
|
||||||
import { toast } from '@/components/core/toaster';
|
import { toast } from '@/components/core/toaster';
|
||||||
import { deleteTeacher } from '@/db/Teachers/Delete';
|
import { deleteUserMeta } from '@/db/UserMetas/Delete';
|
||||||
|
|
||||||
export default function ConfirmDeleteModal({
|
export default function ConfirmDeleteModal({
|
||||||
open,
|
open,
|
||||||
@@ -45,7 +45,7 @@ export default function ConfirmDeleteModal({
|
|||||||
setIsDeleteing(true);
|
setIsDeleteing(true);
|
||||||
|
|
||||||
// RULES: delete<CollectionName>
|
// RULES: delete<CollectionName>
|
||||||
deleteTeacher(idToDelete)
|
deleteUserMeta(idToDelete)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
reloadRows();
|
reloadRows();
|
||||||
handleClose();
|
handleClose();
|
||||||
@@ -83,12 +83,12 @@ export default function ConfirmDeleteModal({
|
|||||||
</Avatar>
|
</Avatar>
|
||||||
<Stack spacing={3}>
|
<Stack spacing={3}>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<Typography variant="h5">{t('Delete Teacher ?')}</Typography>
|
<Typography variant="h5">{t('Delete This User ?')}</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
color="text.secondary"
|
color="text.secondary"
|
||||||
variant="body2"
|
variant="body2"
|
||||||
>
|
>
|
||||||
{t('Are you sure you want to delete this teacher ?')}
|
{t('Are you sure you want to delete this user ?')}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
@@ -4,7 +4,7 @@
|
|||||||
export type SortDir = 'asc' | 'desc';
|
export type SortDir = 'asc' | 'desc';
|
||||||
|
|
||||||
// RULES: core teacher data structure
|
// RULES: core teacher data structure
|
||||||
export interface Teacher {
|
export interface UserMeta {
|
||||||
name: string;
|
name: string;
|
||||||
//
|
//
|
||||||
// NOTE: obslete "avatar" and use "avatar_file"
|
// NOTE: obslete "avatar" and use "avatar_file"
|
||||||
@@ -72,10 +72,10 @@ export interface EditFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RULES: filter props for teacher search and filtering
|
// RULES: filter props for teacher search and filtering
|
||||||
export interface TeachersFiltersProps {
|
export interface UserMetasFiltersProps {
|
||||||
filters?: Filters;
|
filters?: Filters;
|
||||||
sortDir?: SortDir;
|
sortDir?: SortDir;
|
||||||
fullData: Teacher[];
|
fullData: UserMeta[];
|
||||||
}
|
}
|
||||||
export interface Filters {
|
export interface Filters {
|
||||||
email?: string;
|
email?: string;
|
@@ -85,7 +85,7 @@ const defaultValues = {
|
|||||||
avatar: '',
|
avatar: '',
|
||||||
} satisfies Values;
|
} satisfies Values;
|
||||||
|
|
||||||
export function TeacherEditForm(): React.JSX.Element {
|
export function UserMetaEditForm(): React.JSX.Element {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation(['lp_categories']);
|
const { t } = useTranslation(['lp_categories']);
|
||||||
|
|
@@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { getAllTeachersCount } from '@/db/Teachers/GetAllCount';
|
import getAllUserMetasCount from '@/db/UserMetas/GetAllCount';
|
||||||
|
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import Chip from '@mui/material/Chip';
|
import Chip from '@mui/material/Chip';
|
||||||
@@ -21,21 +21,21 @@ import { paths } from '@/paths';
|
|||||||
import { FilterButton } from '@/components/core/filter-button';
|
import { FilterButton } from '@/components/core/filter-button';
|
||||||
import { Option } from '@/components/core/option';
|
import { Option } from '@/components/core/option';
|
||||||
|
|
||||||
import { useTeachersSelection } from './teachers-selection-context';
|
import { useUserMetasSelection } from './user-metas-selection-context';
|
||||||
import GetBlockedCount from '@/db/Customers/GetBlockedCount';
|
import GetBlockedCount from '@/db/UserMetas/GetBlockedCount';
|
||||||
import GetPendingCount from '@/db/Customers/GetPendingCount';
|
import GetPendingCount from '@/db/UserMetas/GetPendingCount';
|
||||||
import GetActiveCount from '@/db/Customers/GetActiveCount';
|
import GetActiveCount from '@/db/UserMetas/GetActiveCount';
|
||||||
import PhoneFilterPopover from './phone-filter-popover';
|
import PhoneFilterPopover from './phone-filter-popover';
|
||||||
import EmailFilterPopover from './email-filter-popover';
|
import EmailFilterPopover from './email-filter-popover';
|
||||||
import type { TeachersFiltersProps, Filters, SortDir } from './type.d';
|
import type { UserMetasFiltersProps, Filters, SortDir } from './type.d';
|
||||||
import { logger } from '@/lib/default-logger';
|
import { logger } from '@/lib/default-logger';
|
||||||
|
|
||||||
export function TeachersFilters({
|
export function UserMetasFilters({
|
||||||
filters = {},
|
filters = {},
|
||||||
sortDir = 'desc',
|
sortDir = 'desc',
|
||||||
fullData,
|
fullData,
|
||||||
//
|
//
|
||||||
}: TeachersFiltersProps): React.JSX.Element {
|
}: UserMetasFiltersProps): React.JSX.Element {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { email, phone, status } = filters;
|
const { email, phone, status } = filters;
|
||||||
@@ -47,7 +47,7 @@ export function TeachersFilters({
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const selection = useTeachersSelection();
|
const selection = useUserMetasSelection();
|
||||||
|
|
||||||
// function getVisible(): number {
|
// function getVisible(): number {
|
||||||
// return fullData.reduce((count, item: CrQuestion) => {
|
// return fullData.reduce((count, item: CrQuestion) => {
|
||||||
@@ -89,7 +89,7 @@ export function TeachersFilters({
|
|||||||
searchParams.set('phone', newFilters.phone);
|
searchParams.set('phone', newFilters.phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
router.push(`${paths.dashboard.teachers.list}?${searchParams.toString()}`);
|
router.push(`${paths.dashboard.user_metas.list}?${searchParams.toString()}`);
|
||||||
},
|
},
|
||||||
[router]
|
[router]
|
||||||
);
|
);
|
||||||
@@ -131,7 +131,7 @@ export function TeachersFilters({
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const fetchCount = async (): Promise<void> => {
|
const fetchCount = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const tc = await getAllTeachersCount();
|
const tc = await getAllUserMetasCount();
|
||||||
setTotalCount(tc);
|
setTotalCount(tc);
|
||||||
|
|
||||||
const bc = await GetBlockedCount();
|
const bc = await GetBlockedCount();
|
@@ -7,7 +7,7 @@ function noop(): void {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomersPaginationProps {
|
interface UserMetasPaginationProps {
|
||||||
count: number;
|
count: number;
|
||||||
page: number;
|
page: number;
|
||||||
//
|
//
|
||||||
@@ -16,14 +16,14 @@ interface CustomersPaginationProps {
|
|||||||
rowsPerPage: number;
|
rowsPerPage: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TeachersPagination({
|
export function UserMetasPagination({
|
||||||
count,
|
count,
|
||||||
page,
|
page,
|
||||||
//
|
//
|
||||||
setPage,
|
setPage,
|
||||||
setRowsPerPage,
|
setRowsPerPage,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
}: CustomersPaginationProps): React.JSX.Element {
|
}: UserMetasPaginationProps): React.JSX.Element {
|
||||||
// You should implement the pagination using a similar logic as the filters.
|
// You should implement the pagination using a similar logic as the filters.
|
||||||
// Note that when page change, you should keep the filter search params.
|
// Note that when page change, you should keep the filter search params.
|
||||||
const handleChangePage = (event: unknown, newPage: number) => {
|
const handleChangePage = (event: unknown, newPage: number) => {
|
@@ -0,0 +1,43 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
import { useSelection } from '@/hooks/use-selection';
|
||||||
|
import type { Selection } from '@/hooks/use-selection';
|
||||||
|
|
||||||
|
import type { UserMeta } from './type.d';
|
||||||
|
|
||||||
|
function noop(): void {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserMetasSelectionContextValue extends Selection {}
|
||||||
|
|
||||||
|
export const UserMetasSelectionContext = React.createContext<UserMetasSelectionContextValue>({
|
||||||
|
deselectAll: noop,
|
||||||
|
deselectOne: noop,
|
||||||
|
selectAll: noop,
|
||||||
|
selectOne: noop,
|
||||||
|
selected: new Set(),
|
||||||
|
selectedAny: false,
|
||||||
|
selectedAll: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
interface UserMetasSelectionProviderProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
userMetas: UserMeta[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserMetasSelectionProvider({
|
||||||
|
children,
|
||||||
|
userMetas: teachers = [],
|
||||||
|
}: UserMetasSelectionProviderProps): React.JSX.Element {
|
||||||
|
const customerIds = React.useMemo(() => teachers.map((customer) => customer.id), [teachers]);
|
||||||
|
const selection = useSelection(customerIds);
|
||||||
|
|
||||||
|
return <UserMetasSelectionContext.Provider value={{ ...selection }}>{children}</UserMetasSelectionContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUserMetasSelection(): UserMetasSelectionContextValue {
|
||||||
|
return React.useContext(UserMetasSelectionContext);
|
||||||
|
}
|
@@ -18,19 +18,16 @@ import { Images as ImagesIcon } from '@phosphor-icons/react/dist/ssr/Images';
|
|||||||
import { Minus as MinusIcon } from '@phosphor-icons/react/dist/ssr/Minus';
|
import { Minus as MinusIcon } from '@phosphor-icons/react/dist/ssr/Minus';
|
||||||
import { PencilSimple as PencilSimpleIcon } from '@phosphor-icons/react/dist/ssr/PencilSimple';
|
import { PencilSimple as PencilSimpleIcon } from '@phosphor-icons/react/dist/ssr/PencilSimple';
|
||||||
import { TrashSimple as TrashSimpleIcon } from '@phosphor-icons/react/dist/ssr/TrashSimple';
|
import { TrashSimple as TrashSimpleIcon } from '@phosphor-icons/react/dist/ssr/TrashSimple';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { toast } from 'sonner';
|
|
||||||
|
|
||||||
import { paths } from '@/paths';
|
import { paths } from '@/paths';
|
||||||
import { dayjs } from '@/lib/dayjs';
|
import { dayjs } from '@/lib/dayjs';
|
||||||
import { DataTable } from '@/components/core/data-table';
|
import { DataTable } from '@/components/core/data-table';
|
||||||
import type { ColumnDef } from '@/components/core/data-table';
|
import type { ColumnDef } from '@/components/core/data-table';
|
||||||
|
|
||||||
import ConfirmDeleteModal from './confirm-delete-modal';
|
import ConfirmDeleteModal from './confirm-delete-modal';
|
||||||
import { useTeachersSelection } from './teachers-selection-context';
|
import { useUserMetasSelection } from './user-metas-selection-context';
|
||||||
import type { Teacher } from './type.d';
|
import type { UserMeta } from './type.d';
|
||||||
|
|
||||||
function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Teacher>[] {
|
function columns(handleDeleteClick: (userMetaId: string) => void): ColumnDef<UserMeta>[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
formatter: (row): React.JSX.Element => (
|
formatter: (row): React.JSX.Element => (
|
||||||
@@ -47,7 +44,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Teacher
|
|||||||
<Link
|
<Link
|
||||||
color="inherit"
|
color="inherit"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.teachers.details(row.id)}
|
href={paths.dashboard.user_metas.view(row.id)}
|
||||||
sx={{ whiteSpace: 'nowrap' }}
|
sx={{ whiteSpace: 'nowrap' }}
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
>
|
>
|
||||||
@@ -144,14 +141,12 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Teacher
|
|||||||
//
|
//
|
||||||
color="secondary"
|
color="secondary"
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.teachers.view(row.id)}
|
href={paths.dashboard.user_metas.view(row.id)}
|
||||||
>
|
>
|
||||||
<PencilSimpleIcon size={24} />
|
<PencilSimpleIcon size={24} />
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
color="error"
|
color="error"
|
||||||
// TODO: originally it is row.isEmpty
|
|
||||||
disabled={false}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDeleteClick(row.id);
|
handleDeleteClick(row.id);
|
||||||
}}
|
}}
|
||||||
@@ -167,14 +162,13 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Teacher
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TeachersTableProps {
|
export interface UserMetasTableProps {
|
||||||
rows: Teacher[];
|
rows: UserMeta[];
|
||||||
reloadRows: () => void;
|
reloadRows: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TeachersTable({ rows, reloadRows }: TeachersTableProps): React.JSX.Element {
|
export function UserMetasTable({ rows, reloadRows }: UserMetasTableProps): React.JSX.Element {
|
||||||
const { t } = useTranslation(['teachers']);
|
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useUserMetasSelection();
|
||||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useTeachersSelection();
|
|
||||||
|
|
||||||
const [idToDelete, setIdToDelete] = React.useState('');
|
const [idToDelete, setIdToDelete] = React.useState('');
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
@@ -192,7 +186,7 @@ export function TeachersTable({ rows, reloadRows }: TeachersTableProps): React.J
|
|||||||
reloadRows={reloadRows}
|
reloadRows={reloadRows}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
/>
|
/>
|
||||||
<DataTable<Teacher>
|
<DataTable<UserMeta>
|
||||||
columns={columns(handleDeleteClick)}
|
columns={columns(handleDeleteClick)}
|
||||||
onDeselectAll={deselectAll}
|
onDeselectAll={deselectAll}
|
||||||
onDeselectOne={(_, row) => {
|
onDeselectOne={(_, row) => {
|
||||||
@@ -213,8 +207,7 @@ export function TeachersTable({ rows, reloadRows }: TeachersTableProps): React.J
|
|||||||
sx={{ textAlign: 'center' }}
|
sx={{ textAlign: 'center' }}
|
||||||
variant="body2"
|
variant="body2"
|
||||||
>
|
>
|
||||||
{/* TODO: update this */}
|
No user metadata found
|
||||||
{t('no-teachers-found')}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
) : null}
|
) : null}
|
@@ -2,10 +2,10 @@
|
|||||||
// RULES:
|
// RULES:
|
||||||
// TBA
|
// TBA
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import type { CreateFormProps } from '@/components/dashboard/customer/type.d';
|
import type { CreateFormProps } from '@/components/dashboard/user_meta/type.d';
|
||||||
import type { RecordModel } from 'pocketbase';
|
import type { RecordModel } from 'pocketbase';
|
||||||
|
|
||||||
export async function createCustomer(data: CreateFormProps): Promise<RecordModel> {
|
export async function createUserMeta(data: CreateFormProps): Promise<RecordModel> {
|
||||||
return pb.collection(COL_CUSTOMERS).create(data);
|
return pb.collection(COL_USER_METAS).create(data);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
|
|
||||||
export async function deleteCustomer(id: string): Promise<boolean> {
|
export async function deleteUserMeta(id: string): Promise<boolean> {
|
||||||
return pb.collection(COL_CUSTOMERS).delete(id);
|
return pb.collection(COL_USER_METAS).delete(id);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
export default async function GetActiveCount(): Promise<number> {
|
export default async function GetActiveCount(): Promise<number> {
|
||||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||||
filter: 'status = "active"',
|
filter: 'status = "active"',
|
||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import { RecordModel } from 'pocketbase';
|
import { RecordModel } from 'pocketbase';
|
||||||
|
|
||||||
export async function getAllCustomers(options = {}): Promise<RecordModel[]> {
|
export async function getAllUserMetas(options = {}): Promise<RecordModel[]> {
|
||||||
return pb.collection(COL_CUSTOMERS).getFullList(options);
|
return pb.collection(COL_USER_METAS).getFullList(options);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
export default async function GetBlockedCount(): Promise<number> {
|
export default async function GetBlockedCount(): Promise<number> {
|
||||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||||
filter: 'status = "blocked"',
|
filter: 'status = "blocked"',
|
||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import { RecordModel } from 'pocketbase';
|
import { RecordModel } from 'pocketbase';
|
||||||
|
|
||||||
export async function getCustomerById(id: string): Promise<RecordModel> {
|
export async function getUserMetaById(id: string): Promise<RecordModel> {
|
||||||
return pb.collection(COL_CUSTOMERS).getOne(id);
|
return pb.collection(COL_USER_METAS).getOne(id);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
export default async function GetPendingCount(): Promise<number> {
|
export default async function GetPendingCount(): Promise<number> {
|
||||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||||
filter: 'status = "pending"',
|
filter: 'status = "pending"',
|
||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { pb } from '@/lib/pb';
|
import { pb } from '@/lib/pb';
|
||||||
import { COL_CUSTOMERS } from '@/constants';
|
import { COL_USER_METAS } from '@/constants';
|
||||||
import type { RecordModel } from 'pocketbase';
|
import type { RecordModel } from 'pocketbase';
|
||||||
import type { EditFormProps } from '@/components/dashboard/customer/type.d';
|
import type { EditFormProps } from '@/components/dashboard/customer/type.d';
|
||||||
|
|
||||||
export async function updateCustomer(id: string, data: Partial<EditFormProps>): Promise<RecordModel> {
|
export async function updateCustomer(id: string, data: Partial<EditFormProps>): Promise<RecordModel> {
|
||||||
return pb.collection(COL_CUSTOMERS).update(id, data);
|
return pb.collection(COL_USER_METAS).update(id, data);
|
||||||
}
|
}
|
||||||
|
11
002_source/cms/src/db/UserMetas/_PROMPT.md
Normal file
11
002_source/cms/src/db/UserMetas/_PROMPT.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
`working directory`: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/UserMetas`
|
||||||
|
|
||||||
|
these files are clone from elsewhere,
|
||||||
|
please help to list `*.tsx.draft` files in `working directory` (e.g. `find`),
|
||||||
|
iterate the files listed in the result.
|
||||||
|
please understand, modify and update the content to handle `UserMeta` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
restrict your modifications in working directory only,
|
||||||
|
I will handle all the modification outside this direcotry
|
||||||
|
|
||||||
|
e.g. if `lessonCategories` exist in file, modify it to `userMetas`
|
@@ -149,13 +149,13 @@ export const paths = {
|
|||||||
// edit: (id: string) => `/dashboard/teachers/edit/${id}`,
|
// edit: (id: string) => `/dashboard/teachers/edit/${id}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
users: {
|
user_metas: {
|
||||||
list: '/dashboard/users/list',
|
list: '/dashboard/user_metas/list',
|
||||||
create: '/dashboard/users/create',
|
create: '/dashboard/user_metas/create',
|
||||||
view: (id: string) => `/dashboard/users/view/${id}`,
|
view: (id: string) => `/dashboard/user_metas/view/${id}`,
|
||||||
// RULES: details is obsoleted, use view instead
|
// RULES: details is obsoleted, use view instead
|
||||||
details: (id: string) => `/dashboard/teachers/view/${id}`,
|
// details: (id: string) => `/dashboard/teachers/view/${id}`,
|
||||||
edit: (id: string) => `/dashboard/users/edit/${id}`,
|
edit: (id: string) => `/dashboard/user_metas/edit/${id}`,
|
||||||
},
|
},
|
||||||
students: {
|
students: {
|
||||||
list: '/dashboard/students/list',
|
list: '/dashboard/students/list',
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
@@ -16,11 +19,23 @@
|
|||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
|
"plugins": [
|
||||||
"plugins": [{ "name": "next" }],
|
{
|
||||||
"paths": { "@/*": ["./src/*"] }
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts"
|
||||||
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
".next",
|
".next",
|
||||||
|
Reference in New Issue
Block a user