From 2c65742538615c9c5ff71d18567b22ba3d2d62f9 Mon Sep 17 00:00:00 2001 From: tamalCodes Date: Sat, 19 Oct 2024 22:32:07 +0530 Subject: [PATCH 1/3] fix: signup for clubs flow --- package-lock.json | 4 +- package.json | 1 + .../profileCompletion/ProfileCompletion.jsx | 158 +++++------------- src/pages/dashboard/Dashboard.jsx | 35 ++-- src/redux/slice/userSlice.js | 2 +- src/static/Constants.js | 4 + src/utils/getProfileFields.js | 51 ++---- 7 files changed, 74 insertions(+), 181 deletions(-) diff --git a/package-lock.json b/package-lock.json index d628bd92..68cfbbb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "dotenv": "^16.3.1", "framer-motion": "^11.0.3", "js-cookie": "^3.0.5", + "lodash": "^4.17.21", "react": "^18.2.0", "react-calendar": "^4.8.0", "react-dom": "^18.2.0", @@ -13776,7 +13777,8 @@ }, "node_modules/lodash": { "version": "4.17.21", - "license": "MIT" + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.camelcase": { "version": "4.3.0", diff --git a/package.json b/package.json index 36e922cb..94304f07 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "dotenv": "^16.3.1", "framer-motion": "^11.0.3", "js-cookie": "^3.0.5", + "lodash": "^4.17.21", "react": "^18.2.0", "react-calendar": "^4.8.0", "react-dom": "^18.2.0", diff --git a/src/components/shared/profileCompletion/ProfileCompletion.jsx b/src/components/shared/profileCompletion/ProfileCompletion.jsx index 79274ca7..1b37f0aa 100644 --- a/src/components/shared/profileCompletion/ProfileCompletion.jsx +++ b/src/components/shared/profileCompletion/ProfileCompletion.jsx @@ -1,142 +1,60 @@ /* eslint-disable no-unused-vars */ -import { useEffect, useState } from "react"; +import { useState } from "react"; import { useSelector } from "react-redux"; import getProfileFields from "../../../utils/getProfileFields"; -import Button from "../buttons/globalbutton/Button"; import "./ProfileCompletion.scss"; -const ProfileCompletion = ({ editProfile }) => { - const [part, setPart] = useState(editProfile ? 2 : 1); - const [currentStep, setcurrentStep] = useState(2); - const [currentIndex, setcurrentIndex] = useState(0); - const [formData, setFormData] = useState({}); - const [errors, setErrors] = useState({}); +const ProfileCompletion = () => { + const [credentials, setCredentials] = useState({}); const user = useSelector((state) => state.user); - useEffect(() => { - if (editProfile) { - setFormData(user); - } - }, [editProfile]); - - const fields = getProfileFields(user, editProfile); - - const totalfields = fields.length; - - const handleIncrementStep = () => { - if (currentStep + 2 <= totalfields) { - setcurrentIndex(currentIndex + 2); - setcurrentStep(currentStep + 2); - } - }; - - const handleDecrementStep = () => { - if (currentStep - 2 >= 2) { - setcurrentIndex(currentIndex - 2); - setcurrentStep(currentStep - 2); - } - }; + const fields = getProfileFields(user); const handleChange = (e) => { - setFormData({ ...formData, [e.target.name]: e.target.value }); - setErrors({ ...errors, [e.target.name]: undefined }); - }; - - const handleSubmit = async (e) => { - e.preventDefault(); - - // formData is an object - // lenght of an object - - // const response = await UpdateUser(formData); - // if (response?.status !== 200) { - // showErrorToast(response?.data?.message); - // } else { - // dispatch(updateUserData(formData)); - // setFormData({}); - // setShowProfileModal(false); - // seteditProfile(false); - // showSuccessToast(response?.data?.message); - // mutate(clubEndpoints.details(user?.userName)); - // } + setCredentials({ + ...credentials, + [e.target.name]: e.target.value, + }); }; return (
- {part === 1 ? ( -

Choose Account Type

- ) : ( -

{editProfile ? "Edit Profile" : `We're almost done`}

- )} +

We're almost done

- {part === 1 ? ( -

Your Account Type is permanent and cannot be changed later.

- ) : !editProfile ? ( -

- Please complete your profile to enjoy the full benefits of the - platform. -

- ) : null} +

+ Please complete your profile to enjoy the full benefits of the + platform. +

- {/*
- {fields.slice(currentIndex, currentIndex + 2).map((elId) => { - const formElement = ProfileElements.find( - (element) => element.id === elId, - ); - - return ( -
- - {formElement?.id === "description" ? ( -