Skip to content

Commit

Permalink
Refactor Layout to conditionally render ModalAccount based on custom…
Browse files Browse the repository at this point in the history
…er first name
  • Loading branch information
jamalsoueidan committed Jul 7, 2024
1 parent 66a3aae commit 6b26581
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,30 @@ export function Layout({children}: {children: ReactNode}) {
<body>
<DirectionProvider detectDirection>
<MantineProvider>
<ModalAccount customer={data?.customer} />
<NavigationProgress />
<ModalsProvider>
{!path.includes('/book/') && data?.cart ? (
<Analytics.Provider
cart={data.cart}
shop={data.shop}
consent={data.consent}
customData={{foo: 'bar'}}
>
<LayoutWrapper>{children}</LayoutWrapper>
<CustomAnalytics />
</Analytics.Provider>
) : (
children
)}
<LanguageDetector />
</ModalsProvider>
{data.customer && !data.customer.customer.firstName ? (
<ModalAccount customer={data?.customer} />
) : (
<>
<NavigationProgress />
<ModalsProvider>
{!path.includes('/book/') &&
!path.includes('/account/business') ? (
<Analytics.Provider
cart={data.cart}
shop={data.shop}
consent={data.consent}
customData={{foo: 'bar'}}
>
<LayoutWrapper>{children}</LayoutWrapper>
<CustomAnalytics />
</Analytics.Provider>
) : (
children
)}
<LanguageDetector />
</ModalsProvider>
</>
)}
</MantineProvider>
</DirectionProvider>
<ScrollRestoration nonce={nonce} />
Expand Down

0 comments on commit 6b26581

Please sign in to comment.