diff --git a/app/chat/[id]/layout.tsx b/app/chat/[id]/layout.tsx
index 8a64125..59b3e6c 100644
--- a/app/chat/[id]/layout.tsx
+++ b/app/chat/[id]/layout.tsx
@@ -3,7 +3,7 @@ import { ChatProvider } from "@/components/chat/context";
import { Header } from "@/components/chat/header";
import { ShareConversation } from "@/components/chat/share";
import { ChatUsersPermissionsList } from "@/components/chat/share/users-permissions-list";
-import { UnauthorizedError } from "@/components/fga/unauthorized";
+import { ErrorContainer } from "@/components/fga/error";
import { getHistoryFromStore } from "@/llm/actions/history";
import { getUser, withFGA } from "@/sdk/fga";
import { assignChatReader, isChatOwner, isUserInvitedToChat } from "@/sdk/fga/chats";
@@ -66,10 +66,8 @@ export default withCheckPermission(
},
onUnauthorized: ({ params }: RootChatParams) => (
-
-
- The conversation does not exist or you are not authorized to access it.
-
+
+
),
},
diff --git a/app/report/[id]/page.tsx b/app/report/[id]/page.tsx
index b4935d1..5b5381a 100644
--- a/app/report/[id]/page.tsx
+++ b/app/report/[id]/page.tsx
@@ -2,7 +2,7 @@
import Markdown from "react-markdown";
-import { UnauthorizedError } from "@/components/fga/unauthorized";
+import { ErrorContainer } from "@/components/fga/error";
import { documents } from "@/lib/db";
import { withFGA } from "@/sdk/fga";
import { withCheckPermission } from "@/sdk/fga/next/with-check-permission";
@@ -38,7 +38,7 @@ export default withCheckPermission(
relation: "can_view",
}),
onUnauthorized: async () => {
- return You are not authorized to view this document.;
+ return ;
},
},
Report
diff --git a/components/fga/error.tsx b/components/fga/error.tsx
new file mode 100644
index 0000000..24a4ac5
--- /dev/null
+++ b/components/fga/error.tsx
@@ -0,0 +1,82 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+
+import { SimplePlusIcon } from "../icons";
+import { Button } from "../ui/button";
+
+const DottedContainer = ({ children }: { children: React.ReactNode }) => (
+
{children}
+);
+
+const UnautorizedIcon = () => {
+ return (
+
+ );
+};
+
+export function ErrorContainer({
+ title,
+ message,
+ icon,
+ action,
+}: {
+ title?: string;
+ message?: string;
+ icon?: React.ReactNode;
+ action?: {
+ label: string;
+ onClick: () => void;
+ icon?: React.ReactNode;
+ className?: string;
+ };
+}) {
+ const finalAction =
+ action !== undefined
+ ? action
+ : {
+ label: "Create New Chat",
+ onClick: () => (window.location.href = "/"),
+ icon: ,
+ className: "",
+ };
+ return (
+
+
+
+
+
{icon || }
+
{title || "Not Authorized"}
+
+ {message || "You are not authorized to access the requested information."}
+
+
+ {finalAction && (
+
+ )}
+
+
+
+ );
+}
diff --git a/components/fga/unauthorized.tsx b/components/fga/unauthorized.tsx
deleted file mode 100644
index 1069e79..0000000
--- a/components/fga/unauthorized.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-export function UnauthorizedError({ children }: { children?: React.ReactNode }) {
- // TODO: improve UI for this error
- return (
-
-
-
-
- {children || "You are not authorized to access the requested information."}
-
-
-
-
- );
-}