chore: hide sign up button when disabled

This commit is contained in:
Steven
2023-06-26 22:35:12 +08:00
parent d46df916cf
commit 106cdfa7da
4 changed files with 46 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import { createBrowserRouter, redirect } from "react-router-dom";
import { isNullorUndefined } from "../helpers/utils";
import { userService } from "../services";
import { globalService, userService } from "../services";
import Root from "../layouts/Root";
import SignIn from "../pages/SignIn";
import SignUp from "../pages/SignUp";
@ -11,10 +11,35 @@ const router = createBrowserRouter([
{
path: "/auth",
element: <SignIn />,
loader: async () => {
try {
await globalService.initialState();
} catch (error) {
// do nth
}
return null;
},
},
{
path: "/auth/signup",
element: <SignUp />,
loader: async () => {
try {
await globalService.initialState();
} catch (error) {
// do nth
}
const {
workspaceProfile: { disallowSignUp },
} = globalService.getState();
if (disallowSignUp) {
return redirect("/auth");
}
return null;
},
},
{
path: "/",