update ,
This commit is contained in:
@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import { LpCategory } from '@/components/dashboard/lp_categories/type';
|
import { LpCategory } from '@/components/dashboard/lp_categories/type';
|
||||||
|
|
||||||
function getImageUrlFrRecord(record) {
|
function getImageUrlFrRecord(record: LpCategory): string {
|
||||||
return `http://127.0.0.1:8090/api/files/${record.collectionId}/${record.id}/${record.cat_image}`;
|
return `http://127.0.0.1:8090/api/files/${record.collectionId}/${record.id}/${record.cat_image}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,14 +45,12 @@ export default function Page(): React.JSX.Element {
|
|||||||
router.push(paths.dashboard.lp_categories.edit(showLessonCategory.id));
|
router.push(paths.dashboard.lp_categories.edit(showLessonCategory.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lpModel, setLpModel] = React.useState<RecordModel>(null);
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (catId) {
|
if (catId) {
|
||||||
pb.collection(COL_LISTENINGS_PRACTICE_CATEGORIES)
|
pb.collection(COL_LISTENINGS_PRACTICE_CATEGORIES)
|
||||||
.getOne(catId)
|
.getOne(catId)
|
||||||
.then((model: RecordModel) => {
|
.then((model: RecordModel) => {
|
||||||
setShowLessonCategory({ ...defaultLpCategory, ...model });
|
setShowLessonCategory({ ...defaultLpCategory, ...model });
|
||||||
setLpModel(model);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
@@ -104,7 +102,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
spacing={3}
|
spacing={3}
|
||||||
sx={{ alignItems: 'flex-start' }}
|
sx={{ alignItems: 'flex-start' }}
|
||||||
>
|
>
|
||||||
<TitleCard lpModel={lpModel} />
|
<TitleCard lpModel={showLessonCategory} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Grid
|
<Grid
|
||||||
@@ -117,7 +115,7 @@ export default function Page(): React.JSX.Element {
|
|||||||
>
|
>
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<BasicDetailCard
|
<BasicDetailCard
|
||||||
lpModel={lpModel}
|
lpModel={showLessonCategory}
|
||||||
handleEditClick={handleEditClick}
|
handleEditClick={handleEditClick}
|
||||||
/>
|
/>
|
||||||
<SampleSecurityCard />
|
<SampleSecurityCard />
|
||||||
|
@@ -99,8 +99,6 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
|||||||
width: 'var(--Content-width)',
|
width: 'var(--Content-width)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{JSON.stringify({ currentPage, rowsPerPage })}
|
|
||||||
|
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<Stack
|
<Stack
|
||||||
direction={{ xs: 'column', sm: 'row' }}
|
direction={{ xs: 'column', sm: 'row' }}
|
||||||
|
@@ -13,7 +13,9 @@ export const defaultLpCategory: LpCategory = {
|
|||||||
lesson_id: 'default-lesson-id',
|
lesson_id: 'default-lesson-id',
|
||||||
description: 'default-description',
|
description: 'default-description',
|
||||||
remarks: 'default-remarks',
|
remarks: 'default-remarks',
|
||||||
//
|
slug: '',
|
||||||
|
init_answer: {},
|
||||||
|
// from pocketbase
|
||||||
collectionId: '0000000000',
|
collectionId: '0000000000',
|
||||||
createdAt: dayjs('2099-01-01').toDate(),
|
createdAt: dayjs('2099-01-01').toDate(),
|
||||||
//
|
//
|
||||||
|
@@ -116,7 +116,8 @@ export function LpCategoryEditForm(): React.JSX.Element {
|
|||||||
cat_name: values.cat_name,
|
cat_name: values.cat_name,
|
||||||
cat_image: values.avatar ? [await base64ToFile(values.avatar)] : null,
|
cat_image: values.avatar ? [await base64ToFile(values.avatar)] : null,
|
||||||
pos: values.pos,
|
pos: values.pos,
|
||||||
init_answer: JSON.parse(values.init_answer) || {},
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
|
init_answer: JSON.parse(values.init_answer || '{}'),
|
||||||
|
|
||||||
visible: values.visible,
|
visible: values.visible,
|
||||||
slug: values.slug || 'not-defined',
|
slug: values.slug || 'not-defined',
|
||||||
|
@@ -12,6 +12,8 @@ export interface LpCategory {
|
|||||||
lesson_id: string;
|
lesson_id: string;
|
||||||
description: string;
|
description: string;
|
||||||
remarks: string;
|
remarks: string;
|
||||||
|
slug: string;
|
||||||
|
init_answer: any;
|
||||||
//
|
//
|
||||||
name: string;
|
name: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
|
@@ -30,14 +30,37 @@ function LessonTypeCount(): React.JSX.Element {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <LoadingSummary />;
|
return (
|
||||||
|
<LoadingSummary
|
||||||
|
diff={15}
|
||||||
|
icon={ListChecksIcon}
|
||||||
|
title={t('課程類型')}
|
||||||
|
trend="up"
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <Summary amount={0} diff={0} icon={ListChecksIcon} title={t('Error')} trend="down" />;
|
return (
|
||||||
|
<Summary
|
||||||
|
amount={0}
|
||||||
|
diff={0}
|
||||||
|
icon={ListChecksIcon}
|
||||||
|
title={t('Error')}
|
||||||
|
trend="down"
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Summary amount={amount} diff={15} icon={ListChecksIcon} title={t('課程類型')} trend="up" />;
|
return (
|
||||||
|
<Summary
|
||||||
|
amount={amount}
|
||||||
|
diff={15}
|
||||||
|
icon={ListChecksIcon}
|
||||||
|
title={t('課程類型')}
|
||||||
|
trend="up"
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default React.memo(LessonTypeCount);
|
export default React.memo(LessonTypeCount);
|
||||||
|
@@ -14,6 +14,7 @@ export function fileToBase64(file: Blob): Promise<string> {
|
|||||||
export function base64ToFile(base64String: string, filename?: string): Promise<File> {
|
export function base64ToFile(base64String: string, filename?: string): Promise<File> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const arr = base64String.split(',');
|
const arr = base64String.split(',');
|
||||||
|
// eslint-disable-next-line prefer-named-capture-group
|
||||||
const type = arr[0].match(/:(.*?);/)![1];
|
const type = arr[0].match(/:(.*?);/)![1];
|
||||||
const bstr = atob(arr[1]);
|
const bstr = atob(arr[1]);
|
||||||
let n = bstr.length;
|
let n = bstr.length;
|
||||||
|
@@ -44,7 +44,8 @@
|
|||||||
"temp",
|
"temp",
|
||||||
".next",
|
".next",
|
||||||
"_archive",
|
"_archive",
|
||||||
"_del"
|
"_del",
|
||||||
|
"*.del"
|
||||||
//
|
//
|
||||||
],
|
],
|
||||||
"excludeFiles": [
|
"excludeFiles": [
|
||||||
|
Reference in New Issue
Block a user