import { useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { Upload, X, Loader2 } from "lucide-react"; import { cn } from "@/lib/utils"; import { postFile, buildFileUrl } from "@/features/shared/api/sharedApi"; // ─── Types ──────────────────────────────────────────────────────────────────── interface AvatarUploadProps { label?: string; value?: string; onChange?: (url: string) => void; error?: string; required?: boolean; disabled?: boolean; } // ─── FieldLabel ─────────────────────────────────────────────────────────────── function FieldLabel({ label, required }: { label?: string; required?: boolean }) { if (!label) return null; return ( ); } // ─── ErrorMsg ───────────────────────────────────────────────────────────────── function ErrorMsg({ error }: { error?: string }) { if (!error) return null; return (
{error}
); } // ─── AvatarUpload ───────────────────────────────────────────────────────────── export function AvatarUpload({ label, value, onChange, error, required, disabled }: AvatarUploadProps) { const { t } = useTranslation(); const inputRef = useRef