From 4fbad2828c2e2468767d64b9c8746ae1ffd4c155 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 29 Aug 2025 17:12:45 +0800 Subject: [PATCH] Feat: Allow users to delete their profile pictures #3221 (#9826) ### What problem does this PR solve? Feat: Allow users to delete their profile pictures #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/avatar-upload.tsx | 17 ++++++++++++++++- web/src/locales/zh.ts | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/web/src/components/avatar-upload.tsx b/web/src/components/avatar-upload.tsx index af141b180..0071ba36a 100644 --- a/web/src/components/avatar-upload.tsx +++ b/web/src/components/avatar-upload.tsx @@ -1,5 +1,5 @@ import { transformFile2Base64 } from '@/utils/file-util'; -import { Pencil, Upload } from 'lucide-react'; +import { Pencil, Upload, XIcon } from 'lucide-react'; import { ChangeEventHandler, forwardRef, @@ -9,6 +9,7 @@ import { } from 'react'; import { useTranslation } from 'react-i18next'; import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'; +import { Button } from './ui/button'; import { Input } from './ui/input'; type AvatarUploadProps = { value?: string; onChange?: (value: string) => void }; @@ -31,6 +32,11 @@ export const AvatarUpload = forwardRef( [onChange], ); + const handleRemove = useCallback(() => { + setAvatarBase64Str(''); + onChange?.(''); + }, [onChange]); + useEffect(() => { if (value) { setAvatarBase64Str(value); @@ -59,6 +65,15 @@ export const AvatarUpload = forwardRef( className="absolute right-2 bottom-0 opacity-50 hidden group-hover:block" /> + )}