diff --git a/03_source/frontend/src/components/hook-form/rhf-upload.tsx b/03_source/frontend/src/components/hook-form/rhf-upload.tsx index 9574d37..1a82b0c 100644 --- a/03_source/frontend/src/components/hook-form/rhf-upload.tsx +++ b/03_source/frontend/src/components/hook-form/rhf-upload.tsx @@ -1,7 +1,9 @@ import type { BoxProps } from '@mui/material/Box'; +import Box from '@mui/material/Box'; import { Controller, useFormContext } from 'react-hook-form'; -import { Upload } from '../upload'; +import { Upload, UploadAvatar, UploadBox } from '../upload'; import type { UploadProps } from '../upload'; +import { HelperText } from './help-text'; // ---------------------------------------------------------------------- @@ -12,6 +14,48 @@ export type RHFUploadProps = UploadProps & { }; }; +export function RHFUploadAvatar({ name, slotProps, ...other }: RHFUploadProps) { + const { control, setValue } = useFormContext(); + + return ( + { + const onDrop = (acceptedFiles: File[]) => { + const value = acceptedFiles[0]; + + setValue(name, value, { shouldValidate: true }); + }; + + return ( + + + + + + ); + }} + /> + ); +} + +// ---------------------------------------------------------------------- + +export function RHFUploadBox({ name, ...other }: RHFUploadProps) { + const { control } = useFormContext(); + + return ( + ( + + )} + /> + ); +} + // ---------------------------------------------------------------------- export function RHFUpload({ name, multiple, helperText, ...other }: RHFUploadProps) { @@ -35,8 +79,6 @@ export function RHFUpload({ name, multiple, helperText, ...other }: RHFUploadPro setValue(name, value, { shouldValidate: true }); }; - // return <>{JSON.stringify({ t: field.value })}; - return ; }} /> diff --git a/03_source/frontend/src/components/nav-section/vertical/nav-section-vertical.tsx b/03_source/frontend/src/components/nav-section/vertical/nav-section-vertical.tsx index 2cafd70..d9316bb 100644 --- a/03_source/frontend/src/components/nav-section/vertical/nav-section-vertical.tsx +++ b/03_source/frontend/src/components/nav-section/vertical/nav-section-vertical.tsx @@ -2,11 +2,11 @@ import Collapse from '@mui/material/Collapse'; import { useTheme } from '@mui/material/styles'; import { useBoolean } from 'minimal-shared/hooks'; import { mergeClasses } from 'minimal-shared/utils'; +import { useTranslation } from 'react-i18next'; import { Nav, NavLi, NavSubheader, NavUl } from '../components'; import { navSectionClasses, navSectionCssVars } from '../styles'; import type { NavGroupProps, NavSectionProps } from '../types'; import { NavList } from './nav-list'; -import { useTranslation } from 'react-i18next'; // ---------------------------------------------------------------------- @@ -26,7 +26,11 @@ export function NavSectionVertical({ const cssVars = { ...navSectionCssVars.vertical(theme), ...overridesVars }; return ( -