Skip to content

Commit

Permalink
Merge pull request #1643 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Dev Server
  • Loading branch information
nashnsulthan authored Oct 8, 2024
2 parents 138063a + 933147a commit bae2129
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
13 changes: 5 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
Navigate
} from "react-router-dom";
import AuthRoutes from "./components/AuthRoutes";
import Onboarding from "./modules/Common/Authentication/pages/Onboarding";
import Login from "./modules/Common/Authentication/pages/Login";
import ForgotPassword from "./modules/Common/Authentication/pages/ForgotPassword";

import PrivateRoutes from "./components/PrivateRoutes";
import DashboardRootLayout from "./modules/Dashboard/layouts/DashboardRootLayout";
import NotFound from "./components/NotFound";
Expand Down Expand Up @@ -298,18 +294,19 @@ function App() {
{
path: "",
element: <AccountCreation />
},
{
path: "interests",
element: <UserInterest />
}
]
},

{ path: "login", element: <SignIn /> },
{ path: "forgot-password", element: <ForgetPassword /> },
{ path: "reset-password", element: <ResetPassword /> }
]
},
{
path: "/register/interests",
element: <UserInterest />
},
{
path: "/signin",
element: <SignIn />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { KKEMRoutes, onboardingRoutes } from "@/MuLearnServices/urls";

import { Dispatch, SetStateAction } from "react";
import { NavigateFunction } from "react-router-dom";
import { bool, boolean } from "yup";
import { getInfo } from "../../../Dashboard/modules/ConnectDiscord/services/apis";
import { DWMSDetails } from "./onboardingApis";
import toast from "react-hot-toast";
Expand Down Expand Up @@ -53,7 +52,7 @@ export const createAccount = async ({
const tokens = response.data.response;
localStorage.setItem("accessToken", tokens.accessToken);
localStorage.setItem("refreshToken", tokens.refreshToken);
getInfo(() => {
getInfo(navigate, () => {
navigate("/role");
});
} catch (err: any) {
Expand Down Expand Up @@ -165,7 +164,7 @@ export const submitUserData = async ({
const tokens = res.data.response;
localStorage.setItem("accessToken", tokens.accessToken);
localStorage.setItem("refreshToken", tokens.refreshToken);
getInfo(() => navigate("/register/interests"));
navigate("/register/interests");
} catch (err: any) {
setIsLoading(false);
const messages = err.response.data.message.general[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export const registerUser = (
"refreshToken",
response.data.response.refreshToken
);
getInfo(() => {
getInfo(navigate, () => {
navigate("/dashboard/connect-discord");
setShowSubmitLoader(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ConnectDiscord = () => {
) {
setMuid(JSON.parse(localStorage.getItem("userInfo")!).mu_id);
} else {
getInfo(setMuid);
getInfo(navigate, setMuid);
}
}
firstFetch.current = false;
Expand Down
12 changes: 11 additions & 1 deletion src/modules/Dashboard/modules/ConnectDiscord/services/apis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { privateGateway } from "@/MuLearnServices/apiGateways";
import { dashboardRoutes, onboardingRoutes } from "@/MuLearnServices/urls";
import toast from "react-hot-toast";
import { NavigateFunction } from "react-router-dom";

type muid = UseStateFunc<string>;
export const connectDiscord = async (code: string) => {
Expand All @@ -21,14 +23,22 @@ export const connectDiscord = async (code: string) => {
return false;
}
};
export const getInfo = (setMuid?: muid, onComplete?: Function) => {
export const getInfo = (
navigate: NavigateFunction,
setMuid?: muid,
onComplete?: Function
) => {
privateGateway
.get(dashboardRoutes.getInfo)
.then((response: APIResponse<UserInfo>) => {
localStorage.setItem(
"userInfo",
JSON.stringify(response.data.response)
);
if (response.data.response?.interest_selected) {
toast.error(response.data.response?.interest_selected);
navigate("/register/interests");
}
if (setMuid) setMuid(response.data.response.muid);
if (onComplete) onComplete();
})
Expand Down
38 changes: 20 additions & 18 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ type UseStateFunc<T> = React.Dispatch<React.SetStateAction<T>>;
type FC<T> = React.FC<T>;

type Role =
(typeof import("./services/types").roles)[keyof typeof import("./services/types").roles];
typeof import("./services/types").roles[keyof typeof import("./services/types").roles];

type ManagementTypes = (typeof import('./services/types').managementTypes)[keyof typeof import('./services/types').managementTypes]
type ManagementTypes =
typeof import("./services/types").managementTypes[keyof typeof import("./services/types").managementTypes];

type UserInfo = {
muid: string,
full_name: string,
email: string,
mobile: string,
gender: null,
dob: null,
active: boolean,
exist_in_guild: boolean,
joined: string,
roles: Role[],
dynamic_type?: ManagementTypes[],
cipher?: string,
profile_pic?: string,
}

type ColOrder = { column: string, Label: string, isSortable: boolean }
muid: string;
full_name: string;
email: string;
mobile: string;
gender: null;
dob: null;
active: boolean;
exist_in_guild: boolean;
joined: string;
roles: Role[];
dynamic_type?: ManagementTypes[];
cipher?: string;
profile_pic?: string;
interest_selected: string | null;
};

type ColOrder = { column: string; Label: string; isSortable: boolean };

// just pass json structure type as parameters
type APIResponse<R = {}, M = {}[]> = {
Expand Down

0 comments on commit bae2129

Please sign in to comment.