diff --git a/web/src/pages/SignIn.tsx b/web/src/pages/SignIn.tsx
index a106f3f..fe394dd 100644
--- a/web/src/pages/SignIn.tsx
+++ b/web/src/pages/SignIn.tsx
@@ -4,11 +4,15 @@ import { Link, useNavigate } from "react-router-dom";
import { toast } from "react-hot-toast";
import * as api from "../helpers/api";
import { userService } from "../services";
+import { useAppSelector } from "../stores";
import useLoading from "../hooks/useLoading";
import Icon from "../components/Icon";
const SignIn: React.FC = () => {
const navigate = useNavigate();
+ const {
+ workspaceProfile: { disallowSignUp },
+ } = useAppSelector((state) => state.global);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const actionBtnLoadingState = useLoading(false);
@@ -91,12 +95,14 @@ const SignIn: React.FC = () => {
-
- {"Don't have an account yet?"}
-
- Sign up
-
-
+ {!disallowSignUp && (
+
+ {"Don't have an account yet?"}
+
+ Sign up
+
+
+ )}
diff --git a/web/src/routers/index.tsx b/web/src/routers/index.tsx
index 2c0df29..0eb114e 100644
--- a/web/src/routers/index.tsx
+++ b/web/src/routers/index.tsx
@@ -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: ,
+ loader: async () => {
+ try {
+ await globalService.initialState();
+ } catch (error) {
+ // do nth
+ }
+
+ return null;
+ },
},
{
path: "/auth/signup",
element: ,
+ loader: async () => {
+ try {
+ await globalService.initialState();
+ } catch (error) {
+ // do nth
+ }
+
+ const {
+ workspaceProfile: { disallowSignUp },
+ } = globalService.getState();
+ if (disallowSignUp) {
+ return redirect("/auth");
+ }
+
+ return null;
+ },
},
{
path: "/",
diff --git a/web/src/services/globalService.ts b/web/src/services/globalService.ts
index 0a5694b..245655a 100644
--- a/web/src/services/globalService.ts
+++ b/web/src/services/globalService.ts
@@ -1,3 +1,4 @@
+import * as api from "../helpers/api";
import store from "../stores";
import { setGlobalState } from "../stores/modules/global";
import userService from "./userService";
@@ -8,15 +9,18 @@ const globalService = {
},
initialState: async () => {
- const defaultGlobalState = {};
-
try {
await userService.initialState();
} catch (error) {
// do nth
}
- store.dispatch(setGlobalState(defaultGlobalState));
+ try {
+ const workspaceProfile = (await api.getWorkspaceProfile()).data;
+ store.dispatch(setGlobalState({ workspaceProfile }));
+ } catch (error) {
+ // do nth
+ }
},
};
diff --git a/web/src/stores/modules/global.ts b/web/src/stores/modules/global.ts
index 7689ffc..2b889b6 100644
--- a/web/src/stores/modules/global.ts
+++ b/web/src/stores/modules/global.ts
@@ -1,7 +1,7 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
type State = {
- // do nth
+ workspaceProfile: WorkspaceProfile;
};
const globalSlice = createSlice({