@graphcommerce/magento-customer 9.1.0-canary.17 → 9.1.0-canary.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/components/AccountAddresses/AccountAddresses.tsx +9 -4
- package/components/AccountDeleteForm/AccountDeleteForm.tsx +14 -4
- package/components/AccountLatestOrder/AccountLatestOrder.tsx +1 -2
- package/components/AccountOrders/AccountOrders.tsx +1 -1
- package/components/CancelOrder/CancelOrderForm.tsx +2 -2
- package/components/CancelOrder/CancelOrderFragment.graphql +5 -0
- package/components/ChangeNameForm/ChangeNameForm.tsx +1 -0
- package/components/ContactForm/ContactUsConfig.graphql +3 -0
- package/components/CreditMemo/CreditMemo.graphql +43 -0
- package/components/CreditMemo/CreditMemoCard.graphql +12 -0
- package/components/CreditMemo/CreditMemoCard.tsx +66 -0
- package/components/CreditMemo/CreditMemoDetails.tsx +94 -0
- package/components/CreditMemo/CreditMemoItem.graphql +26 -0
- package/components/CreditMemo/CreditMemoItem.tsx +125 -0
- package/components/CreditMemo/CreditMemoItems.tsx +78 -0
- package/components/CreditMemo/CreditMemoTotals.tsx +122 -0
- package/components/CreditMemo/index.ts +8 -0
- package/components/CustomerForms/CustomerAttributeField.tsx +112 -0
- package/components/CustomerForms/CustomerAttributeMetadata.graphql +9 -0
- package/components/CustomerForms/CustomerUpdateForm.tsx +65 -0
- package/components/CustomerForms/UseCustomerCreateForm.graphql +7 -0
- package/components/CustomerForms/UseCustomerUpdateForm.graphql +7 -0
- package/components/CustomerForms/customerAttributeFieldHelpers.ts +127 -0
- package/components/CustomerForms/index.ts +8 -0
- package/components/CustomerForms/nameFieldset.tsx +32 -0
- package/components/CustomerForms/useCustomerCreateForm.ts +83 -0
- package/components/CustomerForms/useCustomerUpdateForm.ts +122 -0
- package/components/GuestOrderOverview/GuestOrderOverviewForm.tsx +28 -11
- package/components/Invoice/Invoice.graphql +13 -0
- package/components/Invoice/InvoiceCard.graphql +9 -0
- package/components/Invoice/InvoiceCard.tsx +66 -0
- package/components/Invoice/InvoiceDetails.tsx +94 -0
- package/components/Invoice/InvoiceItem.graphql +25 -0
- package/components/Invoice/InvoiceItem.tsx +125 -0
- package/components/Invoice/InvoiceItems.tsx +72 -0
- package/components/Invoice/InvoiceTotal.graphql +29 -0
- package/components/Invoice/InvoiceTotals.tsx +110 -0
- package/components/Invoice/index.ts +9 -0
- package/components/NameFields/NameFields.tsx +33 -18
- package/components/Order/OrderAdditional/OrderAdditional.graphql +16 -0
- package/components/Order/OrderAdditional/OrderAdditional.tsx +51 -0
- package/components/Order/OrderCard/OrderCard.graphql +13 -0
- package/components/{OrderCard → Order/OrderCard}/OrderCard.tsx +22 -18
- package/components/{OrderCardItem → Order/OrderCard}/OrderCardItem.graphql +1 -0
- package/components/Order/OrderComments/OrderComments.graphql +5 -0
- package/components/Order/OrderComments/SalesCommentItem.graphql +4 -0
- package/components/Order/OrderComments/SalesComments.tsx +28 -0
- package/components/Order/OrderDetails/OrderAddress.graphql +17 -0
- package/components/Order/OrderDetails/OrderDetails.graphql +38 -0
- package/components/{OrderDetails → Order/OrderDetails}/OrderDetails.tsx +70 -57
- package/components/Order/OrderDetails/ShippingHandling.graphql +19 -0
- package/components/Order/OrderDetails/TaxItem.graphql +7 -0
- package/components/{OrderItem → Order/OrderItem}/OrderItem.graphql +13 -0
- package/components/Order/OrderItem/OrderItem.tsx +144 -0
- package/components/Order/OrderItems/OrderItems.tsx +81 -0
- package/components/{OrderStateLabel → Order/OrderStateLabel}/OrderStateLabel.tsx +2 -2
- package/components/Order/OrderTotals/OrderTotal.graphql +32 -0
- package/components/Order/OrderTotals/OrderTotals.graphql +7 -0
- package/components/{OrderDetails → Order/OrderTotals}/OrderTotals.tsx +27 -12
- package/components/Order/index.ts +16 -0
- package/components/ReorderItems/ReorderItems.tsx +1 -1
- package/components/Shipment/Shipment.graphql +14 -0
- package/components/Shipment/ShipmentCard.graphql +8 -0
- package/components/Shipment/ShipmentCard.tsx +71 -0
- package/components/Shipment/ShipmentDetails.tsx +100 -0
- package/components/Shipment/ShipmentItem.graphql +19 -0
- package/components/Shipment/ShipmentItem.tsx +117 -0
- package/components/Shipment/ShipmentItems.tsx +72 -0
- package/components/Shipment/index.ts +7 -0
- package/components/SignUpForm/SignUpForm.tsx +51 -46
- package/components/WaitForCustomer/WaitForCustomer.tsx +12 -3
- package/components/index.ts +5 -8
- package/graphql/{AccountDashboardQueryFragment.graphql → fragments/AccountDashboardQueryFragment.graphql} +8 -3
- package/graphql/index.ts +10 -0
- package/graphql/queries/CreditMemoDetailPage.graphql +14 -0
- package/graphql/queries/InvoiceDetailPage.graphql +14 -0
- package/graphql/queries/OrderDetailPage.graphql +14 -0
- package/graphql/queries/ShipmentDetailPage.graphql +12 -0
- package/hooks/CustomerInfo.graphql +3 -3
- package/index.ts +1 -4
- package/package.json +14 -14
- package/utils/orderState.ts +1 -2
- package/components/OrderCard/OrderCard.graphql +0 -29
- package/components/OrderDetails/OrderDetails.graphql +0 -77
- package/components/OrderItem/OrderItem.tsx +0 -176
- package/components/OrderItems/OrderItems.tsx +0 -70
- package/graphql/OrderDetailPage.graphql +0 -10
- /package/components/{OrderItems → Order/OrderItems}/OrderItems.graphql +0 -0
- /package/components/{OrderStateLabel → Order/OrderStateLabel}/OrderStateLabel.graphql +0 -0
- /package/components/{OrderStateLabel → Order/OrderStateLabel}/OrderStateLabelInline.tsx +0 -0
- /package/graphql/{CustomerStoreConfig.graphql → inject/CustomerStoreConfig.graphql} +0 -0
- /package/graphql/{AccountDashboard.graphql → queries/AccountDashboard.graphql} +0 -0
- /package/graphql/{AccountDashboardAddresses.graphql → queries/AccountDashboardAddresses.graphql} +0 -0
- /package/graphql/{AccountDashboardCustomer.graphql → queries/AccountDashboardCustomer.graphql} +0 -0
- /package/graphql/{AccountDashboardOrders.graphql → queries/AccountDashboardOrders.graphql} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Money } from '@graphcommerce/magento-store'
|
|
2
|
+
import { breakpointVal, extendableComponent, sxx } from '@graphcommerce/next-ui'
|
|
3
|
+
import { Trans } from '@lingui/macro'
|
|
4
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
5
|
+
import { Box, Divider, lighten, Typography } from '@mui/material'
|
|
6
|
+
import type { InvoiceFragment } from './Invoice.gql'
|
|
7
|
+
|
|
8
|
+
export type InvoiceTotalsProps = {
|
|
9
|
+
invoice: InvoiceFragment
|
|
10
|
+
sx?: SxProps<Theme>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const componentName = 'InvoiceTotals'
|
|
14
|
+
const parts = ['totalsContainer', 'totalsRow', 'totalsDivider', 'totalsVat'] as const
|
|
15
|
+
const { classes } = extendableComponent(componentName, parts)
|
|
16
|
+
|
|
17
|
+
export function InvoiceTotals(props: InvoiceTotalsProps) {
|
|
18
|
+
const { invoice, sx = [] } = props
|
|
19
|
+
const { total } = invoice
|
|
20
|
+
|
|
21
|
+
if (!total) return null
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Box
|
|
25
|
+
className={classes.totalsContainer}
|
|
26
|
+
sx={sxx(
|
|
27
|
+
(theme) => ({
|
|
28
|
+
my: theme.spacings.md,
|
|
29
|
+
...breakpointVal(
|
|
30
|
+
'borderRadius',
|
|
31
|
+
theme.shape.borderRadius * 3,
|
|
32
|
+
theme.shape.borderRadius * 5,
|
|
33
|
+
theme.breakpoints.values,
|
|
34
|
+
),
|
|
35
|
+
background:
|
|
36
|
+
theme.palette.mode === 'light'
|
|
37
|
+
? theme.palette.background.default
|
|
38
|
+
: lighten(theme.palette.background.default, 0.15),
|
|
39
|
+
padding: `${theme.spacings.xs} ${theme.spacings.sm}`,
|
|
40
|
+
}),
|
|
41
|
+
sx,
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
<Box className={classes.totalsRow} sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
45
|
+
<Typography>
|
|
46
|
+
<Trans>Subtotal</Trans>
|
|
47
|
+
</Typography>
|
|
48
|
+
<Money {...total.subtotal} />
|
|
49
|
+
</Box>
|
|
50
|
+
|
|
51
|
+
{total.discounts?.map((discount) => (
|
|
52
|
+
<Box
|
|
53
|
+
className={classes.totalsRow}
|
|
54
|
+
sx={{ display: 'flex', justifyContent: 'space-between' }}
|
|
55
|
+
key={`discount-${discount?.label}`}
|
|
56
|
+
>
|
|
57
|
+
<Typography>{discount?.label}</Typography>
|
|
58
|
+
{discount?.amount && (
|
|
59
|
+
<Money {...discount.amount} value={(discount.amount.value ?? 0) * -1} />
|
|
60
|
+
)}
|
|
61
|
+
</Box>
|
|
62
|
+
))}
|
|
63
|
+
|
|
64
|
+
{total.total_shipping && (
|
|
65
|
+
<Box
|
|
66
|
+
className={classes.totalsRow}
|
|
67
|
+
sx={{ display: 'flex', justifyContent: 'space-between' }}
|
|
68
|
+
>
|
|
69
|
+
<Typography>
|
|
70
|
+
<Trans>Shipping</Trans>
|
|
71
|
+
</Typography>
|
|
72
|
+
<Money {...total.total_shipping} />
|
|
73
|
+
</Box>
|
|
74
|
+
)}
|
|
75
|
+
|
|
76
|
+
<Divider sx={(theme) => ({ my: theme.spacings.xxs })} />
|
|
77
|
+
|
|
78
|
+
<Box
|
|
79
|
+
className={classes.totalsRow}
|
|
80
|
+
sx={(theme) => ({
|
|
81
|
+
display: 'flex',
|
|
82
|
+
justifyContent: 'space-between',
|
|
83
|
+
color: theme.palette.primary.main,
|
|
84
|
+
})}
|
|
85
|
+
>
|
|
86
|
+
<Typography>
|
|
87
|
+
<Trans>Grand total</Trans>
|
|
88
|
+
</Typography>
|
|
89
|
+
<Money {...total.grand_total} />
|
|
90
|
+
</Box>
|
|
91
|
+
|
|
92
|
+
{total.taxes?.map((tax) => (
|
|
93
|
+
<Box
|
|
94
|
+
key={tax?.title}
|
|
95
|
+
className={classes.totalsVat}
|
|
96
|
+
sx={(theme) => ({
|
|
97
|
+
display: 'flex',
|
|
98
|
+
justifyContent: 'space-between',
|
|
99
|
+
color: theme.palette.text.disabled,
|
|
100
|
+
})}
|
|
101
|
+
>
|
|
102
|
+
<Typography>
|
|
103
|
+
<Trans>Including {tax?.title}</Trans>
|
|
104
|
+
</Typography>
|
|
105
|
+
<Money {...tax?.amount} />
|
|
106
|
+
</Box>
|
|
107
|
+
))}
|
|
108
|
+
</Box>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './Invoice.gql'
|
|
2
|
+
export * from './InvoiceCard'
|
|
3
|
+
export * from './InvoiceCard.gql'
|
|
4
|
+
export * from './InvoiceDetails'
|
|
5
|
+
export * from './InvoiceItem'
|
|
6
|
+
export * from './InvoiceItem.gql'
|
|
7
|
+
export * from './InvoiceItems'
|
|
8
|
+
export * from './InvoiceTotal.gql'
|
|
9
|
+
export * from './InvoiceTotals'
|
|
@@ -1,46 +1,61 @@
|
|
|
1
1
|
import { SelectElement, TextFieldElement } from '@graphcommerce/ecommerce-ui'
|
|
2
2
|
import { FormRow } from '@graphcommerce/next-ui'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
FieldPath,
|
|
5
|
+
FieldValues,
|
|
6
|
+
PathValue,
|
|
7
|
+
UseFormReturn,
|
|
8
|
+
} from '@graphcommerce/react-hook-form'
|
|
4
9
|
import { assertFormGqlOperation } from '@graphcommerce/react-hook-form'
|
|
5
10
|
import { i18n } from '@lingui/core'
|
|
6
11
|
import { Trans } from '@lingui/react'
|
|
7
12
|
|
|
8
13
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
14
|
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
form: UseFormReturn<any>
|
|
15
|
+
export type NameFieldProps<TFieldValues extends FieldValues = FieldValues> = {
|
|
16
|
+
form: UseFormReturn<TFieldValues>
|
|
17
|
+
names?: {
|
|
18
|
+
firstname: FieldPath<TFieldValues>
|
|
19
|
+
lastname: FieldPath<TFieldValues>
|
|
20
|
+
prefix?: FieldPath<TFieldValues>
|
|
21
|
+
}
|
|
19
22
|
readOnly?: boolean
|
|
20
23
|
prefix?: boolean
|
|
21
24
|
prefixes?: string[]
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
export function NameFields
|
|
27
|
+
export function NameFields<TFieldValues extends FieldValues = FieldValues>(
|
|
28
|
+
props: NameFieldProps<TFieldValues>,
|
|
29
|
+
) {
|
|
25
30
|
const mr = i18n._(/* i18n */ 'Mr')
|
|
26
31
|
const mrs = i18n._(/* i18n */ 'Mrs')
|
|
27
32
|
const other = i18n._(/* i18n */ 'Other')
|
|
28
33
|
|
|
29
|
-
const {
|
|
30
|
-
|
|
34
|
+
const {
|
|
35
|
+
form,
|
|
36
|
+
readOnly,
|
|
37
|
+
prefixes = [mr, mrs, other],
|
|
38
|
+
prefix,
|
|
39
|
+
names = {
|
|
40
|
+
firstname: 'firstname' as FieldPath<TFieldValues>,
|
|
41
|
+
lastname: 'lastname' as FieldPath<TFieldValues>,
|
|
42
|
+
prefix: prefix ? ('prefix' as FieldPath<TFieldValues>) : undefined,
|
|
43
|
+
},
|
|
44
|
+
} = props
|
|
45
|
+
assertFormGqlOperation<TFieldValues>(form)
|
|
31
46
|
|
|
32
47
|
const { control, required } = form
|
|
33
48
|
|
|
34
49
|
return (
|
|
35
50
|
<>
|
|
36
|
-
{prefix && (
|
|
51
|
+
{names.prefix && (
|
|
37
52
|
<FormRow>
|
|
38
53
|
<SelectElement
|
|
39
54
|
variant='outlined'
|
|
40
|
-
defaultValue={prefixes[0]}
|
|
55
|
+
defaultValue={prefixes[0] as PathValue<TFieldValues, FieldPath<TFieldValues>>}
|
|
41
56
|
control={control}
|
|
42
57
|
required={required.prefix}
|
|
43
|
-
name=
|
|
58
|
+
name={names.prefix}
|
|
44
59
|
label={<Trans id='Prefix' />}
|
|
45
60
|
showValid
|
|
46
61
|
InputProps={{ readOnly }}
|
|
@@ -51,7 +66,7 @@ export function NameFields(props: NameFieldProps) {
|
|
|
51
66
|
<FormRow>
|
|
52
67
|
<TextFieldElement
|
|
53
68
|
control={control}
|
|
54
|
-
name=
|
|
69
|
+
name={names.firstname}
|
|
55
70
|
required={required.firstname}
|
|
56
71
|
variant='outlined'
|
|
57
72
|
type='text'
|
|
@@ -61,7 +76,7 @@ export function NameFields(props: NameFieldProps) {
|
|
|
61
76
|
/>
|
|
62
77
|
<TextFieldElement
|
|
63
78
|
control={control}
|
|
64
|
-
name=
|
|
79
|
+
name={names.lastname}
|
|
65
80
|
required={required.lastname}
|
|
66
81
|
variant='outlined'
|
|
67
82
|
type='text'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { filterNonNullableKeys, SectionContainer, sxx } from '@graphcommerce/next-ui'
|
|
2
|
+
import { Box, type SxProps, type Theme } from '@mui/material'
|
|
3
|
+
import { CancelOrderForm } from '../../CancelOrder/CancelOrderForm'
|
|
4
|
+
import { CreditMemoCard } from '../../CreditMemo/CreditMemoCard'
|
|
5
|
+
import { InvoiceCard } from '../../Invoice/InvoiceCard'
|
|
6
|
+
import { ShipmentCard } from '../../Shipment/ShipmentCard'
|
|
7
|
+
import { SalesComments } from '../OrderComments/SalesComments'
|
|
8
|
+
import type { OrderAdditionalFragment } from './OrderAdditional.gql'
|
|
9
|
+
|
|
10
|
+
export type OrderAdditionalProps = {
|
|
11
|
+
order: OrderAdditionalFragment
|
|
12
|
+
sx?: SxProps<Theme>
|
|
13
|
+
children?: React.ReactNode
|
|
14
|
+
additionalForms?: React.ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function OrderAdditional(props: OrderAdditionalProps) {
|
|
18
|
+
const { order, children, sx, additionalForms } = props
|
|
19
|
+
const comments = filterNonNullableKeys(order.comments)
|
|
20
|
+
const invoices = filterNonNullableKeys(order.invoices)
|
|
21
|
+
const shipments = filterNonNullableKeys(order.shipments)
|
|
22
|
+
const creditMemos = filterNonNullableKeys(order.credit_memos)
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Box
|
|
26
|
+
sx={sxx(
|
|
27
|
+
(theme) => ({ mb: theme.spacings.lg, display: 'grid', rowGap: theme.spacings.xs }),
|
|
28
|
+
sx,
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
{comments.length > 0 ? <SalesComments comments={comments} /> : null}
|
|
32
|
+
|
|
33
|
+
{shipments.map((shipment) => (
|
|
34
|
+
<ShipmentCard key={shipment.id} shipment={shipment} orderNumber={order.number} />
|
|
35
|
+
))}
|
|
36
|
+
|
|
37
|
+
{invoices.map((invoice) => (
|
|
38
|
+
<InvoiceCard key={invoice.id} invoice={invoice} orderNumber={order.number} />
|
|
39
|
+
))}
|
|
40
|
+
|
|
41
|
+
{creditMemos.map((creditMemo) => (
|
|
42
|
+
<CreditMemoCard key={creditMemo.id} creditMemo={creditMemo} orderNumber={order.number} />
|
|
43
|
+
))}
|
|
44
|
+
|
|
45
|
+
{children}
|
|
46
|
+
|
|
47
|
+
<CancelOrderForm order={order} />
|
|
48
|
+
{additionalForms}
|
|
49
|
+
</Box>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@graphcommerce/next-ui'
|
|
13
13
|
import { Trans } from '@lingui/macro'
|
|
14
14
|
import type { SxProps, Theme } from '@mui/material'
|
|
15
|
-
import { Box, lighten, Paper, Skeleton } from '@mui/material'
|
|
15
|
+
import { Avatar, Box, lighten, Paper, Skeleton } from '@mui/material'
|
|
16
16
|
import { OrderStateLabel } from '../OrderStateLabel/OrderStateLabel'
|
|
17
17
|
import type { OrderCardFragment } from './OrderCard.gql'
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ export function OrderCard(props: OrderCardProps) {
|
|
|
32
32
|
const itemsWithImages = filterNonNullableKeys(items, ['product_url_key', 'product'])
|
|
33
33
|
.map((item) => {
|
|
34
34
|
const img = item.product.thumbnail
|
|
35
|
-
if (!img?.url
|
|
35
|
+
if (!img?.url) return null
|
|
36
36
|
return { ...img, url: img.url }
|
|
37
37
|
})
|
|
38
38
|
.filter((v) => !!v)
|
|
@@ -94,22 +94,26 @@ export function OrderCard(props: OrderCardProps) {
|
|
|
94
94
|
gap: 1,
|
|
95
95
|
}}
|
|
96
96
|
>
|
|
97
|
-
{itemsWithImages.slice(0, maxItemsToShow).map((item) =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
{itemsWithImages.slice(0, maxItemsToShow).map((item, index) => {
|
|
98
|
+
const key = `${item.url}-${index}`
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Image
|
|
102
|
+
key={key}
|
|
103
|
+
alt={item.label ?? ''}
|
|
104
|
+
layout='fill'
|
|
105
|
+
src={item.url}
|
|
106
|
+
width={96}
|
|
107
|
+
height={96}
|
|
108
|
+
sx={{ borderRadius: 4, objectFit: 'contain' }}
|
|
109
|
+
pictureProps={{
|
|
110
|
+
sx: {
|
|
111
|
+
gridArea: itemsWithImages.length === 1 ? '1 / 1 / 3 / 3' : undefined,
|
|
112
|
+
},
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
)
|
|
116
|
+
})}
|
|
113
117
|
|
|
114
118
|
{totalItems > 4 && (
|
|
115
119
|
<Box
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
filterNonNullableKeys,
|
|
3
|
+
RelativeToTimeFormat,
|
|
4
|
+
SectionContainer,
|
|
5
|
+
} from '@graphcommerce/next-ui'
|
|
6
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
7
|
+
import type { SalesCommentItemFragment } from './SalesCommentItem.gql'
|
|
8
|
+
|
|
9
|
+
export type SalesCommentsProps = {
|
|
10
|
+
comments: (SalesCommentItemFragment | null | undefined)[] | null | undefined
|
|
11
|
+
sx?: SxProps<Theme>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function SalesComments(props: SalesCommentsProps) {
|
|
15
|
+
const { comments, sx } = props
|
|
16
|
+
|
|
17
|
+
if (!comments?.length) return null
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SectionContainer labelLeft='Comments' sx={sx}>
|
|
21
|
+
{filterNonNullableKeys(comments).map((comment) => (
|
|
22
|
+
<div key={comment.message}>
|
|
23
|
+
{comment.message} <RelativeToTimeFormat date={comment.timestamp} />
|
|
24
|
+
</div>
|
|
25
|
+
))}
|
|
26
|
+
</SectionContainer>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
fragment OrderDetails on CustomerOrder {
|
|
2
|
+
id
|
|
3
|
+
number
|
|
4
|
+
order_date
|
|
5
|
+
status
|
|
6
|
+
invoices {
|
|
7
|
+
id
|
|
8
|
+
number
|
|
9
|
+
}
|
|
10
|
+
shipping_method
|
|
11
|
+
shipments {
|
|
12
|
+
id
|
|
13
|
+
tracking {
|
|
14
|
+
...TrackingLink
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
# applied_coupons {
|
|
18
|
+
# ...AppliedCoupon
|
|
19
|
+
# }
|
|
20
|
+
payment_methods {
|
|
21
|
+
name
|
|
22
|
+
type
|
|
23
|
+
additional_data {
|
|
24
|
+
name
|
|
25
|
+
value
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
billing_address {
|
|
29
|
+
...OrderAddress
|
|
30
|
+
}
|
|
31
|
+
shipping_address {
|
|
32
|
+
...OrderAddress
|
|
33
|
+
}
|
|
34
|
+
carrier
|
|
35
|
+
total {
|
|
36
|
+
...OrderTotal
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -2,18 +2,17 @@ import {
|
|
|
2
2
|
breakpointVal,
|
|
3
3
|
DateTimeFormat,
|
|
4
4
|
extendableComponent,
|
|
5
|
-
iconInvoice,
|
|
6
|
-
IconSvg,
|
|
7
5
|
SectionContainer,
|
|
8
6
|
} from '@graphcommerce/next-ui'
|
|
9
7
|
import { Trans } from '@lingui/macro'
|
|
10
8
|
import type { SxProps, Theme } from '@mui/material'
|
|
11
9
|
import { Box, lighten, Typography } from '@mui/material'
|
|
12
|
-
import { AddressMultiLine } from '
|
|
13
|
-
import { TrackingLink } from '
|
|
10
|
+
import { AddressMultiLine } from '../../AddressMultiLine/AddressMultiLine'
|
|
11
|
+
import { TrackingLink } from '../../TrackingLink/TrackingLink'
|
|
14
12
|
import type { OrderDetailsFragment } from './OrderDetails.gql'
|
|
15
13
|
|
|
16
|
-
export type OrderDetailsProps =
|
|
14
|
+
export type OrderDetailsProps = {
|
|
15
|
+
order: OrderDetailsFragment
|
|
17
16
|
sx?: SxProps<Theme>
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -28,6 +27,7 @@ const parts = [
|
|
|
28
27
|
const { classes } = extendableComponent(componentName, parts)
|
|
29
28
|
|
|
30
29
|
export function OrderDetails(props: OrderDetailsProps) {
|
|
30
|
+
const { order, sx = [] } = props
|
|
31
31
|
const {
|
|
32
32
|
number,
|
|
33
33
|
order_date,
|
|
@@ -37,29 +37,27 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
37
37
|
shipments,
|
|
38
38
|
shipping_method,
|
|
39
39
|
invoices,
|
|
40
|
-
|
|
41
|
-
} = props
|
|
40
|
+
} = order
|
|
42
41
|
|
|
43
42
|
return (
|
|
44
|
-
<
|
|
45
|
-
labelLeft={<Trans>Order details</Trans>}
|
|
43
|
+
<Box
|
|
46
44
|
sx={[
|
|
47
45
|
(theme) => ({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
margin: `${theme.spacings.sm} 0`,
|
|
47
|
+
'& > div:last-of-type': {
|
|
48
|
+
borderRadius: '0',
|
|
49
|
+
...breakpointVal(
|
|
50
|
+
'borderBottomLeftRadius',
|
|
51
|
+
theme.shape.borderRadius * 2,
|
|
52
|
+
theme.shape.borderRadius * 3,
|
|
53
|
+
theme.breakpoints.values,
|
|
54
|
+
),
|
|
55
|
+
...breakpointVal(
|
|
56
|
+
'borderBottomRightRadius',
|
|
57
|
+
theme.shape.borderRadius * 2,
|
|
58
|
+
theme.shape.borderRadius * 3,
|
|
59
|
+
theme.breakpoints.values,
|
|
60
|
+
),
|
|
63
61
|
},
|
|
64
62
|
}),
|
|
65
63
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
@@ -67,25 +65,39 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
67
65
|
>
|
|
68
66
|
<Box
|
|
69
67
|
className={classes.orderDetailContainer}
|
|
70
|
-
sx={
|
|
71
|
-
(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
sx={(theme) => ({
|
|
69
|
+
...breakpointVal(
|
|
70
|
+
'borderTopLeftRadius',
|
|
71
|
+
theme.shape.borderRadius * 2,
|
|
72
|
+
theme.shape.borderRadius * 3,
|
|
73
|
+
theme.breakpoints.values,
|
|
74
|
+
),
|
|
75
|
+
...breakpointVal(
|
|
76
|
+
'borderTopRightRadius',
|
|
77
|
+
theme.shape.borderRadius * 2,
|
|
78
|
+
theme.shape.borderRadius * 3,
|
|
79
|
+
theme.breakpoints.values,
|
|
80
|
+
),
|
|
81
|
+
background:
|
|
82
|
+
theme.palette.mode === 'light'
|
|
83
|
+
? theme.palette.background.default
|
|
84
|
+
: lighten(theme.palette.background.default, 0.15),
|
|
85
|
+
padding: theme.spacings.sm,
|
|
86
|
+
gridColumnGap: theme.spacings.xxl,
|
|
87
|
+
gridRowGap: theme.spacings.sm,
|
|
88
|
+
display: 'grid',
|
|
89
|
+
[theme.breakpoints.up('sm')]: {
|
|
90
|
+
gridTemplateColumns: '1fr 1fr',
|
|
91
|
+
marginTop: theme.spacings.xxs,
|
|
92
|
+
},
|
|
93
|
+
})}
|
|
82
94
|
>
|
|
83
95
|
<Box className={classes.orderDetailRow}>
|
|
84
96
|
<SectionContainer
|
|
85
97
|
variantLeft='h5'
|
|
86
98
|
labelLeft={<Trans>Order number</Trans>}
|
|
87
99
|
className={classes.orderDetailTitle}
|
|
88
|
-
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '
|
|
100
|
+
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
|
|
89
101
|
>
|
|
90
102
|
<Typography>{number}</Typography>
|
|
91
103
|
</SectionContainer>
|
|
@@ -96,7 +108,7 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
96
108
|
variantLeft='h5'
|
|
97
109
|
labelLeft={<Trans>Order date</Trans>}
|
|
98
110
|
className={classes.orderDetailTitle}
|
|
99
|
-
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '
|
|
111
|
+
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '8px' } }}
|
|
100
112
|
>
|
|
101
113
|
<DateTimeFormat date={order_date} />
|
|
102
114
|
</SectionContainer>
|
|
@@ -138,22 +150,7 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
138
150
|
)}
|
|
139
151
|
|
|
140
152
|
{payment_methods && payment_methods[0] && (
|
|
141
|
-
|
|
142
|
-
<Typography>{payment_methods[0].name}</Typography>
|
|
143
|
-
{invoices && invoices?.length > 0 && (
|
|
144
|
-
<Box
|
|
145
|
-
className={classes.invoice}
|
|
146
|
-
sx={{
|
|
147
|
-
display: 'flex',
|
|
148
|
-
justifyContent: 'flex-start',
|
|
149
|
-
alignItems: 'center',
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
<IconSvg src={iconInvoice} size='small' />
|
|
153
|
-
{invoices?.[0]?.number}
|
|
154
|
-
</Box>
|
|
155
|
-
)}
|
|
156
|
-
</>
|
|
153
|
+
<Typography>{payment_methods[0].name}</Typography>
|
|
157
154
|
)}
|
|
158
155
|
</SectionContainer>
|
|
159
156
|
</Box>
|
|
@@ -166,7 +163,14 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
166
163
|
className={classes.orderDetailTitle}
|
|
167
164
|
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '4px' } }}
|
|
168
165
|
>
|
|
169
|
-
<AddressMultiLine
|
|
166
|
+
<AddressMultiLine
|
|
167
|
+
{...shipping_address}
|
|
168
|
+
region={{
|
|
169
|
+
region: shipping_address.region,
|
|
170
|
+
region_id: shipping_address.region_id ? Number(shipping_address.region_id) : null,
|
|
171
|
+
}}
|
|
172
|
+
// custom_attributesV2={[]}
|
|
173
|
+
/>
|
|
170
174
|
</SectionContainer>
|
|
171
175
|
</Box>
|
|
172
176
|
)}
|
|
@@ -178,10 +182,19 @@ export function OrderDetails(props: OrderDetailsProps) {
|
|
|
178
182
|
className={classes.orderDetailTitle}
|
|
179
183
|
sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '4px' } }}
|
|
180
184
|
>
|
|
181
|
-
|
|
185
|
+
{billing_address && (
|
|
186
|
+
<AddressMultiLine
|
|
187
|
+
{...billing_address}
|
|
188
|
+
region={{
|
|
189
|
+
region: billing_address.region,
|
|
190
|
+
region_id: billing_address.region_id ? Number(billing_address.region_id) : null,
|
|
191
|
+
}}
|
|
192
|
+
// custom_attributesV2={[]}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
182
195
|
</SectionContainer>
|
|
183
196
|
</Box>
|
|
184
197
|
</Box>
|
|
185
|
-
</
|
|
198
|
+
</Box>
|
|
186
199
|
)
|
|
187
200
|
}
|