diff --git a/.env.sample b/.env.sample index c4f419fc4..89a12e8c7 100644 --- a/.env.sample +++ b/.env.sample @@ -1,4 +1,5 @@ VITE_BACKEND_URL= VITE_FRONTEND_URL= VITE_DISCORD_INVITE_URL= -VITE_RAZORPAY_KEY_ID= \ No newline at end of file +VITE_RAZORPAY_KEY_ID= +VITE_DISCORD_AUTH_URL= \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 28bf96b06..0d96f7edc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "react-select": "^5.7.7", "react-spinners": "^0.13.8", "react-tabs": "^6.0.1", + "react-tag-input-component": "^2.0.2", "react-tooltip": "^5.18.1", "recharts": "^2.10.2", "sass": "^1.62.1", @@ -8963,6 +8964,15 @@ "react": "^18.0.0" } }, + "node_modules/react-tag-input-component": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/react-tag-input-component/-/react-tag-input-component-2.0.2.tgz", + "integrity": "sha512-dydI9luVwwv9vrjE5u1TTnkcOVkOVL6mhFti8r6hLi78V2F2EKWQOLptURz79UYbDHLSk6tnbvGl8FE+sMpADg==", + "peerDependencies": { + "react": "^16 || ^17 || ^18", + "react-dom": "^16 || ^17 || ^18" + } + }, "node_modules/react-tooltip": { "version": "5.18.1", "resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-5.18.1.tgz", @@ -17043,6 +17053,12 @@ "prop-types": "^15.5.0" } }, + "react-tag-input-component": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/react-tag-input-component/-/react-tag-input-component-2.0.2.tgz", + "integrity": "sha512-dydI9luVwwv9vrjE5u1TTnkcOVkOVL6mhFti8r6hLi78V2F2EKWQOLptURz79UYbDHLSk6tnbvGl8FE+sMpADg==", + "requires": {} + }, "react-tooltip": { "version": "5.18.1", "resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-5.18.1.tgz", diff --git a/package.json b/package.json index 227d05c07..431787dde 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "react-select": "^5.7.7", "react-spinners": "^0.13.8", "react-tabs": "^6.0.1", + "react-tag-input-component": "^2.0.2", "react-tooltip": "^5.18.1", "recharts": "^2.10.2", "sass": "^1.62.1", diff --git a/src/App.css b/src/App.css index 1d7cb588f..843de3003 100644 --- a/src/App.css +++ b/src/App.css @@ -15,6 +15,14 @@ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: transparent; } +.rti--container { + width: 250px; + max-height: 100px; + overflow: scroll; +} +.rti--container .rti--input { + width: 100%; +} .css-13cymwt-control, .css-t3ipsp-control { diff --git a/src/App.tsx b/src/App.tsx index a5c709691..2ba147f69 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -47,6 +47,7 @@ import Donation from "./modules/Public/Donation/Donation"; import Refund from "./modules/Public/Donation/pages/Refund"; import DonationSuccess from "./modules/Public/Donation/pages/DonationSuccess"; import OpenGrad from "./modules/Dashboard/modules/OpenGrad"; +import UserInterest from "./modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest"; const Profile = lazy( () => import("./modules/Dashboard/modules/Profile/pages/Profile") @@ -291,7 +292,19 @@ function App() { element: , children: [ { path: "register/:role", element: }, - { path: "register/", element: }, + { + path: "register/", + children: [ + { + path: "", + element: + }, + { + path: "interests", + element: + } + ] + }, { path: "login", element: }, { path: "forgot-password", element: }, { path: "reset-password", element: } diff --git a/src/modules/Common/Authentication/assets/interests/creative.svg b/src/modules/Common/Authentication/assets/interests/creative.svg new file mode 100644 index 000000000..e700e2c18 --- /dev/null +++ b/src/modules/Common/Authentication/assets/interests/creative.svg @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/Common/Authentication/assets/interests/makers.svg b/src/modules/Common/Authentication/assets/interests/makers.svg new file mode 100644 index 000000000..4dca1abdc --- /dev/null +++ b/src/modules/Common/Authentication/assets/interests/makers.svg @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/Common/Authentication/assets/interests/management.svg b/src/modules/Common/Authentication/assets/interests/management.svg new file mode 100644 index 000000000..d22b33537 --- /dev/null +++ b/src/modules/Common/Authentication/assets/interests/management.svg @@ -0,0 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/Common/Authentication/assets/interests/others.svg b/src/modules/Common/Authentication/assets/interests/others.svg new file mode 100644 index 000000000..e4678fac3 --- /dev/null +++ b/src/modules/Common/Authentication/assets/interests/others.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/Common/Authentication/assets/interests/software.svg b/src/modules/Common/Authentication/assets/interests/software.svg new file mode 100644 index 000000000..f410c6c1a --- /dev/null +++ b/src/modules/Common/Authentication/assets/interests/software.svg @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/Common/Authentication/pages/Onboarding/AccountCreation/AccountCreation.tsx b/src/modules/Common/Authentication/pages/Onboarding/AccountCreation/AccountCreation.tsx index 1693863df..44c4612c5 100644 --- a/src/modules/Common/Authentication/pages/Onboarding/AccountCreation/AccountCreation.tsx +++ b/src/modules/Common/Authentication/pages/Onboarding/AccountCreation/AccountCreation.tsx @@ -3,31 +3,20 @@ import { HiEye, HiEyeSlash } from "react-icons/hi2"; import OnboardingTemplate from "../../../components/OnboardingTeamplate/OnboardingTemplate"; import OnboardingHeader from "../../../components/OnboardingHeader/OnboardingHeader"; -import { - getDWMSDetails, - getRoles, - validate -} from "../../../services/newOnboardingApis"; +import { getDWMSDetails } from "../../../services/newOnboardingApis"; import { Form, Formik } from "formik"; import * as z from "yup"; import { FormikTextInputWithoutLabel as SimpleInput } from "@/MuLearnComponents/FormikComponents/FormikComponents"; import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useState } from "react"; -// import { useToast } from "@chakra-ui/react"; import { useNavigate, useParams } from "react-router-dom"; -import Select from "react-select"; import makeAnimated from "react-select/animated"; -import { getCommunities } from "../../../services/onboardingApis"; import { BiSupport } from "react-icons/bi"; import { isDev } from "@/MuLearnServices/common_functions"; -import roleOptions from "../RolePage/data/roleOptions"; -import muBrand from "/src/modules/Common/Authentication/assets/µLearn.png"; import { submitUserData } from "../../../services/newOnboardingApis"; import toast from "react-hot-toast"; -const animatedComponents = makeAnimated(); - type DWMSData = { email: string; fullName: string; @@ -77,29 +66,29 @@ const scheme = z.object({ export default function AccountCreation() { let { role } = useParams(); - const [popUP, setPopUp] = useState(role ? false : true); + // const [popUP, setPopUp] = useState(role ? false : true); // const toast = useToast(); const navigate = useNavigate(); - const [roles, setRoles] = useState([{ id: "", title: "" }]); + // const [roles, setRoles] = useState([{ id: "", title: "" }]); const urlParams = new URLSearchParams(window.location.search); const param = urlParams.get("param"); const referralId = urlParams.get("referral_id"); - const [selectedRoleId, setSelectedRoleId] = useState(""); - const [selectedRole, setSelectedRole] = useState(""); + // const [selectedRoleId, setSelectedRoleId] = useState(""); + // const [selectedRole, setSelectedRole] = useState(""); //ref to community selector for resetting - temporary fix - const community_select_ref = useRef(); + // const community_select_ref = useRef(); const [isLoading, setIsLoading] = useState(false); const [isVisible, setVisible] = useState(false); - const [isVisibleC, setVisibleC] = useState(false); + // const [isVisibleC, setVisibleC] = useState(false); const [dwmsData, setDWMSData] = useState(); const [isTncChecked, setTncChecked] = useState(false); - const [communitiesList, setCommunitiesList] = useState([ - { id: "", title: "" } - ]); + // const [communitiesList, setCommunitiesList] = useState([ + // { id: "", title: "" } + // ]); const [initialValues, setInitialValues] = useState({ email: "", fullName: "", @@ -117,19 +106,6 @@ export default function AccountCreation() { useEffect(() => { if (isLoading) return; setIsLoading(true); - getCommunities({ - setCommunityAPI: setCommunitiesList, - setIsLoading: setIsLoading - }); - getRoles().then((res: any) => { - setRoles(res); - setIsLoading(false); - setSelectedRoleId( - res.find((role: any) => role.title.toLowerCase() === role) - ?.id || "" - ); - // setSelectedRole(role); - }); if (param) { getDWMSDetails(param, (data: any) => { setDWMSData({ @@ -206,14 +182,6 @@ export default function AccountCreation() { userData.communities = values.communities; } - if (role) { - userData.role = roles.find(e => e.title.toLowerCase() === role)?.id; - } - - if (selectedRoleId) { - userData.role = selectedRoleId; - } - if (param) { userData.integration = { param: param, @@ -225,22 +193,22 @@ export default function AccountCreation() { userData.dob = dwmsData.dob; } - const isSuccess = await validate({ + // const isSuccess = await validate({ + // userData: userData, + // setIsSubmitting: setIsLoading + // // toast: toast // Make sure to pass the toast parameter correctly + // }); + submitUserData({ + setIsLoading: setIsLoading, userData: userData, - setIsSubmitting: setIsLoading - // toast: toast // Make sure to pass the toast parameter correctly + // toast: toast, + navigate: navigate }); + // if (isSuccess && selectedRole.toLowerCase() !== "other") { + // navigate("/register/about", { state: userData }); + // } else if (isSuccess && selectedRole.toLowerCase() === "other") { - if (isSuccess && selectedRole.toLowerCase() !== "other") { - navigate("/register/about", { state: userData }); - } else if (isSuccess && selectedRole.toLowerCase() === "other") { - submitUserData({ - setIsLoading: setIsLoading, - userData: userData, - // toast: toast, - navigate: navigate - }); - } + // } }; // console.log(selectedRole, role); @@ -258,7 +226,7 @@ export default function AccountCreation() { > {formik => (
- {popUP && ( + {/* {popUP && (
mulearn @@ -302,7 +270,7 @@ export default function AccountCreation() {
- )} + )} */}
@@ -628,13 +596,7 @@ export default function AccountCreation() { style={{ marginTop: "10px" }} isLoading={isLoading} > - {selectedRole.toLowerCase() !== "other" - ? isLoading - ? "Validating..." - : "Next Step" - : isLoading - ? "Validating..." - : "Submit"} + {isLoading ? "Validating..." : "Submit"}
diff --git a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx index d19c7f946..328a67c12 100644 --- a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx +++ b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx @@ -79,7 +79,7 @@ export default function CollegePage({ ): boolean => { if (value === "Others") return true; // Always show "Others" option if (!string) return true; - return label.toLowerCase().startsWith(string.toLowerCase()); + return label.toLowerCase().includes(string.toLowerCase()); }; useEffect(() => { diff --git a/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.module.css b/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.module.css new file mode 100644 index 000000000..2a54f83b2 --- /dev/null +++ b/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.module.css @@ -0,0 +1,237 @@ +.popUp { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + backdrop-filter: blur(10px); + background-color: #00000014; + z-index: 100; + display: flex; + justify-content: center; + align-items: center; + + .box { + background-color: #fff; + border-radius: 20px; + padding: 40px 10px 10px; + min-height: 300px; + max-width: 700px; + position: relative; + z-index: 100; + display: flex; + align-items: center; + flex-direction: column; + h1 { + text-align: center; + } + & img { + height: 30px; + } + + & h1 { + font-size: 2rem; + font-weight: 600; + } + + .subText { + margin-top: 10px; + font-size: 1rem; + font-weight: 500; + margin-bottom: 10px; + } + + .itemsContainer { + gap: 1.5rem; + z-index: 10; + cursor: pointer; + display: flex; + flex-wrap: wrap; + padding: 20px; + justify-content: center; + overflow: show; + + .itemsCard { + min-width: 200px; + max-height: 120px; + border-radius: 10px; + background-color: #fff; + box-shadow: 0px 0px 17.65823px 0px rgba(0, 0, 0, 0.07); + display: flex; + align-items: center; + flex-direction: column; + text-align: center; + justify-content: center; + padding: 10px; + position: relative; + transition: all 0.3s ease; + position: relative; + + .infoButton { + position: absolute; + top: 10px; + right: 10px; + padding: 5px; + border-radius: 50%; + cursor: pointer; + color: #456ff6; + z-index: 11; + } + + .interestInfo { + display: none; + position: absolute; + width: 200px; + height: 100%; + top: 0; + left: 0; + color: #22222290; + font-size: 10px; + background: #ffffff; + border: 1px solid #456ef694; + padding: 10px; + border-radius: 10px; + z-index: 10; + flex-direction: column; + justify-content: start; + gap: 10px; + h4 { + font-weight: 800; + text-align: start; + } + ul { + display: block; + padding: 0; + margin: 0; + li { + margin-left: 20px; + text-align: start; + width: auto; + } + } + } + .content { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100px; + p { + transform: translateY(-90%); + } + } + + &.others { + &.checked { + display: flex; + width: calc(380px + 3rem); + justify-content: space-around; + flex-direction: column; + overflow: visible; + flex-direction: row; + gap: 1rem; + } + } + + .checkmark { + position: absolute; + top: 0px; + left: 0px; + transform: translate(-30%, -30%); + color: #ffffff; + background-color: #456ff6; + border-radius: 50%; + padding: 2px; + z-index: 12; + } + + div { + display: flex; + } + + &:hover { + outline: 1.177px solid #456ff6; + transition: 1s ease; + + .interestInfo { + display: flex; + } + } + + &.others { + position: relative; + overflow: hidden; + } + .interestOther { + background: red; + } + + .othersTextBox { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: #fff; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding: 10px; + transform: translateY(0); + transition: transform 0.3s ease-in-out; + } + + .tagInput { + background: red !important; + width: 100%; + } + .otherInterestInput { + width: 90%; + padding: 8px; + margin-top: 10px; + border: 1px solid #ccc; + border-radius: 4px; + font-size: 14px; + } + } + .active { + outline: 2px solid #456ff6; + } + .itemImage { + margin-top: 1rem; + object-fit: cover; + height: 70px; + width: 70px; + -webkit-user-drag: none; + } + .title { + margin-top: 0.5rem; + font-weight: bold; + } + } + + @media (width<500px) { + .interestSelectCards .interestSelectCard { + max-width: 300px; + } + .itemsContainer { + .itemsCard { + max-width: 200px; + &.others { + &.checked { + flex-direction: column; + } + } + } + } + } + + @media (width<300px) { + .interestSelectCards .interestSelectCard { + max-width: 200px; + font-size: 0.65rem; + } + } + } +} diff --git a/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.tsx b/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.tsx new file mode 100644 index 000000000..ffdd1c08a --- /dev/null +++ b/src/modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest.tsx @@ -0,0 +1,359 @@ +import { useEffect, useState } from "react"; +import OnboardingHeader from "../../../components/OnboardingHeader/OnboardingHeader"; +import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton"; +import styles from "./UserInterest.module.css"; +import muBrand from "/src/modules/Common/Authentication/assets/µLearn.png"; +import { TagsInput } from "react-tag-input-component"; +import { privateGateway, publicGateway } from "@/MuLearnServices/apiGateways"; +import { onboardingRoutes } from "@/MuLearnServices/urls"; +import toast from "react-hot-toast"; +import { useNavigate } from "react-router-dom"; +import creative from "/src/modules/Common/Authentication/assets/interests/creative.svg"; +import maker from "/src/modules/Common/Authentication/assets/interests/makers.svg"; +import management from "/src/modules/Common/Authentication/assets/interests/management.svg"; +import software from "/src/modules/Common/Authentication/assets/interests/software.svg"; +import others from "/src/modules/Common/Authentication/assets/interests/others.svg"; + +const CheckMark = () => ( + + + +); + +export default function UserInterest() { + const [interests, setInterests] = useState([ + { title: "Software", value: "software", img: software, checked: false }, + { title: "Maker", value: "maker", img: maker, checked: false }, + { + title: "Management", + value: "management", + img: management, + checked: false + }, + { title: "Creative", value: "creative", img: creative, checked: false }, + { title: "Others", value: "others", img: others, checked: false } + ]); + const [endgoals, setEndgoals] = useState([ + { title: "Job", value: "job", checked: false }, + { + title: "Higher Education", + value: "higher_education", + checked: false + }, + { + title: "Entrepreneurship", + value: "entrepreneurship", + checked: false + }, + { title: "Gig Works", value: "gig_work", checked: false }, + { title: "Others", value: "others", checked: false } + ]); + const [otherInterest, setOtherInterest] = useState([]); + const [otherEndgoal, setOtherEndgoal] = useState([]); + const [stepTwo, setStepTwo] = useState(false); + const [interestGroups, setInterestGroups] = useState<{}>({}); + const navigate = useNavigate(); + + useEffect(() => { + publicGateway + .get(onboardingRoutes.interestGroups) + .then(res => { + var data: [] = res.data?.response?.interestGroup ?? []; + var interestGroupsData = {}; + for (let interest of interests) { + (interestGroupsData as any)[interest.value] = data.filter( + (group: any) => group?.category == interest.value + ); + } + setInterestGroups(interestGroupsData); + }) + .catch(err => { + console.log(err); + }); + }, []); + + const handleInterestChange = (value: any) => { + if (value === "others") { + if ( + interests.filter(interest => interest.value === value)[0] + .checked + ) { + setOtherInterest([]); + } + } + setInterests( + interests.map(interest => + interest.value === value + ? { ...interest, checked: !interest.checked } + : interest + ) + ); + }; + + const handleEndgoalChange = (value: any) => { + if (value === "others") { + if ( + endgoals.filter(endgoal => endgoal.value === value)[0].checked + ) { + setOtherEndgoal([]); + } + } + setEndgoals( + endgoals.map(endgoal => + endgoal.value === value + ? { ...endgoal, checked: !endgoal.checked } + : endgoal + ) + ); + }; + + const handleContinue = () => { + const selectedInterests = interests + .filter(interest => interest.checked) + .map(interest => interest); + if (selectedInterests.find(interest => interest.value === "others")) { + if (otherInterest.length === 0) { + return; + } + } + if (selectedInterests.length > 0 || otherInterest.length > 0) { + setStepTwo(true); + } + }; + + const handleSubmit = () => { + const selectedInterests = interests + .filter(interest => interest.checked) + .map(interest => interest); + const selectedEndgoals = endgoals + .filter(endgoal => endgoal.checked) + .map(endgoal => endgoal); + const data = { + choosen_interests: selectedInterests.map( + interest => interest.value + ), + choosen_endgoals: selectedEndgoals.map(endgoal => endgoal.value), + other_interests: otherInterest, + other_endgoals: otherEndgoal + }; + try { + privateGateway + .post(onboardingRoutes.interests, data) + .then(res => { + toast.success(res.data?.message.general[0]); + navigate("/dashboard/connect-discord"); + }) + .catch(err => { + toast.error(err.response?.data.message.general[0]); + }); + } catch (err) { + toast.error("Unexpected Error occured"); + } + }; + + const isInterestSelected = interests.some(interest => interest.checked); + const isEndgoalSelected = endgoals.some(endgoal => endgoal.checked); + + return stepTwo ? ( + <> + +
+
+ mulearn +

What describes you the most!

+

+ Choose one or goals you expect from µLearn. +

+
+ {endgoals.map(endgoal => { + let classname = `${styles.itemsCard} ${ + endgoal.checked && styles.checked + }`; + return ( +
+ handleEndgoalChange(endgoal.value) + } + > + {endgoal.checked && } +

{endgoal.title}

+ + {endgoal.value == "others" ? ( + endgoals.find( + endgoal => + endgoal.value === "others" + )?.checked && ( +
{ + e.stopPropagation(); + }} + > + +
+ ) + ) : ( + <> + )} +
+ ); + })} +
+ + {isEndgoalSelected && ( + + Submit + + )} +
+
+ + ) : ( + <> + +
+
+ mulearn +

Your dynamic area of interest!

+

+ Please select your interested area +

+
+ {interests.map(interest => { + let classname = `${styles.itemsCard} ${ + interest.checked && styles.active + }`; + return ( +
+ handleInterestChange(interest.value) + } + > + {interest.checked && } +
+ +

+ {interest.title} +

+
+
{ + e.stopPropagation(); + }} + > + + + + +
+
+

This category includes:

+
    + {(interestGroups as any)[ + interest.value + ]?.map((group: any) => ( +
  • + {group.name} +
  • + ))} +
+
+ {interest.value == "others" ? ( + interests.find( + interest => + interest.value === "others" + )?.checked && ( + <> +
{ + e.stopPropagation(); + }} + > + +
+ + ) + ) : ( + <> + )} +
+ ); + })} +
+ + {isInterestSelected && ( + + Continue + + )} +
+
+ + ); +} diff --git a/src/modules/Common/Authentication/services/newOnboardingApis.ts b/src/modules/Common/Authentication/services/newOnboardingApis.ts index dab1c8948..66a2e7fe4 100644 --- a/src/modules/Common/Authentication/services/newOnboardingApis.ts +++ b/src/modules/Common/Authentication/services/newOnboardingApis.ts @@ -165,7 +165,7 @@ export const submitUserData = async ({ const tokens = res.data.response; localStorage.setItem("accessToken", tokens.accessToken); localStorage.setItem("refreshToken", tokens.refreshToken); - getInfo(() => navigate("/dashboard/connect-discord")); + getInfo(() => navigate("/register/interests")); } catch (err: any) { setIsLoading(false); const messages = err.response.data.message.general[0]; diff --git a/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.module.css b/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.module.css index 80bf723e4..c6ea822cb 100644 --- a/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.module.css +++ b/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.module.css @@ -15,6 +15,7 @@ justify-content: space-evenly; background: #fff; /* border: 1px solid #dde2e5; */ + min-height: 250px; border-radius: 20px; overflow: hidden; font-weight: 500; diff --git a/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.tsx b/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.tsx index 2e3bfb133..eeea1e53e 100644 --- a/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.tsx +++ b/src/modules/Dashboard/modules/ConnectDiscord/pages/ConnectDiscord.tsx @@ -1,17 +1,22 @@ import { useEffect, useRef, useState } from "react"; import styles from "./ConnectDiscord.module.css"; import cdimage from "../assets/images/connectdiscordpng1.webp"; -import { getInfo } from "../services/apis"; +import { connectDiscord, getInfo } from "../services/apis"; import { MdContentCopy } from "react-icons/md"; import { BsDiscord } from "react-icons/bs"; import MuLoader from "@/MuLearnComponents/MuLoader/MuLoader"; import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton"; import { FaInstagram } from "react-icons/fa6"; import toast from "react-hot-toast"; +import { useNavigate, useSearchParams } from "react-router-dom"; const ConnectDiscord = () => { const [muid, setMuid] = useState(""); const firstFetch = useRef(true); + const [searchParams, _] = useSearchParams(); + const token = searchParams.get("code"); + const [discordStatus, setDiscordStatus] = useState("connecting"); + const navigate = useNavigate(); useEffect(() => { if (firstFetch.current) { if ( @@ -26,62 +31,94 @@ const ConnectDiscord = () => { firstFetch.current = false; }, []); + useEffect(() => { + if (token) { + connectDiscord(token).then(res => { + if (res) { + setDiscordStatus("connected"); + navigate("/dashboard/profile"); + toast.success( + "You will be added to our discord server shortly" + ); + setTimeout(() => { + var a = document.createElement("a"); + a.href = + "https://discord.gg/gtech-mulearn-771670169691881483"; + a.target = "_blank"; + a.click(); + }, 5000); + } else { + setDiscordStatus("failed"); + } + }); + } + }, []); + return ( <> - {muid && muid.length > 0 ? ( -
-
-
-

Join Discord using your µid

-

- To join our discord server you need to connect - your account with discord. To do so you need to - copy your µid and paste it in the discord - server. -

-
- { - navigator.clipboard.writeText(muid); - - toast.success( - "Copied to clipboard, Please paste it in discord to connect your account" - ); - }} - > - - {muid} - - - - - Connect Discord - - - - -

- Follow Us + {token == null ? ( + <> + {muid && muid.length > 0 ? ( +

+
+
+

Join Discord using your µid

+

+ To join our discord server you need to + connect your account with discord. To do + so you need to copy your µid and paste + it in the discord server.

-
+
+ { + navigator.clipboard.writeText( + muid + ); + + toast.success( + "Copied to clipboard, Please paste it in discord to connect your account" + ); + }} + > + + {muid} + + + + + Join Discord + + + + +

+ Follow Us +

+
+
+
+
-
- -
-
+ {/*

Onboarding Flow

@@ -128,14 +165,46 @@ const ConnectDiscord = () => {

-
-
- ) : ( +
*/} +
+ ) : ( +
+
+ {" "} +
+
+ )} + + ) : discordStatus == "connecting" ? (
{" "}
+ ) : discordStatus == "connected" ? ( +
+
+
+

Discord Connected

+

+ Your account has been successfully connected to + discord. +

+
+
+
+ ) : ( +
+
+
+

Discord Connection Failed

+

+ Your account could not be connected to discord. + Please try again later. +

+
+
+
)} ); diff --git a/src/modules/Dashboard/modules/ConnectDiscord/services/apis.ts b/src/modules/Dashboard/modules/ConnectDiscord/services/apis.ts index 476b64238..791bdbf20 100644 --- a/src/modules/Dashboard/modules/ConnectDiscord/services/apis.ts +++ b/src/modules/Dashboard/modules/ConnectDiscord/services/apis.ts @@ -1,8 +1,26 @@ import { privateGateway } from "@/MuLearnServices/apiGateways"; -import { dashboardRoutes } from "@/MuLearnServices/urls"; +import { dashboardRoutes, onboardingRoutes } from "@/MuLearnServices/urls"; type muid = UseStateFunc; - +export const connectDiscord = async (code: string) => { + try { + return await privateGateway + .get(onboardingRoutes.connectDiscord, { + params: { + code + } + }) + .then(response => { + return response.status === 200; + }) + .catch(err => { + console.log(err); + return false; + }); + } catch (err: any) { + return false; + } +}; export const getInfo = (setMuid?: muid, onComplete?: Function) => { privateGateway .get(dashboardRoutes.getInfo) diff --git a/src/services/urls.ts b/src/services/urls.ts index d12bb37cf..c7d6d4baf 100644 --- a/src/services/urls.ts +++ b/src/services/urls.ts @@ -9,6 +9,8 @@ export const onboardingRoutes = { areaOfInterestList: "/api/v1/register/area-of-interest/list/", communityList: "/api/v1/register/community/list/", register: "/api/v1/register/", + interests: "/api/v1/register/interests/", + interestGroups: "/api/v1/dashboard/ig/list/", emailVerification: "/api/v1/register/email-verification/", // New Onboarding Routes createAccount: "/api/v1/register/new/", @@ -17,7 +19,8 @@ export const onboardingRoutes = { departments: "/api/v1/register/department/list/", companies: "/api/v1/register/company/list/", validate: "/api/v1/register/validate/", - location: "/api/v1/register/location/?q=${param}" + location: "/api/v1/register/location/?q=${param}", + connectDiscord: "/api/v1/register/connect-discord/" } as const; export const authRoutes = {