update to use,
This commit is contained in:
@@ -26,6 +26,7 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import { dayjs } from '@/lib/dayjs';
|
||||
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||
import { DataTable } from '@/components/core/data-table';
|
||||
import type { ColumnDef } from '@/components/core/data-table';
|
||||
|
||||
@@ -43,7 +44,7 @@ function columns(handleDeleteClick: (userMetaId: string) => void): ColumnDef<Use
|
||||
sx={{ alignItems: 'center' }}
|
||||
>
|
||||
<Avatar
|
||||
src={`http://127.0.0.1:8090/api/files/${row.collectionId}/${row.id}/${row.avatar}`}
|
||||
src={getImageUrlFromFile(row.collectionId, row.id, row.avatar)}
|
||||
variant="rounded"
|
||||
/>
|
||||
<div>
|
||||
|
@@ -1,10 +1,9 @@
|
||||
// RULES:
|
||||
// should match the collection `Vocabularies` from `schema.dbml`
|
||||
export interface Vocabulary {
|
||||
id: string;
|
||||
created?: string;
|
||||
updated?: string;
|
||||
image?: string;
|
||||
image: string;
|
||||
sound?: string;
|
||||
word?: string;
|
||||
word_c?: string;
|
||||
@@ -23,6 +22,9 @@ export interface Vocabulary {
|
||||
//
|
||||
};
|
||||
};
|
||||
//
|
||||
id: string;
|
||||
collectionId: string;
|
||||
}
|
||||
|
||||
// RULES: for use with vocabulary-create-form.tsx
|
||||
|
@@ -16,12 +16,13 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import { dayjs } from '@/lib/dayjs';
|
||||
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||
import { DataTable } from '@/components/core/data-table';
|
||||
import type { ColumnDef } from '@/components/core/data-table';
|
||||
|
||||
import ConfirmDeleteModal from './confirm-delete-modal';
|
||||
import { useVocabulariesSelection } from './vocabularies-selection-context';
|
||||
import type { Vocabulary } from './type';
|
||||
import { useVocabulariesSelection } from './vocabularies-selection-context';
|
||||
|
||||
function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Vocabulary>[] {
|
||||
return [
|
||||
@@ -45,7 +46,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<Vocabul
|
||||
sx={{ alignItems: 'center' }}
|
||||
>
|
||||
<Avatar
|
||||
src={`http://127.0.0.1:8090/api/files/${row.collectionId}/${row.id}/${row.cat_image}`}
|
||||
src={getImageUrlFromFile(row.collectionId, row.id, row.image)}
|
||||
variant="rounded"
|
||||
>
|
||||
<ImagesIcon size={32} />
|
||||
|
@@ -4,6 +4,7 @@ import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import { COL_VOCABULARIES } from '@/constants';
|
||||
import { listLessonCategories } from '@/db/LessonCategories/listLessonCategories';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
import { Avatar, Divider } from '@mui/material';
|
||||
@@ -12,7 +13,6 @@ import Button from '@mui/material/Button';
|
||||
import Card from '@mui/material/Card';
|
||||
import CardActions from '@mui/material/CardActions';
|
||||
import CardContent from '@mui/material/CardContent';
|
||||
|
||||
import FormControl from '@mui/material/FormControl';
|
||||
import FormHelperText from '@mui/material/FormHelperText';
|
||||
import InputLabel from '@mui/material/InputLabel';
|
||||
@@ -27,8 +27,10 @@ import { useTranslation } from 'react-i18next';
|
||||
import { z as zod } from 'zod';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
import { logger } from '@/lib/default-logger';
|
||||
import { base64ToFile, fileToBase64 } from '@/lib/file-to-base64';
|
||||
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||
import { pb } from '@/lib/pb';
|
||||
import { Option } from '@/components/core/option';
|
||||
import { toast } from '@/components/core/toaster';
|
||||
@@ -36,8 +38,6 @@ import FormLoading from '@/components/loading';
|
||||
|
||||
import ErrorDisplay from '../error';
|
||||
import type { EditFormProps } from './type';
|
||||
import { listLessonCategories } from '@/db/LessonCategories/listLessonCategories';
|
||||
import isDevelopment from '@/lib/check-is-development';
|
||||
|
||||
const schema = zod.object({
|
||||
image: zod.union([zod.array(zod.any()), zod.string()]).optional(),
|
||||
@@ -144,9 +144,7 @@ export function VocabularyEditForm(): React.JSX.Element {
|
||||
reset({ ...defaultValues, ...result });
|
||||
|
||||
if (result.image !== '') {
|
||||
const fetchResult = await fetch(
|
||||
`http://127.0.0.1:8090/api/files/${result.collectionId}/${result.id}/${result.image}`
|
||||
);
|
||||
const fetchResult = await fetch(getImageUrlFromFile(result.collectionId, result.id, result.image));
|
||||
|
||||
const blob = await fetchResult.blob();
|
||||
const url = await fileToBase64(blob);
|
||||
|
Reference in New Issue
Block a user