A full-featured CRM built with React, shadcn/ui, and Supabase.
Redirect to access denied instead of showing blank page
fzaninottofa2064bcf5f7
diff --git a/src/components/admin/access-denied.tsx b/src/components/admin/access-denied.tsxnew file mode 100644index 00000000..0c52629c--- /dev/null+++ b/src/components/admin/access-denied.tsx@@ -0,0 +1,19 @@+import { Lock } from "lucide-react";+import { Translate } from "ra-core";++/**+ * Page displayed when the current user doesn't have the permissions to access a page.+ *+ * Used by default by `<Admin accessDenied>`, and can be passed to `<CanAccess accessDenied>`.+ */+export const AccessDenied = () => (+ <div className="flex min-h-[50vh] flex-1 flex-col items-center justify-center gap-2 text-center">+ <Lock className="h-16 w-16 text-muted-foreground" />+ <h1 className="text-2xl font-semibold">+ <Translate i18nKey="ra.page.access_denied" />+ </h1>+ <p className="max-w-xl text-muted-foreground">+ <Translate i18nKey="ra.message.access_denied" />+ </p>+ </div>+);diff --git a/src/components/admin/admin.tsx b/src/components/admin/admin.tsxindex a5814545..038f6c39 100644--- a/src/components/admin/admin.tsx+++ b/src/components/admin/admin.tsx@@ -7,6 +7,7 @@ import {localStorageStore,} from "ra-core";import { i18nProvider as defaultI18nProvider } from "@/lib/i18nProvider";+import { AccessDenied } from "@/components/admin/access-denied";import { Layout } from "@/components/admin/layout";import { LoginPage } from "@/components/admin/login-page";import { NotFound } from "@/components/admin/not-found";@@ -101,7 +102,7 @@ const AdminUI = (props: CoreAdminUIProps) => {*/export const Admin = (props: CoreAdminProps) => {const {- accessDenied,+ accessDenied = AccessDenied,authCallbackPage = AuthCallback,authenticationError,authProvider,diff --git a/src/components/admin/index.ts b/src/components/admin/index.tsindex a46c9e3e..f4fc76df 100644--- a/src/components/admin/index.ts+++ b/src/components/admin/index.ts@@ -1,3 +1,4 @@+export * from "./access-denied";export * from "./admin";export * from "./app-sidebar";export * from "./array-field";diff --git a/src/components/atomic-crm/sales/SalesCreate.tsx b/src/components/atomic-crm/sales/SalesCreate.tsxindex 6f6f487c..f16021ac 100644--- a/src/components/atomic-crm/sales/SalesCreate.tsx+++ b/src/components/atomic-crm/sales/SalesCreate.tsx@@ -1,6 +1,7 @@import { useMutation } from "@tanstack/react-query";import {CanAccess,+ Navigate,useDataProvider,useNotify,useRedirect,@@ -50,7 +51,11 @@ export function SalesCreate() {};return (- <CanAccess resource="sales" action="create">+ <CanAccess+ resource="sales"+ action="create"+ accessDenied={<Navigate to="/access-denied" />}+ ><div className="max-w-lg w-full mx-auto mt-8"><Card><CardHeader>