Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Hide error notification in contact show mobile view

fzaninottoc5ffcafdeaeb
diff --git a/src/components/atomic-crm/contacts/ContactShow.tsx b/src/components/atomic-crm/contacts/ContactShow.tsx
index cc322e90..c3f5baa7 100644
--- a/src/components/atomic-crm/contacts/ContactShow.tsx
+++ b/src/components/atomic-crm/contacts/ContactShow.tsx
@@ -153,6 +153,14 @@ const ContactShowContentMobile = () => {
</div>
}
loading={false}
+ error={false}
+ queryOptions={
+ {
+ onError: () => {
+ /** override to hide notification as error case is handled by NotesIteratorMobile */
+ },
+ } as any // fixme: remove once https://github.com/marmelab/react-admin/pull/11166 is released
+ }
>
<NotesIteratorMobile contactId={record.id} showStatus />
</ReferenceManyField>
diff --git a/src/components/atomic-crm/notes/NotesIteratorMobile.tsx b/src/components/atomic-crm/notes/NotesIteratorMobile.tsx
index d83648d6..f40b9ed3 100644
--- a/src/components/atomic-crm/notes/NotesIteratorMobile.tsx
+++ b/src/components/atomic-crm/notes/NotesIteratorMobile.tsx
@@ -2,8 +2,10 @@ import type { Identifier } from "ra-core";
import { useListContext, useTimeout, WithRecord } from "ra-core";
import { Link } from "react-router";
import { ReferenceField } from "@/components/admin/reference-field";
+import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
+import { RotateCcw } from "lucide-react";
import { RelativeDate } from "../misc/RelativeDate";
import { Status } from "../misc/Status";
@@ -17,7 +19,7 @@ export const NotesIteratorMobile = ({
contactId: Identifier;
showStatus?: boolean;
}) => {
- const { data, error, isPending } = useListContext();
+ const { data, error, isPending, refetch } = useListContext();
const oneSecondHasPassed = useTimeout(1000);
if (isPending) {
if (!oneSecondHasPassed) {
@@ -37,7 +39,25 @@ export const NotesIteratorMobile = ({
</div>
);
}
- if (error) return null;
+ if (error && !data) {
+ return (
+ <div className="p-4">
+ <div className="text-center text-muted-foreground mb-4">
+ Error loading notes
+ </div>
+ <div className="text-center mt-2">
+ <Button
+ onClick={() => {
+ refetch();
+ }}
+ >
+ <RotateCcw />
+ Retry
+ </Button>
+ </div>
+ </div>
+ );
+ }
return (
<div className="divide-y">