Skip to content

Commit

Permalink
fix: seperate out edit profile
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalCodes committed Dec 16, 2024
1 parent 7675bb4 commit a80202d
Show file tree
Hide file tree
Showing 6 changed files with 868 additions and 124 deletions.
166 changes: 50 additions & 116 deletions src/components/shared/profileCompletion/ProfileCompletion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { completeProfileApiCall } from "@service/MilanApi";
import { showSuccessToast } from "@utils/Toasts";
import clsx from "clsx";
import { useState } from "react";
import { RxCross2 } from "react-icons/rx";
import { Button } from "..";
import "./ProfileCompletion.scss";

const ProfileCompletion = ({ edit, setShowEditModal, refreshProfileData }) => {
const { errors, validateForm, handleChange, credentials } =
const ProfileCompletion = ({ setShowEditModal, refreshProfileData }) => {
const { errors, validateForm, handleChange, credentials, handleResetFields } =
useProfileCompletion();

const [uploadedImage, setUploadedImage] = useState(null);
Expand All @@ -31,62 +30,41 @@ const ProfileCompletion = ({ edit, setShowEditModal, refreshProfileData }) => {
<div className="profilecompletion_overlay">
<div className="profilecompletion_modal">
<div className="profilecompletion_header">
{edit === false ? (
<div className="profilecompletion_header_top">
<div>
<h1> We&apos;re almost done </h1>
<p>
To make your Organization visible to others, please complete
your profile.
</p>
</div>
<div className="profilecompletion_header_top">
<div>
<h1> We&apos;re almost done </h1>
<p>
To make your Organization visible to others, please complete
your profile.
</p>
</div>

<Button
type="submit"
disabled={
!credentials?.description ||
!credentials?.address?.line1 ||
!credentials?.address?.line2 ||
!credentials?.address?.city ||
!credentials?.address?.state ||
!credentials?.address?.country ||
!credentials?.address?.pincode
}
onClickfunction={async () => {
const data = await completeProfileApiCall({
credentials,
});
<Button
type="submit"
disabled={
!credentials?.description ||
!credentials?.address?.line1 ||
!credentials?.address?.line2 ||
!credentials?.address?.city ||
!credentials?.address?.state ||
!credentials?.address?.country ||
!credentials?.address?.pincode
}
onClickfunction={async () => {
const data = await completeProfileApiCall({
credentials,
});

if (data?.status === 200) {
showSuccessToast(data?.data?.message);
setShowEditModal(false);
refreshProfileData();
}
}}
>
Save
</Button>
</div>
) : (
<div className="profilecompletion_header_edit">
<RxCross2 />
<h1> Edit profile </h1>
<Button
type="submit"
disabled={
!credentials?.description ||
!credentials?.address?.line1 ||
!credentials?.address?.line2 ||
!credentials?.address?.city ||
!credentials?.address?.state ||
!credentials?.address?.country ||
!credentials?.address?.pincode
if (data?.status === 200) {
showSuccessToast(data?.data?.message);
setShowEditModal(false);
refreshProfileData();
}
>
Save
</Button>
</div>
)}
}}
>
Save
</Button>
</div>
</div>

<form
Expand Down Expand Up @@ -141,48 +119,6 @@ const ProfileCompletion = ({ edit, setShowEditModal, refreshProfileData }) => {
className="hidden"
onChange={(e) => handleFileChange(e, "cover")}
/>

{edit === true && (
<>
<label
htmlFor="dropzone_pfp"
className="dropzone_label profile_picture_label"
>
{uploadedProfilePicture ? (
<img
src={uploadedProfilePicture}
alt="Uploaded Preview"
className="uploaded-image profile_picture"
/>
) : (
<div className="dropzone_content">
<svg
className="dropzone_icon"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 20 16"
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"
/>
</svg>
</div>
)}
</label>

<input
id="dropzone_pfp"
type="file"
className="hidden"
onChange={(e) => handleFileChange(e, "pfp")}
/>
</>
)}
</div>
</div>
<div
Expand Down Expand Up @@ -306,24 +242,22 @@ const ProfileCompletion = ({ edit, setShowEditModal, refreshProfileData }) => {
</div>
</div>

{edit === "false" && (
<div className="profilecompletion_btndiv">
<Button
type="submit"
disabled={
!credentials?.description ||
!credentials?.address?.line1 ||
!credentials?.address?.line2 ||
!credentials?.address?.city ||
!credentials?.address?.state ||
!credentials?.address?.country ||
!credentials?.address?.pincode
}
>
Submit
</Button>
</div>
)}
<div className="profilecompletion_btndiv">
<Button
type="submit"
disabled={
!credentials?.description ||
!credentials?.address?.line1 ||
!credentials?.address?.line2 ||
!credentials?.address?.city ||
!credentials?.address?.state ||
!credentials?.address?.country ||
!credentials?.address?.pincode
}
>
Submit
</Button>
</div>
</form>
</div>
</div>
Expand Down
Loading

0 comments on commit a80202d

Please sign in to comment.