A full-featured CRM built with React, shadcn/ui, and Supabase.
Revert "use a portal in header"
Jean-Baptiste Kaiser69e1966bc023
diff --git a/registry.json b/registry.jsonindex a828eaea..1009e211 100644--- a/registry.json+++ b/registry.json@@ -396,10 +396,6 @@"path": "src/components/atomic-crm/layout/MobileContent.tsx","type": "registry:component"},- {- "path": "src/components/atomic-crm/layout/MobileAppBar.tsx",- "type": "registry:component"- },{"path": "src/components/atomic-crm/layout/Layout.tsx","type": "registry:component"diff --git a/src/components/atomic-crm/companies/CompanyList.tsx b/src/components/atomic-crm/companies/CompanyList.tsxindex 459fc024..7e2a8664 100644--- a/src/components/atomic-crm/companies/CompanyList.tsx+++ b/src/components/atomic-crm/companies/CompanyList.tsx@@ -6,8 +6,9 @@ import { SortButton } from "@/components/admin/sort-button";import { InfiniteListBase, useGetIdentity, useListContext } from "ra-core";import { useIsMobile } from "@/hooks/use-mobile";+import { MobileContent } from "../layout/MobileContent";+import MobileHeader from "../layout/MobileHeader";import { TopToolbar } from "../layout/TopToolbar";-import { MobileHeader } from "../layout/MobileHeader";import { InfinitePagination } from "../misc/InfinitePagination";import { CompanyEmpty } from "./CompanyEmpty";import { CompanyListFilter } from "./CompanyListFilter";@@ -44,9 +45,6 @@ const CompanyListMobile = () => {return (<InfiniteListBase perPage={25} sort={{ field: "name", order: "ASC" }}><MobileCompanyListLayout />- <div className="flex justify-center">- <InfinitePagination />- </div></InfiniteListBase>);};@@ -78,12 +76,17 @@ const MobileCompanyListLayout = () => {if (!data?.length && !hasFilters) return <CompanyEmpty />;return (- <>+ <div><MobileHeader><CompanyListFilter /></MobileHeader>+ <MobileContent><ImageList />- </>+ <div className="flex justify-center">+ <InfinitePagination />+ </div>+ </MobileContent>+ </div>);};diff --git a/src/components/atomic-crm/contacts/ContactList.tsx b/src/components/atomic-crm/contacts/ContactList.tsxindex 5e747d5e..445c0969 100644--- a/src/components/atomic-crm/contacts/ContactList.tsx+++ b/src/components/atomic-crm/contacts/ContactList.tsx@@ -21,7 +21,8 @@ import { ContactListFilter } from "./ContactListFilter";import { TopToolbar } from "../layout/TopToolbar";import { useIsMobile } from "@/hooks/use-mobile";import { InfinitePagination } from "../misc/InfinitePagination";-import { MobileHeader } from "../layout/MobileHeader";+import MobileHeader from "../layout/MobileHeader";+import { MobileContent } from "../layout/MobileContent";export const ContactList = () => {const isMobile = useIsMobile();@@ -58,9 +59,6 @@ const ContactListMobile = () => {exporter={exporter}><MobileContactListLayout />- <div className="flex justify-center">- <InfinitePagination />- </div></InfiniteListBase>);};@@ -97,14 +95,19 @@ const MobileContactListLayout = () => {if (!data?.length && !hasFilters) return <ContactEmpty />;return (- <>+ <div><MobileHeader><ContactListFilter /></MobileHeader>- <Card className="py-0">- <ContactListContent />- </Card>- </>+ <MobileContent>+ <Card className="py-0">+ <ContactListContent />+ </Card>+ <div className="flex justify-center">+ <InfinitePagination />+ </div>+ </MobileContent>+ </div>);};diff --git a/src/components/atomic-crm/dashboard/MobileDashboard.tsx b/src/components/atomic-crm/dashboard/MobileDashboard.tsxindex 141e6d0f..11016a34 100644--- a/src/components/atomic-crm/dashboard/MobileDashboard.tsx+++ b/src/components/atomic-crm/dashboard/MobileDashboard.tsx@@ -1,10 +1,36 @@import { useGetList } from "ra-core";-import { MobileHeader } from "../layout/MobileHeader";import type { Contact, ContactNote } from "../types";import { DashboardActivityLog } from "./DashboardActivityLog";import { DashboardStepper } from "./DashboardStepper";import { Welcome } from "./Welcome";+import MobileHeader from "../layout/MobileHeader";+import { MobileContent } from "../layout/MobileContent";+import { useConfigurationContext } from "../root/ConfigurationContext";++const Wrapper = ({ children }: { children: React.ReactNode }) => {+ const { darkModeLogo, lightModeLogo, title } = useConfigurationContext();+ return (+ <>+ <MobileHeader>+ <div className="flex items-center gap-2 text-secondary-foreground no-underline py-3">+ <img+ className="[.light_&]:hidden h-6"+ src={darkModeLogo}+ alt={title}+ />+ <img+ className="[.dark_&]:hidden h-6"+ src={lightModeLogo}+ alt={title}+ />+ <h1 className="text-xl font-semibold">{title}</h1>+ </div>+ </MobileHeader>+ <MobileContent>{children}</MobileContent>+ </>+ );+};export const MobileDashboard = () => {const {@@ -28,29 +54,26 @@ export const MobileDashboard = () => {if (!totalContact) {return (- <>- <MobileHeader />+ <Wrapper><DashboardStepper step={1} />- </>+ </Wrapper>);}if (!totalContactNotes) {return (- <>- <MobileHeader />+ <Wrapper><DashboardStepper step={2} contactId={dataContact?.[0]?.id} />- </>+ </Wrapper>);}return (- <>- <MobileHeader />+ <Wrapper><div className="grid grid-cols-1 md:grid-cols-12 gap-6 mt-1">{import.meta.env.VITE_IS_DEMO === "true" ? <Welcome /> : null}<DashboardActivityLog /></div>- </>+ </Wrapper>);};diff --git a/src/components/atomic-crm/layout/MobileAppBar.tsx b/src/components/atomic-crm/layout/MobileAppBar.tsxdeleted file mode 100644index 6a71e2ee..00000000--- a/src/components/atomic-crm/layout/MobileAppBar.tsx+++ /dev/null@@ -1,12 +0,0 @@-export const MobileAppBar = () => {- return (- <header className="fixed top-0 left-0 right-0 z-10 bg-secondary h-14 px-4 w-full flex justify-between items-center">- <div- id="atomic-crm-header"- className="w-full flex justify-between items-center"- >- {/* Portal content will be rendered here */}- </div>- </header>- );-};diff --git a/src/components/atomic-crm/layout/MobileHeader.tsx b/src/components/atomic-crm/layout/MobileHeader.tsxindex 3b414091..e300584f 100644--- a/src/components/atomic-crm/layout/MobileHeader.tsx+++ b/src/components/atomic-crm/layout/MobileHeader.tsx@@ -1,21 +1,9 @@-import { type ReactNode } from "react";-import { createPortal } from "react-dom";-import { useConfigurationContext } from "../root/ConfigurationContext";--export const MobileHeader = ({ children }: { children?: ReactNode }) => {- const { darkModeLogo, lightModeLogo, title } = useConfigurationContext();-- const portalTarget = document.getElementById("atomic-crm-header");-- if (!portalTarget) return null;-- const content = children || (- <div className="flex items-center gap-2 text-secondary-foreground no-underline py-3">- <img className="[.light_&]:hidden h-6" src={darkModeLogo} alt={title} />- <img className="[.dark_&]:hidden h-6" src={lightModeLogo} alt={title} />- <h1 className="text-xl font-semibold">{title}</h1>- </div>+const MobileHeader = ({ children }: { children: React.ReactNode }) => {+ return (+ <header className="fixed top-0 left-0 right-0 z-10 bg-secondary h-14 px-4 w-full flex justify-between items-center">+ {children}+ </header>);-- return createPortal(content, portalTarget);};++export default MobileHeader;diff --git a/src/components/atomic-crm/layout/MobileLayout.tsx b/src/components/atomic-crm/layout/MobileLayout.tsxindex 3f9bb2c9..c03ded36 100644--- a/src/components/atomic-crm/layout/MobileLayout.tsx+++ b/src/components/atomic-crm/layout/MobileLayout.tsx@@ -5,19 +5,14 @@ import { Suspense, type ReactNode } from "react";import { ErrorBoundary } from "react-error-boundary";import { MobileNavigation } from "./MobileNavigation";-import { MobileContent } from "./MobileContent";-import { MobileAppBar } from "./MobileAppBar";export const MobileLayout = ({ children }: { children: ReactNode }) => (<>- <MobileAppBar />- <MobileContent>- <ErrorBoundary FallbackComponent={Error}>- <Suspense fallback={<Skeleton className="h-12 w-12 rounded-full" />}>- {children}- </Suspense>- </ErrorBoundary>- </MobileContent>+ <ErrorBoundary FallbackComponent={Error}>+ <Suspense fallback={<Skeleton className="h-12 w-12 rounded-full" />}>+ {children}+ </Suspense>+ </ErrorBoundary><MobileNavigation /><Notification /></>