From 0267a2f91f65eaa77be59c8698f864a511f665db Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 3 Jan 2024 18:26:46 +0100 Subject: [PATCH] split Settings in UserSettings and ProfileSettings --- src/Components/AppShell/NavBar.tsx | 5 +- .../{Settings.tsx => ProfileSettings.tsx} | 23 +---- src/Components/Profile/UserSettings.tsx | 88 +++++++++++++++++++ src/Components/Profile/index.tsx | 3 +- src/index.tsx | 2 +- src/types.ts | 17 ++-- 6 files changed, 109 insertions(+), 29 deletions(-) rename src/Components/Profile/{Settings.tsx => ProfileSettings.tsx} (87%) create mode 100644 src/Components/Profile/UserSettings.tsx diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index 2e2afbdf..36699ebb 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -90,7 +90,7 @@ export default function NavBar({ appName, nameWidth = 200}: { appName: string, n return ( <> -
+
-
+

{appName}

@@ -123,6 +123,7 @@ export default function NavBar({ appName, nameWidth = 200}: { appName: string, n diff --git a/src/Components/Profile/Settings.tsx b/src/Components/Profile/ProfileSettings.tsx similarity index 87% rename from src/Components/Profile/Settings.tsx rename to src/Components/Profile/ProfileSettings.tsx index 02960d12..5ac14884 100644 --- a/src/Components/Profile/Settings.tsx +++ b/src/Components/Profile/ProfileSettings.tsx @@ -14,20 +14,16 @@ import DialogModal from '../Templates/DialogModal'; import { useAssetApi } from '../AppShell/hooks/useAssets'; import { ColorPicker } from './ColorPicker'; -export function Settings() { +export function ProfileSettings() { const { user, updateUser, loading, token } = useAuth(); const [id, setId] = useState(""); const [name, setName] = useState(""); const [text, setText] = useState(""); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); const [avatar, setAvatar] = useState(""); const [color, setColor] = useState(""); - const [passwordChanged, setPasswordChanged] = useState(false); - const [crop, setCrop] = useState(); const [image, setImage] = useState(""); const [cropModalOpen, setCropModalOpen] = useState(false); @@ -40,8 +36,6 @@ export function Settings() { setId(user?.id ? user.id : ""); setName(user?.first_name ? user.first_name : ""); setText(user?.description ? user.description : ""); - setEmail(user?.email ? user.email : ""); - setPassword(user?.password ? user.password : ""); setAvatar(user?.avatar ? user?.avatar : ""), setColor(user?.color? user.color : "#aabbcc") }, [user]) @@ -144,7 +138,7 @@ export function Settings() { const onUpdateUser = () => { let changedUser = {} as UserItem; - changedUser = { id: id, first_name: name, description: text, email: email, color: color, ...passwordChanged && { password: password }, ...avatar.length > 10 && { avatar: avatar } }; + changedUser = { id: id, first_name: name, description: text, color: color, ...avatar.length > 10 && { avatar: avatar } }; toast.promise( @@ -167,7 +161,7 @@ export function Settings() { <>
- +
{!cropping ?