forked from github/plane
promote: staging to production
This commit is contained in:
commit
02111d779b
@ -1 +1 @@
|
||||
python-3.11.3
|
||||
python-3.11.4
|
@ -16,7 +16,7 @@ type EmailCodeFormValues = {
|
||||
token?: string;
|
||||
};
|
||||
|
||||
export const EmailCodeForm = ({ onSuccess }: any) => {
|
||||
export const EmailCodeForm = ({ handleSignIn }: any) => {
|
||||
const [codeSent, setCodeSent] = useState(false);
|
||||
const [codeResent, setCodeResent] = useState(false);
|
||||
const [isCodeResending, setIsCodeResending] = useState(false);
|
||||
@ -66,18 +66,23 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
|
||||
|
||||
const handleSignin = async (formData: EmailCodeFormValues) => {
|
||||
setIsLoading(true);
|
||||
await authenticationService.magicSignIn(formData).catch((error) => {
|
||||
setIsLoading(false);
|
||||
setToastAlert({
|
||||
title: "Oops!",
|
||||
type: "error",
|
||||
message: error?.response?.data?.error ?? "Enter the correct code to sign in",
|
||||
await authenticationService
|
||||
.magicSignIn(formData)
|
||||
.then((response) => {
|
||||
handleSignIn(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
setIsLoading(false);
|
||||
setToastAlert({
|
||||
title: "Oops!",
|
||||
type: "error",
|
||||
message: error?.response?.data?.error ?? "Enter the correct code to sign in",
|
||||
});
|
||||
setError("token" as keyof EmailCodeFormValues, {
|
||||
type: "manual",
|
||||
message: error?.error,
|
||||
});
|
||||
});
|
||||
setError("token" as keyof EmailCodeFormValues, {
|
||||
type: "manual",
|
||||
message: error.error,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const emailOld = getValues("email");
|
||||
|
@ -19,12 +19,14 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {
|
||||
} = useRouter();
|
||||
// states
|
||||
const [loginCallBackURL, setLoginCallBackURL] = useState(undefined);
|
||||
const [gitCode, setGitCode] = useState<null | string>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (code) {
|
||||
if (code && !gitCode) {
|
||||
setGitCode(code.toString());
|
||||
handleSignIn(code.toString());
|
||||
}
|
||||
}, [code, handleSignIn]);
|
||||
}, [code, gitCode, handleSignIn]);
|
||||
|
||||
useEffect(() => {
|
||||
const origin =
|
||||
@ -33,12 +35,12 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="w-full px-1">
|
||||
<div className="w-full flex justify-center items-center px-[3px]">
|
||||
<Link
|
||||
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}&scope=read:user,user:email`}
|
||||
>
|
||||
<button className="flex w-full items-center justify-center gap-3 rounded-md border border-brand-base p-2 text-sm font-medium text-brand-secondary duration-300 hover:bg-brand-surface-2">
|
||||
<Image src={githubImage} height={22} width={22} color="#000" alt="GitHub Logo" />
|
||||
<button className="flex w-full items-center justify-center gap-3 rounded border border-brand-base p-2 text-sm font-medium text-brand-secondary duration-300 hover:bg-brand-surface-2">
|
||||
<Image src={githubImage} height={20} width={20} color="#000" alt="GitHub Logo" />
|
||||
<span>Sign In with Github</span>
|
||||
</button>
|
||||
</Link>
|
||||
|
@ -47,7 +47,11 @@ export const GoogleLoginButton: FC<IGoogleLoginButton> = (props) => {
|
||||
return (
|
||||
<>
|
||||
<Script src="https://accounts.google.com/gsi/client" async defer onLoad={loadScript} />
|
||||
<div className="overflow-hidden rounded" id="googleSignInButton" ref={googleSignInButton} />
|
||||
<div
|
||||
className="overflow-hidden rounded w-full flex justify-center items-center"
|
||||
id="googleSignInButton"
|
||||
ref={googleSignInButton}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ import { ICurrentUserResponse, IUser } from "types";
|
||||
import { MultiInput, PrimaryButton, SecondaryButton } from "components/ui";
|
||||
|
||||
type Props = {
|
||||
setStep: React.Dispatch<React.SetStateAction<number>>;
|
||||
setStep: React.Dispatch<React.SetStateAction<number | null>>;
|
||||
workspace: any;
|
||||
user: ICurrentUserResponse | undefined;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ const defaultValues: Partial<IUser> = {
|
||||
|
||||
type Props = {
|
||||
user?: IUser;
|
||||
setStep: React.Dispatch<React.SetStateAction<number>>;
|
||||
setStep: React.Dispatch<React.SetStateAction<number | null>>;
|
||||
setUserRole: React.Dispatch<React.SetStateAction<string | null>>;
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@ import { PrimaryButton } from "components/ui";
|
||||
import { getFirstCharacters, truncateText } from "helpers/string.helper";
|
||||
|
||||
type Props = {
|
||||
setStep: React.Dispatch<React.SetStateAction<number>>;
|
||||
setStep: React.Dispatch<React.SetStateAction<number | null>>;
|
||||
setWorkspace: React.Dispatch<React.SetStateAction<any>>;
|
||||
user: ICurrentUserResponse | undefined;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import { mutate } from "swr";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
import userService from "services/user.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// ui
|
||||
@ -77,7 +78,7 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
|
||||
message: "Workspace created successfully.",
|
||||
});
|
||||
mutate<IWorkspace[]>(USER_WORKSPACES, (prevData) => [res, ...(prevData ?? [])]);
|
||||
onSubmit(res);
|
||||
updateLastWorkspaceIdUnderUSer(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
@ -93,6 +94,18 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
|
||||
});
|
||||
};
|
||||
|
||||
// update last_workspace_id
|
||||
const updateLastWorkspaceIdUnderUSer = (workspace: any) => {
|
||||
userService
|
||||
.updateUser({ last_workspace_id: workspace.id })
|
||||
.then((res) => {
|
||||
onSubmit(workspace);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
// when the component unmounts set the default values to whatever user typed in
|
||||
|
@ -24,6 +24,7 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
||||
mutate,
|
||||
} = useSWR<ICurrentUserResponse>(CURRENT_USER, () => userService.currentUser(), {
|
||||
refreshInterval: 0,
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -69,12 +69,13 @@ const Analytics = () => {
|
||||
useEffect(() => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
trackEventServices.trackAnalyticsEvent(
|
||||
{ workspaceSlug: workspaceSlug?.toString() },
|
||||
"WORKSPACE_SCOPE_AND_DEMAND_ANALYTICS",
|
||||
user
|
||||
);
|
||||
}, [workspaceSlug]);
|
||||
if (user && workspaceSlug)
|
||||
trackEventServices.trackAnalyticsEvent(
|
||||
{ workspaceSlug: workspaceSlug?.toString() },
|
||||
"WORKSPACE_SCOPE_AND_DEMAND_ANALYTICS",
|
||||
user
|
||||
);
|
||||
}, [user, workspaceSlug]);
|
||||
|
||||
return (
|
||||
<WorkspaceAuthorizationLayout
|
||||
|
@ -30,22 +30,24 @@ const HomePage: NextPage = () => {
|
||||
const handleGoogleSignIn = async ({ clientId, credential }: any) => {
|
||||
try {
|
||||
if (clientId && credential) {
|
||||
mutateUser(
|
||||
await authenticationService.socialAuth({
|
||||
medium: "google",
|
||||
credential,
|
||||
clientId,
|
||||
})
|
||||
);
|
||||
const socialAuthPayload = {
|
||||
medium: "google",
|
||||
credential,
|
||||
clientId,
|
||||
};
|
||||
const response = await authenticationService.socialAuth(socialAuthPayload);
|
||||
if (response && response?.user) mutateUser();
|
||||
} else {
|
||||
throw Error("Cant find credentials");
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message: "Something went wrong. Please try again later or contact the support team.",
|
||||
message:
|
||||
error?.error ||
|
||||
"Something went wrong. Please try again later or contact the support team.",
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -53,37 +55,54 @@ const HomePage: NextPage = () => {
|
||||
const handleGithubSignIn = async (credential: string) => {
|
||||
try {
|
||||
if (process.env.NEXT_PUBLIC_GITHUB_ID && credential) {
|
||||
mutateUser(
|
||||
await authenticationService.socialAuth({
|
||||
medium: "github",
|
||||
credential,
|
||||
clientId: process.env.NEXT_PUBLIC_GITHUB_ID,
|
||||
})
|
||||
);
|
||||
const socialAuthPayload = {
|
||||
medium: "github",
|
||||
credential,
|
||||
clientId: process.env.NEXT_PUBLIC_GITHUB_ID,
|
||||
};
|
||||
const response = await authenticationService.socialAuth(socialAuthPayload);
|
||||
if (response && response?.user) mutateUser();
|
||||
} else {
|
||||
throw Error("Cant find credentials");
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message: "Something went wrong. Please try again later or contact the support team.",
|
||||
message:
|
||||
error?.error ||
|
||||
"Something went wrong. Please try again later or contact the support team.",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleEmailPasswordSignIn = async (response: any) => {
|
||||
try {
|
||||
if (response) {
|
||||
mutateUser();
|
||||
}
|
||||
} catch (error) {
|
||||
if (response) mutateUser();
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message: "Something went wrong. Please try again later or contact the support team.",
|
||||
message:
|
||||
error?.error ||
|
||||
"Something went wrong. Please try again later or contact the support team.",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleEmailCodeSignIn = async (response: any) => {
|
||||
try {
|
||||
if (response) mutateUser();
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message:
|
||||
error?.error ||
|
||||
"Something went wrong. Please try again later or contact the support team.",
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -91,8 +110,11 @@ const HomePage: NextPage = () => {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
{isLoading ? (
|
||||
<div className="grid h-screen place-items-center">
|
||||
<Spinner />
|
||||
<div className="flex flex-col gap-3 w-full h-screen justify-center items-center">
|
||||
<div>
|
||||
<Spinner />
|
||||
</div>
|
||||
{/* <div className="text-gray-500">Validating authentication</div> */}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex h-screen w-full items-center justify-center overflow-auto">
|
||||
@ -108,16 +130,14 @@ const HomePage: NextPage = () => {
|
||||
<div className="flex flex-col rounded-[10px] bg-brand-base shadow-md">
|
||||
{parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? (
|
||||
<>
|
||||
<EmailCodeForm />
|
||||
<EmailCodeForm handleSignIn={handleEmailCodeSignIn} />
|
||||
<div className="flex flex-col items-center justify-center gap-3 border-t border-brand-base py-5 px-5">
|
||||
<GoogleLoginButton handleSignIn={handleGoogleSignIn} />
|
||||
<GithubLoginButton handleSignIn={handleGithubSignIn} />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<EmailPasswordForm handleSignIn={handleEmailPasswordSignIn} />
|
||||
</>
|
||||
<EmailPasswordForm handleSignIn={handleEmailPasswordSignIn} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,67 +1,63 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
|
||||
// next imports
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import { mutate } from "swr";
|
||||
|
||||
// layouts
|
||||
import DefaultLayout from "layouts/default-layout";
|
||||
// services
|
||||
import authenticationService from "services/authentication.service";
|
||||
// hooks
|
||||
import useUser from "hooks/use-user";
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
import useToast from "hooks/use-toast";
|
||||
// types
|
||||
import type { NextPage } from "next";
|
||||
// constants
|
||||
import { USER_WORKSPACES } from "constants/fetch-keys";
|
||||
|
||||
const MagicSignIn: NextPage = () => {
|
||||
const router = useRouter();
|
||||
|
||||
const [isSigningIn, setIsSigningIn] = useState(true);
|
||||
const [errorSigningIn, setErrorSignIn] = useState<string | undefined>();
|
||||
|
||||
const { password, key } = router.query;
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const { mutateUser } = useUser();
|
||||
const { user, isLoading, mutateUser } = useUserAuth("sign-in");
|
||||
|
||||
const [isSigningIn, setIsSigningIn] = useState(false);
|
||||
const [errorSigningIn, setErrorSignIn] = useState<string | undefined>();
|
||||
|
||||
useEffect(() => {
|
||||
setIsSigningIn(true);
|
||||
setErrorSignIn(undefined);
|
||||
if (!password || !key) return;
|
||||
authenticationService
|
||||
.magicSignIn({ token: password, key })
|
||||
.then(async (res) => {
|
||||
setIsSigningIn(false);
|
||||
await mutateUser();
|
||||
mutate(USER_WORKSPACES);
|
||||
if (res.user.is_onboarded) router.push("/");
|
||||
else router.push("/invitations");
|
||||
})
|
||||
.catch((err) => {
|
||||
setErrorSignIn(err.response.data.error);
|
||||
setIsSigningIn(false);
|
||||
});
|
||||
setIsSigningIn(() => false);
|
||||
setErrorSignIn(() => undefined);
|
||||
if (!password || !key) {
|
||||
setErrorSignIn("URL is invalid");
|
||||
return;
|
||||
} else {
|
||||
setIsSigningIn(() => true);
|
||||
authenticationService
|
||||
.magicSignIn({ token: password, key })
|
||||
.then(async (res) => {
|
||||
setIsSigningIn(false);
|
||||
await mutateUser();
|
||||
})
|
||||
.catch((err) => {
|
||||
setErrorSignIn(err.response.data.error);
|
||||
setIsSigningIn(false);
|
||||
});
|
||||
}
|
||||
}, [password, key, mutateUser, router]);
|
||||
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<div className="h-screen w-full overflow-auto bg-brand-surface-1">
|
||||
{isSigningIn ? (
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-y-2">
|
||||
<h2 className="text-4xl">Signing you in...</h2>
|
||||
<p className="text-sm text-brand-secondary">
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-3">
|
||||
<h2 className="text-4xl font-medium">Signing you in...</h2>
|
||||
<p className="text-sm font-medium text-brand-secondary">
|
||||
Please wait while we are preparing your take off.
|
||||
</p>
|
||||
</div>
|
||||
) : errorSigningIn ? (
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-y-2">
|
||||
<h2 className="text-4xl">Error</h2>
|
||||
<p className="text-sm text-brand-secondary">
|
||||
{errorSigningIn}.
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-3">
|
||||
<h2 className="text-4xl font-medium">Error</h2>
|
||||
<div className="text-sm font-medium text-brand-secondary flex gap-2">
|
||||
<div>{errorSigningIn}.</div>
|
||||
<span
|
||||
className="cursor-pointer underline"
|
||||
onClick={() => {
|
||||
@ -85,12 +81,14 @@ const MagicSignIn: NextPage = () => {
|
||||
>
|
||||
Send link again?
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-y-2">
|
||||
<h2 className="text-4xl">Success</h2>
|
||||
<p className="text-sm text-brand-secondary">Redirecting you to the app...</p>
|
||||
<h2 className="text-4xl font-medium">Success</h2>
|
||||
<p className="text-sm font-medium text-brand-secondary">
|
||||
Redirecting you to the app...
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -1,10 +1,6 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import Image from "next/image";
|
||||
import Router, { useRouter } from "next/router";
|
||||
|
||||
import { mutate } from "swr";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
// next imports
|
||||
import Router from "next/router";
|
||||
// services
|
||||
import userService from "services/user.service";
|
||||
import workspaceService from "services/workspace.service";
|
||||
@ -12,7 +8,6 @@ import workspaceService from "services/workspace.service";
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
// layouts
|
||||
import DefaultLayout from "layouts/default-layout";
|
||||
import { UserAuthorizationLayout } from "layouts/auth-layout/user-authorization-wrapper";
|
||||
// components
|
||||
import {
|
||||
InviteMembers,
|
||||
@ -27,136 +22,114 @@ import { PrimaryButton, Spinner } from "components/ui";
|
||||
import { ONBOARDING_CARDS } from "constants/workspace";
|
||||
// types
|
||||
import type { NextPage } from "next";
|
||||
import { ICurrentUserResponse } from "types";
|
||||
// fetch-keys
|
||||
import { CURRENT_USER } from "constants/fetch-keys";
|
||||
|
||||
const Onboarding: NextPage = () => {
|
||||
const [step, setStep] = useState(1);
|
||||
const [step, setStep] = useState<null | number>(null);
|
||||
const [userRole, setUserRole] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [workspace, setWorkspace] = useState();
|
||||
|
||||
const router = useRouter();
|
||||
const { user, isLoading: userLoading, mutateUser } = useUserAuth("onboarding");
|
||||
|
||||
const { user, mutateUser } = useUserAuth("onboarding");
|
||||
useEffect(() => {
|
||||
if (user && step === null) {
|
||||
let currentStep: number = 1;
|
||||
if (user?.role) currentStep = 2;
|
||||
if (user?.last_workspace_id) currentStep = 4;
|
||||
setStep(() => currentStep);
|
||||
}
|
||||
}, [step, user]);
|
||||
|
||||
return (
|
||||
<UserAuthorizationLayout>
|
||||
<DefaultLayout>
|
||||
{isLoading ? (
|
||||
<div className="grid h-screen place-items-center">
|
||||
<Spinner />
|
||||
</div>
|
||||
) : (
|
||||
<div className="relative grid h-full place-items-center p-5">
|
||||
{step <= 3 ? (
|
||||
<div className="h-full flex flex-col justify-center w-full py-4">
|
||||
<div className="mb-7 flex items-center justify-center text-center">
|
||||
<OnboardingLogo className="h-12 w-48 fill-current text-brand-base" />
|
||||
</div>
|
||||
{step === 1 ? (
|
||||
<UserDetails user={user} setStep={setStep} setUserRole={setUserRole} />
|
||||
) : step === 2 ? (
|
||||
<Workspace setStep={setStep} setWorkspace={setWorkspace} user={user} />
|
||||
) : (
|
||||
<InviteMembers setStep={setStep} workspace={workspace} user={user} />
|
||||
)}
|
||||
<DefaultLayout>
|
||||
{userLoading || isLoading || step === null ? (
|
||||
<div className="grid h-screen place-items-center">
|
||||
<Spinner />
|
||||
</div>
|
||||
) : (
|
||||
<div className="relative grid h-full place-items-center p-5">
|
||||
{step <= 3 ? (
|
||||
<div className="h-full flex flex-col justify-center w-full py-4">
|
||||
<div className="mb-7 flex items-center justify-center text-center">
|
||||
<OnboardingLogo className="h-12 w-48 fill-current text-brand-base" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full max-w-2xl flex-col gap-12">
|
||||
<div className="flex flex-col items-center justify-center gap-7 rounded-[10px] bg-brand-base pb-7 text-center shadow-md">
|
||||
{step === 4 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.welcome} />
|
||||
) : step === 5 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.issue} gradient />
|
||||
) : step === 6 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.cycle} gradient />
|
||||
) : step === 7 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.module} gradient />
|
||||
) : (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.commandMenu} />
|
||||
)}
|
||||
<div className="mx-auto flex h-1/4 items-end lg:w-1/2">
|
||||
<PrimaryButton
|
||||
type="button"
|
||||
className="flex w-full items-center justify-center text-center "
|
||||
size="md"
|
||||
onClick={() => {
|
||||
if (step === 8) {
|
||||
setIsLoading(true);
|
||||
userService
|
||||
.updateUserOnBoard({ userRole }, user)
|
||||
.then(async () => {
|
||||
mutate<ICurrentUserResponse>(
|
||||
CURRENT_USER,
|
||||
(prevData) => {
|
||||
if (!prevData) return prevData;
|
||||
{step === 1 ? (
|
||||
<UserDetails user={user} setStep={setStep} setUserRole={setUserRole} />
|
||||
) : step === 2 ? (
|
||||
<Workspace setStep={setStep} setWorkspace={setWorkspace} user={user} />
|
||||
) : (
|
||||
step === 3 && <InviteMembers setStep={setStep} workspace={workspace} user={user} />
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full max-w-2xl flex-col gap-12">
|
||||
<div className="flex flex-col items-center justify-center gap-7 rounded-[10px] bg-brand-base pb-7 text-center shadow-md">
|
||||
{step === 4 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.welcome} />
|
||||
) : step === 5 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.issue} gradient />
|
||||
) : step === 6 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.cycle} gradient />
|
||||
) : step === 7 ? (
|
||||
<OnboardingCard data={ONBOARDING_CARDS.module} gradient />
|
||||
) : (
|
||||
step === 8 && <OnboardingCard data={ONBOARDING_CARDS.commandMenu} />
|
||||
)}
|
||||
<div className="mx-auto flex h-1/4 items-end lg:w-1/2">
|
||||
<PrimaryButton
|
||||
type="button"
|
||||
className="flex w-full items-center justify-center text-center "
|
||||
size="md"
|
||||
onClick={() => {
|
||||
if (step === 8) {
|
||||
setIsLoading(true);
|
||||
userService
|
||||
.updateUserOnBoard({ userRole }, user)
|
||||
.then(async () => {
|
||||
mutateUser();
|
||||
const userWorkspaces = await workspaceService.userWorkspaces();
|
||||
|
||||
return {
|
||||
...prevData,
|
||||
user: {
|
||||
...prevData.user,
|
||||
is_onboarded: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
false
|
||||
);
|
||||
const userWorkspaces = await workspaceService.userWorkspaces();
|
||||
const lastActiveWorkspace =
|
||||
userWorkspaces.find(
|
||||
(workspace) => workspace.id === user?.last_workspace_id
|
||||
) ?? userWorkspaces[0];
|
||||
|
||||
const lastActiveWorkspace =
|
||||
userWorkspaces.find(
|
||||
(workspace) => workspace.id === user?.last_workspace_id
|
||||
) ?? userWorkspaces[0];
|
||||
|
||||
if (lastActiveWorkspace) {
|
||||
userService
|
||||
.updateUser({
|
||||
last_workspace_id: lastActiveWorkspace.id,
|
||||
})
|
||||
.then((res) => {
|
||||
mutateUser();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
Router.push(`/${lastActiveWorkspace.slug}`);
|
||||
if (lastActiveWorkspace) {
|
||||
mutateUser();
|
||||
Router.push(`/${lastActiveWorkspace.slug}`);
|
||||
return;
|
||||
} else {
|
||||
const invitations = await workspaceService.userWorkspaceInvitations();
|
||||
if (invitations.length > 0) {
|
||||
Router.push(`/invitations`);
|
||||
return;
|
||||
} else {
|
||||
const invitations =
|
||||
await workspaceService.userWorkspaceInvitations();
|
||||
if (invitations.length > 0) {
|
||||
Router.push(`/invitations`);
|
||||
return;
|
||||
} else {
|
||||
Router.push(`/create-workspace`);
|
||||
return;
|
||||
}
|
||||
Router.push(`/create-workspace`);
|
||||
return;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
setIsLoading(false);
|
||||
console.log(err);
|
||||
});
|
||||
} else setStep((prevData) => prevData + 1);
|
||||
}}
|
||||
>
|
||||
{step === 4 || step === 8 ? "Get Started" : "Next"}
|
||||
</PrimaryButton>
|
||||
</div>
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
setIsLoading(false);
|
||||
console.log(err);
|
||||
});
|
||||
} else setStep((prevData) => (prevData != null ? prevData + 1 : prevData));
|
||||
}}
|
||||
>
|
||||
{step === 4 || step === 8 ? "Get Started" : "Next"}
|
||||
</PrimaryButton>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute flex flex-col gap-1 justify-center items-start left-5 top-5">
|
||||
<span className="text-xs text-brand-secondary">Logged in:</span>
|
||||
<span className="text-sm text-brand-base">{user?.email}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute flex flex-col gap-1 justify-center items-start left-5 top-5">
|
||||
<span className="text-xs text-brand-secondary">Logged in:</span>
|
||||
<span className="text-sm text-brand-base">{user?.email}</span>
|
||||
</div>
|
||||
)}
|
||||
</DefaultLayout>
|
||||
</UserAuthorizationLayout>
|
||||
</div>
|
||||
)}
|
||||
</DefaultLayout>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,12 @@ import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const unAuthorizedStatus = [401];
|
||||
const nonValidatedRoutes = ["/", "/reset-password", "/workspace-member-invitation"];
|
||||
const nonValidatedRoutes = [
|
||||
"/",
|
||||
"/magic-sign-in",
|
||||
"/reset-password",
|
||||
"/workspace-member-invitation",
|
||||
];
|
||||
|
||||
const validateRouteCheck = (route: string): boolean => {
|
||||
let validationToggle = false;
|
||||
|
Loading…
Reference in New Issue
Block a user