diff --git a/src/components/profile/file-input.tsx b/src/components/profile/file-input.tsx index 5357224a..2943d829 100644 --- a/src/components/profile/file-input.tsx +++ b/src/components/profile/file-input.tsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"; import { Box, Button, Typography } from "@mui/material"; interface Props { - onChange: (value: string) => void; + onChange: (file: File, value: string) => void; } export const FileInput = (props: Props) => { @@ -28,7 +28,7 @@ export const FileInput = (props: Props) => { const reader = new FileReader(); reader.onload = (event) => { resolve(null); - onChange(event.target?.result as string); + onChange(file, event.target?.result as string); }; reader.onerror = reject; reader.readAsText(file); diff --git a/src/components/profile/profile-viewer.tsx b/src/components/profile/profile-viewer.tsx index ba70096a..14839dd8 100644 --- a/src/components/profile/profile-viewer.tsx +++ b/src/components/profile/profile-viewer.tsx @@ -246,7 +246,15 @@ export const ProfileViewer = forwardRef( )} {isLocal && openType === "new" && ( - (fileDataRef.current = val)} /> + { + if (!formIns.getValues("name")) { + const name = file.name.substring(0, file.name.lastIndexOf(".")); + formIns.setValue("name", name); + } + fileDataRef.current = val; + }} + /> )} {isRemote && (