Skip to content

Commit

Permalink
<WaitForCustomer /> now accepts all props of the FullPageMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
paales committed Jan 30, 2025
1 parent 2a09ca9 commit 623e993
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-olives-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-customer': patch
---

`<WaitForCustomer />` now accepts all props of the FullPageMessage
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { FullPageMessage, iconPerson, IconSvg } from '@graphcommerce/next-ui'
import { Trans } from '@lingui/react'
import { Button, CircularProgress } from '@mui/material'
import React from 'react'
import type { SetOptional } from 'type-fest'
import { useCustomerSession } from '../../hooks/useCustomerSession'
import { ApolloCustomerErrorFullPage } from '../ApolloCustomerError/ApolloCustomerErrorFullPage'

export type WaitForCustomerProps = Omit<WaitForQueriesProps, 'fallback' | 'waitFor'> &
Pick<FullPageMessageProps, 'disableMargin'> & {
waitFor?: WaitForQueriesProps['waitFor']
fallback?: React.ReactNode
export type WaitForCustomerProps = SetOptional<WaitForQueriesProps, 'waitFor'> &
SetOptional<FullPageMessageProps, 'title' | 'icon'> & {
unauthenticated?: React.ReactNode
}

Expand Down Expand Up @@ -42,7 +41,7 @@ export function nonNullable<T>(value: T): value is NonNullable<T> {
* ```
*/
export function WaitForCustomer(props: WaitForCustomerProps) {
const { waitFor = [], children, fallback, unauthenticated, disableMargin } = props
const { waitFor = [], children, fallback, unauthenticated, ...rest } = props

const session = useCustomerSession()
const queries = Array.isArray(waitFor) ? waitFor : [waitFor]
Expand All @@ -58,7 +57,7 @@ export function WaitForCustomer(props: WaitForCustomerProps) {
<FullPageMessage
icon={<CircularProgress />}
title={<Trans id='Loading your data' />}
disableMargin={disableMargin}
{...rest}
>
<Trans id='This may take a second' />
</FullPageMessage>
Expand All @@ -79,7 +78,7 @@ export function WaitForCustomer(props: WaitForCustomerProps) {
)}
</Button>
}
disableMargin={disableMargin}
{...rest}
/>
))}
{session.loggedIn && error && <ApolloCustomerErrorFullPage error={error} />}
Expand Down

0 comments on commit 623e993

Please sign in to comment.