Skip to content

Commit

Permalink
Merge pull request #1690 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Dev Server
  • Loading branch information
aswanthabam authored Nov 17, 2024
2 parents 37e372a + 488eeec commit 7ba12c0
Show file tree
Hide file tree
Showing 18 changed files with 1,312 additions and 444 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import { CampusStudentList, ConnectDiscord } from "./modules/Dashboard/modules";

import LandingPage from "./modules/Public/LearningCircles/pages/LandingPage";
import ProfileV2 from "./modules/Dashboard/modules/ProfileV2/pages/Profile";
import AccountCreation from "./modules/Common/Authentication/pages/Onboarding/AccountCreation/AccountCreation";
import Rolepage from "./modules/Common/Authentication/pages/Onboarding/RolePage/RolePage";
import CollegePage from "./modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage";
import CompanyPage from "./modules/Common/Authentication/pages/Onboarding/CompanyPage/CompanyPage";
import SignIn from "./modules/Common/Authentication/pages/Onboarding/SignIn/SignIn";

import ErrorLog from "./modules/Dashboard/modules/ErrorLog/ErrorLog";
Expand All @@ -43,7 +41,6 @@ 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";
import LcMeetupIfo from "./modules/Dashboard/modules/LearningCircle/pages/Meetup/LcMeetup";
import OrganizationSetting from "./modules/Dashboard/modules/Settings/pages/Organization/Organization";
import SettingsHome from "./modules/Dashboard/modules/Settings/pages/Settings/SettingsHome";
Expand All @@ -58,6 +55,9 @@ import YourLC from "./modules/Dashboard/modules/LearningCircleV2/pages/YourLC/Yo
import MoreInfoLC from "./modules/Dashboard/modules/LearningCircleV2/pages/moreInfoLC/MoreInfoLC";
import AttendeeReport from "./modules/Dashboard/modules/LearningCircleV2/pages/AttendeeReport/AttendeeReport";
import LCReport from "./modules/Dashboard/modules/LearningCircleV2/pages/LCReport/LCReport";
import UserInterest from "./modules/Common/Authentication/pages/Onboarding/UserInterest/UserInterest";
import PathFinder from "./modules/Common/Authentication/pages/Onboarding/PathFinder/PathFinder";
import RegisterPage from "./modules/Common/Authentication/pages/Onboarding/Register/Register";

const Profile = lazy(
() => import("./modules/Dashboard/modules/Profile/pages/Profile")
Expand Down Expand Up @@ -301,17 +301,16 @@ function App() {
path: "/",
element: <AuthRoutes />,
children: [
{ path: "register/:role", element: <AccountCreation /> },
{ path: "register/:role", element: <RegisterPage /> },
{
path: "register/",
children: [
{
path: "",
element: <AccountCreation />
element: <RegisterPage />
}
]
},

{ path: "login", element: <SignIn /> },
{ path: "forgot-password", element: <ForgetPassword /> },
{ path: "reset-password", element: <ResetPassword /> }
Expand All @@ -325,6 +324,10 @@ function App() {
path: "/register/organization",
element: <CollegePage />
},
{
path: "/register/pathfinder",
element: <PathFinder />
},
{
path: "/signin",
element: <SignIn />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/modules/Common/Authentication/assets/quiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
import styles from "./AccountCreation.module.css";
import { HiEye, HiEyeSlash } from "react-icons/hi2";

import OnboardingTemplate from "../../../components/OnboardingTeamplate/OnboardingTemplate";
import OnboardingHeader from "../../../components/OnboardingHeader/OnboardingHeader";
import { getDWMSDetails } from "../../../services/newOnboardingApis";
import OnboardingHeader from "../OnboardingHeader/OnboardingHeader";
import OnboardingTemplate from "../OnboardingTeamplate/OnboardingTemplate";
import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { Form, Formik } from "formik";
import { isDev } from "@/MuLearnServices/common_functions";
import * as z from "yup";
import styles from "./AccountCreationComponent.module.css";
import { FormikTextInputWithoutLabel as SimpleInput } from "@/MuLearnComponents/FormikComponents/FormikComponents";
import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton";
import { useEffect, useState } from "react";

import { useNavigate, useParams } from "react-router-dom";
import makeAnimated from "react-select/animated";
import { HiEye } from "react-icons/hi";
import { HiEyeSlash } from "react-icons/hi2";
import { BiSupport } from "react-icons/bi";
import { isDev } from "@/MuLearnServices/common_functions";
import { submitUserData } from "../../../services/newOnboardingApis";
import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton";
import { getDWMSDetails } from "../../services/newOnboardingApis";
import toast from "react-hot-toast";

type DWMSData = {
email: string;
fullName: string;
phoneNumber: string;
gender?: string;
dob?: string;
};

const scheme = z.object({
email: z
.string()
.required(`Email is Required`)
.min(5, `Email must be at least 3 characters`)
.max(100, `Email must be at most 100 characters`),
fullName: z
full_name: z
.string()
.required(`Full Name is Required`)
.min(3, `Full Name must be at least 3 characters`)
.max(100, `Full Name must be at most 100 characters`),
// phoneNumber: z
// .string()
// .required(`Phone number is Required`)
// .min(10, `Phone number must be at least 10 characters`)
// .max(10, `Phone number must be at most 10 characters`),
...(isDev()
? {
password: z.string().required(`Password is Required`)
Expand All @@ -52,51 +35,62 @@ const scheme = z.object({
.min(8, `Password must be at least 8 characters`)
.max(100, `Password must be at most 100 characters`)
})
// confirmPassword: z
// .string()
// .required(`Password is Required`)
// .test(
// "passwords-match",
// "Passwords are not matching",
// function (value) {
// return this.parent.password === value;
// }
// )
});

export default function AccountCreation() {
let { role } = useParams();
const navigate = useNavigate();
const urlParams = new URLSearchParams(window.location.search);
const param = urlParams.get("param");
const referralId = urlParams.get("referral_id");

const [isLoading, setIsLoading] = useState(false);
const [isVisible, setVisible] = useState(false);
const [dwmsData, setDWMSData] = useState<DWMSData>();

const [isTncChecked, setTncChecked] = useState(false);

const [initialValues, setInitialValues] = useState({
export default function AccountCreationComponent({
ruri,
isLoading,
setIsLoading,
dwmsParam,
refferalId,
onContinue
}: {
ruri?: string;
isLoading: boolean;
setIsLoading: Dispatch<SetStateAction<boolean>>;
dwmsParam?: string;
refferalId?: string;
onContinue: (data: RegisterRequestDataType) => void;
}) {
const [initialValues, setInitialValues] = useState<RegisterUserData>({
full_name: "",
email: "",
fullName: "",
password: "",
role: "",
muid: "",
communities: []
password: ""
});
const ruri = window.location.href.split("=")[1];
const [dwmsData, setDWMSData] = useState<DWMSData>();
const [isVisible, setVisible] = useState(false);
const [isTncChecked, setTncChecked] = useState(false);

role =
role === "student" || role === "mentor" || role === "enabler"
? role
: "other";
const onSubmit = (values: any) => {
if (!isTncChecked) {
toast.error("Please accept the terms and conditions");
return;
}
const userData: RegisterRequestDataType = {
user: {
full_name: values.full_name,
email: values.email,
password: values.password
},
interests: {
choosen_interests: [],
choosen_endgoals: [],
other_interests: [],
other_endgoals: []
},
integration: dwmsParam
? { param: dwmsParam, title: "DWMS" }
: undefined,
referral: refferalId ? { muid: refferalId } : undefined
};
onContinue(userData);
};

useEffect(() => {
if (isLoading) return;
setIsLoading(true);
if (param) {
getDWMSDetails(param, (data: any) => {
if (dwmsParam) {
getDWMSDetails(dwmsParam, (data: any) => {
setDWMSData({
email: data?.email_id || "",
fullName:
Expand All @@ -110,74 +104,16 @@ export default function AccountCreation() {
setInitialValues({
...initialValues,
email: data?.email_id || "",
fullName:
full_name:
data?.job_seeker_fname + " " + data?.job_seeker_lname ||
""
// phoneNumber: data?.mobile_no || ""
});
});
}

setIsLoading(false);
}, []);

const onsubmit = async (values: any, actions: any) => {
if (!isTncChecked) {
toast.error("Please accept the terms and conditions");
return;
}
const userData: {
user: {
full_name: any;
email: any;
password: any;
};
role?: string;
referral?: { muid: string };
gender?: string;
dob?: string;
communities?: string[];
integration?: {
param: string;
title: string;
};
} = {
user: {
full_name: values.fullName,
email: values.email,
password: values.password
}
};

if (dwmsData && dwmsData.gender) {
userData.gender = dwmsData.gender;
}

if (param) {
userData.integration = {
param: param,
title: "DWMS"
};
}

if (dwmsData && dwmsData.dob) {
userData.dob = dwmsData.dob;
}

submitUserData({
setIsLoading: setIsLoading,
userData: userData
}).then(res => {
if (res) {
navigate(
ruri
? `/register/interests/?ruri=${ruri}`
: "/register/interests"
);
}
});
};

return (
<OnboardingTemplate>
<OnboardingHeader
Expand All @@ -188,7 +124,7 @@ export default function AccountCreation() {
initialValues={initialValues}
enableReinitialize={true}
validationSchema={scheme}
onSubmit={onsubmit}
onSubmit={onSubmit}
>
{formik => (
<Form>
Expand Down Expand Up @@ -221,12 +157,12 @@ export default function AccountCreation() {
<div className={styles.accountCreationName}>
<div className={styles.inputBox}>
<SimpleInput
name={"fullName"}
name={"full_name"}
onChange={formik.handleChange}
type="text"
placeholder="Full Name"
value={
formik.values.fullName ||
formik.values.full_name ||
dwmsData?.fullName
}
required
Expand Down
Loading

0 comments on commit 7ba12c0

Please sign in to comment.