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