From 723928d678f570a1d1c6d92de7bf73041c1cbcd8 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Thu, 27 Jun 2024 01:43:23 +0100 Subject: [PATCH] fix setup page redirect --- apps/client/src/App.tsx | 2 +- .../src/features/comment/components/comment-dialog.tsx | 5 +---- .../editor/components/bubble-menu/bubble-menu.tsx | 1 - apps/client/src/lib/api-client.ts | 10 +++++++--- apps/client/src/lib/app-route.ts | 1 + 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/client/src/App.tsx b/apps/client/src/App.tsx index 6c243036..f4ac926e 100644 --- a/apps/client/src/App.tsx +++ b/apps/client/src/App.tsx @@ -61,8 +61,8 @@ export default function App() { } /> } /> - } /> } /> + } /> } /> diff --git a/apps/client/src/features/comment/components/comment-dialog.tsx b/apps/client/src/features/comment/components/comment-dialog.tsx index 58b40e26..1a3020fa 100644 --- a/apps/client/src/features/comment/components/comment-dialog.tsx +++ b/apps/client/src/features/comment/components/comment-dialog.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { Avatar, Dialog, Group, Stack, Text } from "@mantine/core"; +import { Dialog, Group, Stack, Text } from "@mantine/core"; import { useClickOutside } from "@mantine/hooks"; import { useAtom } from "jotai"; import { @@ -35,7 +35,6 @@ function CommentDialog({ editor, pageId }: CommentDialogProps) { const handleDialogClose = () => { setShowCommentPopup(false); - // @ts-ignore editor.chain().focus().unsetCommentDecoration().run(); }; @@ -48,7 +47,6 @@ function CommentDialog({ editor, pageId }: CommentDialogProps) { try { const selectedText = getSelectedText(); const commentData = { - id: draftCommentId, pageId: pageId, content: JSON.stringify(comment), selection: selectedText, @@ -58,7 +56,6 @@ function CommentDialog({ editor, pageId }: CommentDialogProps) { await createCommentMutation.mutateAsync(commentData); editor .chain() - // @ts-ignore .setComment(createdComment.id) .unsetCommentDecoration() .run(); diff --git a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx index bfd6406b..9a77e5b5 100644 --- a/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx +++ b/apps/client/src/features/editor/components/bubble-menu/bubble-menu.tsx @@ -86,7 +86,6 @@ export const EditorBubbleMenu: FC = (props) => { command: () => { const commentId = uuidv4(); - // @ts-ignore props.editor.chain().focus().setCommentDecoration().run(); setDraftCommentId(commentId); setShowCommentPopup(true); diff --git a/apps/client/src/lib/api-client.ts b/apps/client/src/lib/api-client.ts index fca1a57f..cdf37ea5 100644 --- a/apps/client/src/lib/api-client.ts +++ b/apps/client/src/lib/api-client.ts @@ -1,10 +1,10 @@ import axios, { AxiosInstance } from "axios"; import Cookies from "js-cookie"; import Routes from "@/lib/app-route.ts"; +import { getBackendUrl } from "@/lib/config.ts"; -const baseUrl = import.meta.env.DEV ? "http://localhost:3000" : ""; const api: AxiosInstance = axios.create({ - baseURL: baseUrl + "/api", + baseURL: getBackendUrl(), }); api.interceptors.request.use( @@ -51,8 +51,12 @@ api.interceptors.response.use( .toLowerCase() .includes("workspace not found") ) { + console.log("workspace not found"); Cookies.remove("authTokens"); - redirectToLogin(); + + if (window.location.pathname != Routes.AUTH.SETUP) { + window.location.href = Routes.AUTH.SETUP; + } } break; case 500: diff --git a/apps/client/src/lib/app-route.ts b/apps/client/src/lib/app-route.ts index 53173c6f..58216832 100644 --- a/apps/client/src/lib/app-route.ts +++ b/apps/client/src/lib/app-route.ts @@ -3,6 +3,7 @@ const APP_ROUTE = { AUTH: { LOGIN: "/login", SIGNUP: "/signup", + SETUP: "/setup/register", }, SETTINGS: { ACCOUNT: {