This commit is contained in:
louiscklaw
2025-05-30 01:14:10 +08:00
parent 98bc3fe3ce
commit 834f58bde1
52 changed files with 624 additions and 604 deletions

View File

@@ -11,18 +11,12 @@ import { uploadClasses } from './classes';
import { RejectionFiles } from './components/rejection-files';
import type { UploadProps } from './types';
import { useTranslation } from 'react-i18next';
// ----------------------------------------------------------------------
export function UploadAvatar({
sx,
error,
value,
disabled,
helperText,
className,
...other
}: UploadProps) {
export function UploadAvatar({ sx, error, value, disabled, helperText, className, ...other }: UploadProps) {
const { t } = useTranslation();
const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections } = useDropzone({
multiple: false,
disabled,
@@ -44,10 +38,7 @@ export function UploadAvatar({
}
}, [value]);
const renderPreview = () =>
hasFile && (
<Image alt="Avatar" src={preview} sx={{ width: 1, height: 1, borderRadius: '50%' }} />
);
const renderPreview = () => hasFile && <Image alt="Avatar" src={preview} sx={{ width: 1, height: 1, borderRadius: '50%' }} />;
const renderPlaceholder = () => (
<Box
@@ -85,7 +76,7 @@ export function UploadAvatar({
>
<Iconify icon="solar:camera-add-bold" width={32} />
<Typography variant="caption">{hasFile ? 'Update photo' : 'Upload photo'}</Typography>
<Typography variant="caption">{hasFile ? t('Update photo') : t('Update photo')}</Typography>
</Box>
);