From de4e4093c67e1127d9e5b5036e12338a854fef9d Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 13 Oct 2023 23:49:28 +0200 Subject: [PATCH] avatar upload finetuning --- src/Components/Gaming/hooks/useQuests.tsx | 4 +- src/Components/Profile/Settings.tsx | 46 ++++++++++++++++------- src/index.css | 12 ++++++ 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/Components/Gaming/hooks/useQuests.tsx b/src/Components/Gaming/hooks/useQuests.tsx index 43b8a8b2..f267fb90 100644 --- a/src/Components/Gaming/hooks/useQuests.tsx +++ b/src/Components/Gaming/hooks/useQuests.tsx @@ -20,9 +20,7 @@ function useQuestsManager(initialOpen: boolean): { const [open, setOpen] = useState(initialOpen); const setQuestsOpen = useCallback((questOpen: boolean) => { - setOpen(questOpen); - console.log(open); - + setOpen(questOpen); }, []); return { open, setQuestsOpen }; diff --git a/src/Components/Profile/Settings.tsx b/src/Components/Profile/Settings.tsx index 0fd66e7a..dc368e2e 100644 --- a/src/Components/Profile/Settings.tsx +++ b/src/Components/Profile/Settings.tsx @@ -140,19 +140,20 @@ export function Settings() { const onUpdateUser = () => { let changedUser = {} as UserItem; - if (passwordChanged) { - changedUser = { id: id, first_name: name, description: text, email: email, avatar: avatar, password: password }; - } - else { - changedUser = { id: id, first_name: name, description: text, email: email, avatar: avatar }; - } + changedUser = { id: id, first_name: name, description: text, email: email, ...passwordChanged && { password: password }, ...avatar.length > 10 && { avatar: avatar } }; + + toast.promise( updateUser(changedUser), { pending: 'updating Profile ...', success: 'Profile updated', - error: 'Error' + error: { + render({ data }) { + return `${data}` + }, + }, }) .then(() => navigate("/")); } @@ -164,15 +165,32 @@ export function Settings() {
- {!cropping && avatar ? - - : - + :
+ +
+ } setName(v)} containerStyle='tw-grow tw-ml-6 tw-my-auto ' />
diff --git a/src/index.css b/src/index.css index f8c0f1d6..748d8a1a 100644 --- a/src/index.css +++ b/src/index.css @@ -47,4 +47,16 @@ input[type="file"] { display: none; +} + +.custom-file-upload:hover .button{ + opacity: 0.8; +} + +.custom-file-upload .button{ + transition: .5s ease; + opacity: 0; + position: absolute; + transform: translate(8px, 8px); + } \ No newline at end of file