update build ok,
This commit is contained in:
@@ -26,6 +26,7 @@ import { PencilSimple as PencilSimpleIcon } from '@phosphor-icons/react/dist/ssr
|
||||
import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus';
|
||||
import { ShieldWarning as ShieldWarningIcon } from '@phosphor-icons/react/dist/ssr/ShieldWarning';
|
||||
import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { config } from '@/config';
|
||||
import { paths } from '@/paths';
|
||||
@@ -40,6 +41,8 @@ import { ShippingAddress } from '@/components/dashboard/lesson_category/shipping
|
||||
// export const metadata = { title: `Details | Customers | Dashboard | ${config.site.name}` } satisfies Metadata;
|
||||
|
||||
export default function Page(): React.JSX.Element {
|
||||
let { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -60,7 +63,7 @@ export default function Page(): React.JSX.Element {
|
||||
variant="subtitle2"
|
||||
>
|
||||
<ArrowLeftIcon fontSize="var(--icon-fontSize-md)" />
|
||||
Lesson Categories
|
||||
{t('dashboard.lessonCategorys.list.title')}
|
||||
</Link>
|
||||
</div>
|
||||
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={3} sx={{ alignItems: 'flex-start' }}>
|
||||
|
@@ -17,11 +17,7 @@ import { paths } from '@/paths';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { pb } from '@/lib/pb';
|
||||
import { toast } from '@/components/core/toaster';
|
||||
import {
|
||||
DBLessonCategory,
|
||||
defaultLessonCategory,
|
||||
type LessonCategory,
|
||||
} from '@/components/dashboard/lesson_category/interfaces';
|
||||
import { defaultLessonCategory, type LessonCategory } from '@/components/dashboard/lesson_category/interfaces';
|
||||
import { LessonCategoriesFilters } from '@/components/dashboard/lesson_category/lesson-categories-filters';
|
||||
import type { Filters } from '@/components/dashboard/lesson_category/lesson-categories-filters';
|
||||
import { LessonCategoriesPagination } from '@/components/dashboard/lesson_category/lesson-categories-pagination';
|
||||
@@ -52,18 +48,21 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
const [recordCount, setRecordCount] = React.useState<number>(0);
|
||||
const [rowsPerPage, setRowsPerPage] = React.useState<number>(5);
|
||||
const [currentPage, setCurrentPage] = React.useState<number>(1);
|
||||
const sortedLessonCategories = applySort(lessonCategoriesSampleData, sortDir);
|
||||
const filteredLessonCategories = applyFilters(sortedLessonCategories, { email, phone, status: spStatus });
|
||||
|
||||
//
|
||||
const [isLoadingAddPage, setIsLoadingAddPage] = React.useState<boolean>(false);
|
||||
const [lessonCategoriesData, setLessonCategoriesData] = React.useState<LessonCategory[]>([]);
|
||||
|
||||
const sortedLessonCategories = applySort(lessonCategoriesData, sortDir);
|
||||
const filteredLessonCategories = applyFilters(sortedLessonCategories, { email, phone, status: spStatus });
|
||||
|
||||
const reloadRows = () => {
|
||||
pb.collection(COL_LESSON_CATEGORIES)
|
||||
.getList(currentPage, rowsPerPage, {})
|
||||
.then((lessonCategories: ListResult<RecordModel>) => {
|
||||
// console.log(lessonTypes);
|
||||
const { items, page, perPage, totalItems, totalPages } = lessonCategories;
|
||||
const tempLessonCategories: DBLessonCategory[] = items.map((item) => {
|
||||
const tempLessonCategories: LessonCategory[] = items.map((item) => {
|
||||
return { ...defaultLessonCategory, ...item };
|
||||
});
|
||||
|
||||
@@ -82,6 +81,8 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
|
||||
if (lessonCategoriesData.length < 1) return <FormLoading />;
|
||||
|
||||
// return <pre>{JSON.stringify(lessonCategoriesData, null, 2)}</pre>;
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -94,7 +95,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
<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('Lesson Categories')}</Typography>
|
||||
<Typography variant="h4">{t('dashboard.lessonCategorys.list.title')}</Typography>
|
||||
</Box>
|
||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||
<LoadingButton
|
||||
@@ -115,7 +116,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
<LessonCategoriesFilters filters={{ email, phone, status: spStatus }} sortDir={sortDir} />
|
||||
<Divider />
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
<LessonCategoriesTable rows={filteredLessonCategories} />
|
||||
<LessonCategoriesTable reloadRows={reloadRows} rows={filteredLessonCategories} />
|
||||
</Box>
|
||||
<Divider />
|
||||
<LessonCategoriesPagination count={filteredLessonCategories.length + 100} page={0} />
|
||||
@@ -140,17 +141,17 @@ function applySort(row: LessonCategory[], sortDir: 'asc' | 'desc' | undefined):
|
||||
|
||||
function applyFilters(row: LessonCategory[], { email, phone, status }: Filters): LessonCategory[] {
|
||||
return row.filter((item) => {
|
||||
if (email) {
|
||||
if (!item.email?.toLowerCase().includes(email.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (email) {
|
||||
// if (!item.email?.toLowerCase().includes(email.toLowerCase())) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (phone) {
|
||||
if (!item.phone?.toLowerCase().includes(phone.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (phone) {
|
||||
// if (!item.phone?.toLowerCase().includes(phone.toLowerCase())) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (status) {
|
||||
if (item.status !== status) {
|
||||
|
Reference in New Issue
Block a user