A full-featured CRM built with React, shadcn/ui, and Supabase.
fix(contacts): use ShowBase error prop for mobile error state, drop retry
erwanMarmelabddaaff5a9c98
diff --git a/src/components/atomic-crm/contacts/ContactShow.test.tsx b/src/components/atomic-crm/contacts/ContactShow.test.tsxindex befd68eb..ccaa40d5 100644--- a/src/components/atomic-crm/contacts/ContactShow.test.tsx+++ b/src/components/atomic-crm/contacts/ContactShow.test.tsx@@ -62,7 +62,7 @@ describe("ContactShow", () => {.toHaveAttribute("aria-selected", "true");});- it("shows an error with a retry button when the contact cannot be loaded", async () => {+ it("shows an error when the contact cannot be loaded", async () => {const screen = await render(<StoryWrapper data={{ contacts: [] }}>{/* An id no other test loads, so no persisted query cache can serve it */}@@ -73,9 +73,6 @@ describe("ContactShow", () => {await expect.element(screen.getByText("Error loading contact")).toBeVisible();- await expect- .element(screen.getByRole("button", { name: "Retry" }))- .toBeVisible();});it("updates the contact status from the aside", async () => {diff --git a/src/components/atomic-crm/contacts/ContactShow.tsx b/src/components/atomic-crm/contacts/ContactShow.tsxindex 96f35723..0470c128 100644--- a/src/components/atomic-crm/contacts/ContactShow.tsx+++ b/src/components/atomic-crm/contacts/ContactShow.tsx@@ -14,7 +14,7 @@ import { Card, CardContent } from "@/components/ui/card";import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";import { Button } from "@/components/ui/button";import { Separator } from "@/components/ui/separator";-import { Pencil, RotateCcw } from "lucide-react";+import { Pencil } from "lucide-react";import { Link, useSearchParams } from "react-router";import MobileHeader from "../layout/MobileHeader";@@ -47,6 +47,8 @@ export const ContactShow = (props: ShowBaseProps = {}) => {}: undefined,}}+ // The error notification is disabled on mobile, so show the error here+ error={isMobile ? <ContactShowErrorMobile /> : undefined}{...props}>{isMobile ? <ContactShowContentMobile /> : <ContactShowContent />}@@ -54,6 +56,22 @@ export const ContactShow = (props: ShowBaseProps = {}) => {);};+const ContactShowErrorMobile = () => {+ const translate = useTranslate();+ return (+ <>+ <MobileHeader>+ <MobileBackButton />+ </MobileHeader>+ <MobileContent>+ <div className="p-4 text-center text-muted-foreground">+ {translate("resources.contacts.show.error_loading")}+ </div>+ </MobileContent>+ </>+ );+};+const MOBILE_TABS = ["notes", "tasks", "details"];const ContactShowContentMobile = () => {@@ -63,34 +81,10 @@ const ContactShowContentMobile = () => {const requestedTab = searchParams.get("tab");const initialTab =requestedTab && MOBILE_TABS.includes(requestedTab) ? requestedTab : "notes";- const { defaultTitle, record, isPending, refetch } =- useShowContext<Contact>();+ const { defaultTitle, record, isPending } = useShowContext<Contact>();const [noteCreateOpen, setNoteCreateOpen] = useState(false);const [editOpen, setEditOpen] = useState(false);- if (isPending) return null;- if (!record) {- // The error notification is disabled on mobile, so show the error here- return (- <>- <MobileHeader>- <MobileBackButton />- </MobileHeader>- <MobileContent>- <div className="p-4">- <div className="text-center text-muted-foreground mb-4">- {translate("resources.contacts.show.error_loading")}- </div>- <div className="text-center mt-2">- <Button onClick={() => refetch()}>- <RotateCcw />- {translate("crm.common.retry")}- </Button>- </div>- </div>- </MobileContent>- </>- );- }+ if (isPending || !record) return null;const taskCount = record.nb_tasks ?? 0;