diff --git a/package.json b/package.json index e8b605f5..e10e20f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utopia-ui", - "version": "2.0.3", + "version": "2.0.4", "description": "Reuseable React Components to build mapping apps for all kinds of communities ", "repository": "https://github.com/utopia-os/utopia-ui", "homepage:": "https://utopia.os/", diff --git a/src/Components/Auth/authDirectus.tsx b/src/Components/Auth/authDirectus.tsx index b86e7926..d9ad079b 100644 --- a/src/Components/Auth/authDirectus.tsx +++ b/src/Components/Auth/authDirectus.tsx @@ -21,7 +21,7 @@ export type MyUserItem = { first_name: string; description: string; email: string; - password: string; + password?: string; } type AuthContextProps = { diff --git a/src/Components/Profile/Settings.tsx b/src/Components/Profile/Settings.tsx index 7b82b687..4172b6bd 100644 --- a/src/Components/Profile/Settings.tsx +++ b/src/Components/Profile/Settings.tsx @@ -18,6 +18,10 @@ export function Settings({useAuth}) { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); + const [passwordChanged, setPasswordChanged] = useState(false); + + + useEffect(() => { setId(user?.id ? user.id : ""); @@ -25,16 +29,23 @@ export function Settings({useAuth}) { setText(user?.description ? user.description : ""); setEmail(user?.email ? user.email : ""); setPassword(user?.password ? user.password : ""); - - }, [user]) const navigate = useNavigate(); const onUpdateUser = () => { + let changedUser = {}; + + if(passwordChanged) { + changedUser = { id: id, first_name: name, description: text, email: email, password: password }; + } + else { + changedUser = { id: id, first_name: name, description: text, email: email }; + } toast.promise( - updateUser({ id: id, first_name: name, description: text, email: email, password: password }), + + updateUser(changedUser), { pending: 'updating Profile ...', success: 'Profile updated', @@ -65,7 +76,10 @@ export function Settings({useAuth}) {
setEmail(v)} /> - setPassword(v)} /> + { + setPassword(v); + setPasswordChanged(true); + }} /> {/* */}