From dcdef77387cf77ffeb644a79b8e87952cc0ebf58 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 8 Jun 2023 17:09:22 +0330 Subject: [PATCH] better profile photo update logic --- components/Modal/UserSettings.tsx | 41 ++++++++++--------------- components/ProfilePhoto.tsx | 6 ++-- lib/api/controllers/users/updateUser.ts | 19 ++++++------ lib/client/avatarExists.ts | 4 --- store/account.ts | 14 ++------- 5 files changed, 31 insertions(+), 53 deletions(-) delete mode 100644 lib/client/avatarExists.ts diff --git a/components/Modal/UserSettings.tsx b/components/Modal/UserSettings.tsx index bd0f1b8..b03a1cd 100644 --- a/components/Modal/UserSettings.tsx +++ b/components/Modal/UserSettings.tsx @@ -10,6 +10,7 @@ import Modal from "."; import ChangePassword from "./ChangePassword"; import { faPenToSquare } from "@fortawesome/free-regular-svg-icons"; import SubmitButton from "../SubmitButton"; +import ProfilePhoto from "../ProfilePhoto"; type Props = { toggleSettingsModal: Function; @@ -141,37 +142,29 @@ export default function UserSettings({ toggleSettingsModal }: Props) { Profile Photo

- {user.profilePic && user.profilePic !== "DELETE" ? ( -
- Profile Photo -
- setUser({ - ...user, - profilePic: "DELETE", - }) - } - className="absolute top-1 left-1 w-5 h-5 flex items-center justify-center border p-1 bg-white border-sky-100 rounded-full text-gray-500 hover:text-red-500 duration-100 cursor-pointer" - > - -
+ + {user.profilePic && ( +
+ setUser({ + ...user, + profilePic: "", + }) + } + className="absolute top-1 left-1 w-5 h-5 flex items-center justify-center border p-1 bg-white border-slate-200 rounded-full text-gray-500 hover:text-red-500 duration-100 cursor-pointer" + > +
- ) : ( - )}