mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-13 00:02:30 +10:00
updates and fixes
* seo friendly urls * custom client serve-static module * database fixes * fix recent pages * other fixes
This commit is contained in:
@ -1,10 +1,18 @@
|
||||
import { useState } from "react";
|
||||
import { login, register } from "@/features/auth/services/auth-service";
|
||||
import {
|
||||
login,
|
||||
register,
|
||||
setupWorkspace,
|
||||
} from "@/features/auth/services/auth-service";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAtom } from "jotai";
|
||||
import { authTokensAtom } from "@/features/auth/atoms/auth-tokens-atom";
|
||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
||||
import { ILogin, IRegister } from "@/features/auth/types/auth.types";
|
||||
import {
|
||||
ILogin,
|
||||
IRegister,
|
||||
ISetupWorkspace,
|
||||
} from "@/features/auth/types/auth.types";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { IAcceptInvite } from "@/features/workspace/types/workspace.types.ts";
|
||||
import { acceptInvitation } from "@/features/workspace/services/workspace-service.ts";
|
||||
@ -76,6 +84,25 @@ export default function useAuth() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSetupWorkspace = async (data: ISetupWorkspace) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const res = await setupWorkspace(data);
|
||||
setIsLoading(false);
|
||||
|
||||
setAuthToken(res.tokens);
|
||||
|
||||
navigate("/home");
|
||||
} catch (err) {
|
||||
setIsLoading(false);
|
||||
notifications.show({
|
||||
message: err.response?.data.message,
|
||||
color: "red",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleIsAuthenticated = async () => {
|
||||
if (!authToken) {
|
||||
return false;
|
||||
@ -109,6 +136,7 @@ export default function useAuth() {
|
||||
signIn: handleSignIn,
|
||||
signUp: handleSignUp,
|
||||
invitationSignup: handleInvitationSignUp,
|
||||
setupWorkspace: handleSetupWorkspace,
|
||||
isAuthenticated: handleIsAuthenticated,
|
||||
logout: handleLogout,
|
||||
hasTokens,
|
||||
|
||||
Reference in New Issue
Block a user