diff --git a/client/src/Components/EditAccount/EditAccount.jsx b/client/src/Components/EditAccount/EditAccount.jsx index 8ca67423..db0ed1d3 100644 --- a/client/src/Components/EditAccount/EditAccount.jsx +++ b/client/src/Components/EditAccount/EditAccount.jsx @@ -8,12 +8,11 @@ import ModalToggler from "../Modals/ModalToggler.jsx"; import RegisterUserForm from "./RegisterUserForm.jsx"; import usePublicUserStore from "../../store/user/public-user.store.js"; import CloudinaryImageService from "../../service/asset/image.service.js"; -import "./EditAccount.css"; const EditAccount = () => { - const publicUserStore = usePublicUserStore() + const publicUserStore = usePublicUserStore(); const userData = JSON.parse(localStorage.getItem("userData")); - const entity = publicUserStore.getEntity() + const entity = publicUserStore.getEntity(); const [editProfile, setEditProfileActive] = useState(false); const [newProfile, setNewProfile] = useState({ userid: entity.userid ? entity.userid : "", @@ -58,199 +57,185 @@ const EditAccount = () => { const handleImageChange = async (e) => { const file = e.target.files[0]; let url; - if (!file) - return + if (!file) return; - const loadingToast = toast.loading('Saving image...'); + const loadingToast = toast.loading("Saving image..."); try { - const response = await CloudinaryImageService.uploadImage(file) - url = response.data.url + const response = await CloudinaryImageService.uploadImage(file); + url = response.data.url; } catch (err) { toast.dismiss(loadingToast); - console.log(err) - return + console.log(err); + return; } if (url) { - const publicUser = publicUserStore.getEntity() - await publicUserStore.updatePublicUser({ ...publicUser, profile_picture: url }) + const publicUser = publicUserStore.getEntity(); + await publicUserStore.updatePublicUser({ + ...publicUser, + profile_picture: url, + }); } toast.dismiss(loadingToast); - toast.success("Profile picture updated successfully", { autoClose: 500 }) + toast.success("Profile picture updated successfully", { autoClose: 500 }); }; - const handleSubmit = async (e) => { e.preventDefault(); const status = await publicUserStore.updatePublicUser(newProfile); if (status) { - toast.success("Account updated successfully", { autoClose: 500 }) + toast.success("Account updated successfully", { autoClose: 500 }); } }; return ( -
+
{entity.role !== "public_user" && ( -
+
)} -
-
+
- -

- User Page -

-
- {/* Avatar Image */} -
setIsHovering(true)} - onMouseLeave={() => setIsHovering(false)} - > - {publicUserStore.getEntity().profile_picture ? ( - <> - Uploaded - - - +

+ User Page +

+
+ {/* Avatar Image */} +
setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)}> + {publicUserStore.getEntity().profile_picture ? ( + <> + Uploaded + + + + ) : ( + <> + + + + )} +
+ {/* Content of the form */} +
+
+

First name:

+ {!editProfile ? ( +

{newProfile.first_name}

) : ( - <> - - - + )}
- {/* Content of the form */} -
-
-
-

First name:

-

Last name:

-

Email:

-

Current Plan:

-
-
- {!editProfile ? ( - <> -

{newProfile.first_name}

-

{newProfile.last_name}

-

{newProfile.email}

-

{entity.role}

- - ) : ( - <> - - - -

{entity.role}

- - )} -
-
+
+

Last name:

+ {!editProfile ? ( +

{newProfile.last_name}

+ ) : ( + + )}
-
-
-
- - - - - - - - - - +
+

Email:

+ {!editProfile ? ( +

{newProfile.email}

+ ) : ( + + )} +
+
+

Current Plan:

+

{entity.role}

- -
+
+
+ + {editProfile && ( + + )} + + + + + + + + +
+
); }; + export default EditAccount; + + diff --git a/client/src/Components/EditAccount/EditAccountCMC.jsx b/client/src/Components/EditAccount/EditAccountCMC.jsx index efcc40e2..7d91ff25 100644 --- a/client/src/Components/EditAccount/EditAccountCMC.jsx +++ b/client/src/Components/EditAccount/EditAccountCMC.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState } from "react"; import axios from "axios"; import { Link } from "react-router-dom"; import { MdKeyboardDoubleArrowLeft } from "react-icons/md"; @@ -85,77 +85,79 @@ const EditAccountCMC = () => { }; return ( -
+
-
-
-
-
-
-

CMC Page

-
-
-
-
-
-

Name:

-

Email:

-

Current Plan:

-
-
- {!editProfile ? ( - <> -

{newProfile.company_name}

-

{newProfile.email}

-

{currentPlan}

- - ) : ( - <> - - -

{currentPlan}

- - )} +
+
+
+
+ +
+

CMC Page

+
+
+
+
+
+

Name:

+

Email:

+

Current Plan:

+
+
+ {!editProfile ? ( + <> +

{newProfile.company_name}

+

{newProfile.email}

+

{currentPlan}

+ + ) : ( + <> + + +

{currentPlan}

+ + )} +
-
-
-
- - +
+
+ + +
-
- + +
@@ -163,3 +165,5 @@ const EditAccountCMC = () => { ); }; export default EditAccountCMC; + +