⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(review): adding review suggestions
justin029ab81c5e89
diff --git a/apps/web/src/fetchers/invitation/get-pending-invitations.ts b/apps/web/src/fetchers/invitation/get-pending-invitations.tsindex e80b7c596..055729e81 100644--- a/apps/web/src/fetchers/invitation/get-pending-invitations.ts+++ b/apps/web/src/fetchers/invitation/get-pending-invitations.ts@@ -8,8 +8,7 @@ export async function getPendingInvitations(): Promise<const response = await client.invitation.pending.$get();if (!response.ok) {- const error = await response.text();- throw new HttpError(response.status, error || "Failed to get pending invitations");+ throw new HttpError(response.status, "Failed to get pending invitations");}return response.json();diff --git a/apps/web/src/fetchers/task/get-tasks.ts b/apps/web/src/fetchers/task/get-tasks.tsindex b13cb1a1d..b9c3700c0 100644--- a/apps/web/src/fetchers/task/get-tasks.ts+++ b/apps/web/src/fetchers/task/get-tasks.ts@@ -9,8 +9,7 @@ async function getTasks(projectId: string) {});if (!response.ok) {- const error = await response.text();- throw new HttpError(response.status, error);+ throw new HttpError(response.status, "Failed to fetch tasks");}const json = await response.json();diff --git a/apps/web/src/lib/http-error.ts b/apps/web/src/lib/http-error.tsindex 3e8c861de..755deef0f 100644--- a/apps/web/src/lib/http-error.ts+++ b/apps/web/src/lib/http-error.ts@@ -11,3 +11,16 @@ export class HttpError extends Error {export function isUnauthorizedError(error: unknown): boolean {return error instanceof HttpError && error.status === 401;}++// Shared unauthorized redirect for both the React Query error cache and direct+// fetcher calls (e.g. route loaders) that bypass the QueryCache. Stashes the+// current pathname/search/hash so the sign-in page can return the user to+// where they were instead of dropping them on /dashboard.+export function handleUnauthorized(): void {+ const currentPath =+ window.location.pathname + window.location.search + window.location.hash;+ const target = currentPath+ ? `/auth/sign-in?redirect=${encodeURIComponent(currentPath)}`+ : "/auth/sign-in";+ window.location.replace(target);+}diff --git a/apps/web/src/query-client/index.ts b/apps/web/src/query-client/index.tsindex 0c024399a..7e42725f1 100644--- a/apps/web/src/query-client/index.ts+++ b/apps/web/src/query-client/index.ts@@ -1,6 +1,6 @@import * as Sentry from "@sentry/react";import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";-import { isUnauthorizedError } from "@/lib/http-error";+import { handleUnauthorized, isUnauthorizedError } from "@/lib/http-error";// TanStack raises these before any fetcher-level message exists; CORS rejections// from the browser also surface here. Used both to skip auto-retry and to tag@@ -57,7 +57,7 @@ const queryClient = new QueryClient({queryCache: new QueryCache({onError: (error) => {if (isUnauthorizedError(error)) {- window.location.replace("/auth/sign-in");+ handleUnauthorized();return;}captureCacheError(error, "query");diff --git a/apps/web/src/routes/_layout/_authenticated.tsx b/apps/web/src/routes/_layout/_authenticated.tsxindex 496baa155..d49ff31f3 100644--- a/apps/web/src/routes/_layout/_authenticated.tsx+++ b/apps/web/src/routes/_layout/_authenticated.tsx@@ -20,7 +20,7 @@ export const Route = createFileRoute("/_layout/_authenticated")({throw redirect({to: "/auth/sign-in",search: {- redirect: location.href,+ redirect: location.pathname + location.search + location.hash,},});}diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/index.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/index.tsxindex 493222426..2167ddc3d 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/index.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/index.tsx@@ -2,12 +2,23 @@ import { createFileRoute, redirect } from "@tanstack/react-router";import { getPendingInvitations } from "@/fetchers/invitation/get-pending-invitations";import getWorkspaces from "@/fetchers/workspace/get-workspaces";import { authClient } from "@/lib/auth-client";+import { handleUnauthorized, isUnauthorizedError } from "@/lib/http-error";import type Workspace from "@/types/workspace";export const Route = createFileRoute("/_layout/_authenticated/dashboard/")({beforeLoad: async () => {- const workspaces: Workspace[] = await getWorkspaces();- const invitations = await getPendingInvitations();+ let workspaces: Workspace[];+ let invitations: Awaited<ReturnType<typeof getPendingInvitations>>;+ try {+ workspaces = await getWorkspaces();+ invitations = await getPendingInvitations();+ } catch (error) {+ if (isUnauthorizedError(error)) {+ handleUnauthorized();+ return;+ }+ throw error;+ }if (invitations && invitations.length > 0 && !workspaces.length) {throw redirect({ to: "/invitations" });