@faststore/core 4.8.1-dev.0 → 4.8.1-dev.2

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.
Files changed (89) hide show
  1. package/.turbo/turbo-generate.log +3 -3
  2. package/.turbo/turbo-test.log +146 -105
  3. package/@generated/gql.ts +3 -3
  4. package/@generated/graphql.ts +4 -2
  5. package/@generated/persisted-documents.json +1 -1
  6. package/@generated/schema.graphql +4 -0
  7. package/CHANGELOG.md +16 -0
  8. package/cms/faststore/my-account/components/cms_component__accountnavigation.jsonc +10 -0
  9. package/cms/faststore/my-account/components/cms_component__accountorderdelivery.jsonc +80 -0
  10. package/cms/faststore/my-account/components/cms_component__accountorderdetails.jsonc +25 -0
  11. package/cms/faststore/my-account/components/cms_component__accountorderslist.jsonc +10 -0
  12. package/cms/faststore/my-account/components/cms_component__accountorderstatus.jsonc +90 -0
  13. package/cms/faststore/my-account/components/cms_component__accountordersummary.jsonc +25 -0
  14. package/package.json +6 -6
  15. package/src/components/account/Drawer/OrganizationDrawer/ContractSwitcher/ContractSwitcher.tsx +4 -6
  16. package/src/components/account/Drawer/OrganizationDrawer/OrganizationDrawer.tsx +18 -3
  17. package/src/components/account/Drawer/OrganizationDrawer/OrganizationDrawerFooter.tsx +13 -2
  18. package/src/components/account/Drawer/OrganizationDrawer/OrganizationDrawerHeader.tsx +1 -0
  19. package/src/components/account/Drawer/OrganizationDrawer/section.module.scss +7 -0
  20. package/src/components/account/Drawer/OrganizationSignInButton/OrganizationSignInButton.tsx +7 -9
  21. package/src/components/account/Menu/Menu.tsx +24 -7
  22. package/src/components/account/orders/ListOrders/FilterSlider/FilterFacetPendingApproval/FilterFacetPendingApproval.tsx +8 -3
  23. package/src/components/account/orders/ListOrders/FilterSlider/FilterSlider.tsx +1 -0
  24. package/src/components/account/orders/ListOrders/ListOrders.tsx +2 -2
  25. package/src/components/account/orders/ListOrders/listOrdersLabels.ts +4 -0
  26. package/src/components/account/orders/OrderDetails/BuyingPolicyAlert/BuyingPolicyAlert.tsx +45 -9
  27. package/src/components/account/orders/OrderDetails/DeliveryCard/DeliveryCard.tsx +14 -3
  28. package/src/components/account/orders/OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordion.tsx +4 -1
  29. package/src/components/account/orders/OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordionDeliveryInfo.tsx +14 -7
  30. package/src/components/account/orders/OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordionProducts.tsx +8 -5
  31. package/src/components/account/orders/OrderDetails/OrderDetailsHeader.tsx +5 -0
  32. package/src/components/account/orders/OrderDetails/StatusCard/StatusCard.tsx +26 -89
  33. package/src/components/account/orders/OrderDetails/StatusCard/statusCardLocalization.ts +114 -0
  34. package/src/components/account/orders/OrderDetails/SummaryCard/SummaryCard.tsx +2 -1
  35. package/src/components/account/orders/OrderDetails/SummaryCard/getOrderTotalLabel.ts +19 -0
  36. package/src/components/account/orders/OrderDetails/getDeliveryOptionLabel.ts +135 -0
  37. package/src/components/account/orders/OrderDetails/orderDetailsLabels.ts +73 -0
  38. package/src/components/navigation/Navbar/Navbar.tsx +17 -19
  39. package/src/components/navigation/Navbar/NavbarAccountArea.tsx +57 -0
  40. package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +16 -18
  41. package/src/components/sections/Account/AccountOrderDelivery.tsx +3 -1
  42. package/src/components/sections/Account/AccountOrderDetails.tsx +16 -0
  43. package/src/components/sections/Account/AccountOrderStatus.tsx +27 -3
  44. package/src/components/sections/Account/AccountOrdersList.tsx +4 -0
  45. package/src/pages/api/fs/switch-contract.ts +194 -0
  46. package/src/pages/api/graphql.ts +108 -69
  47. package/src/sdk/account/accountPageContext.ts +14 -3
  48. package/src/sdk/account/changeContractToken.ts +19 -63
  49. package/src/sdk/account/clearPersistedSessionState.ts +13 -7
  50. package/src/sdk/account/getMyAccountRoutes.ts +2 -0
  51. package/src/sdk/account/useAvailableContracts.ts +1 -0
  52. package/src/sdk/account/useSwitchContract.ts +11 -3
  53. package/src/sdk/overrides/PageProvider.tsx +1 -1
  54. package/src/sdk/session/index.ts +2 -1
  55. package/src/sdk/session/isSignInAreaResolved.ts +12 -0
  56. package/test/components/account/ContractSwitcher.browser.test.tsx +42 -0
  57. package/test/components/account/Menu.browser.test.tsx +123 -0
  58. package/test/components/account/OrganizationDrawer.browser.test.tsx +148 -0
  59. package/test/components/account/OrganizationDrawerFooter.browser.test.tsx +95 -1
  60. package/test/components/account/OrganizationDrawerHeader.browser.test.tsx +2 -0
  61. package/test/components/account/OrganizationSignInButton.browser.test.tsx +49 -0
  62. package/test/components/account/orders/BuyingPolicyAlert.browser.test.tsx +342 -0
  63. package/test/components/account/orders/DeliveryCard.browser.test.tsx +36 -0
  64. package/test/components/account/orders/DeliveryOptionAccordion.browser.test.tsx +76 -0
  65. package/test/components/account/orders/DeliveryOptionAccordionDeliveryInfo.browser.test.tsx +41 -0
  66. package/test/components/account/orders/DeliveryOptionAccordionProducts.browser.test.tsx +35 -0
  67. package/test/components/account/orders/FilterFacetPendingApproval.browser.test.tsx +25 -0
  68. package/test/components/account/orders/StatusCard.browser.test.tsx +37 -0
  69. package/test/components/account/orders/StatusCard.test.ts +101 -0
  70. package/test/components/account/orders/SummaryCard.browser.test.tsx +59 -0
  71. package/test/components/account/orders/getDeliveryOptionLabel.test.ts +129 -0
  72. package/test/components/account/orders/getOrderTotalLabel.test.ts +35 -0
  73. package/test/components/account/orders/listOrdersLabels.test.ts +23 -0
  74. package/test/components/account/orders/orderDetailsLabels.test.ts +13 -0
  75. package/test/components/navigation/Navbar.browser.test.tsx +183 -0
  76. package/test/components/navigation/NavbarAccountArea.browser.test.tsx +115 -0
  77. package/test/components/navigation/NavbarSlider.browser.test.tsx +143 -0
  78. package/test/components/sections/Account/AccountOrderDelivery.browser.test.tsx +72 -0
  79. package/test/components/sections/Account/AccountOrderDetails.browser.test.tsx +151 -0
  80. package/test/components/sections/Account/AccountOrderStatus.browser.test.tsx +59 -0
  81. package/test/components/sections/Account/AccountOrdersList.browser.test.tsx +67 -0
  82. package/test/pages/api/graphql.test.ts +27 -1
  83. package/test/pages/api/switch-contract.test.ts +385 -0
  84. package/test/sdk/account/changeContractToken.browser.test.ts +23 -71
  85. package/test/sdk/account/clearPersistedSessionState.browser.test.ts +24 -0
  86. package/test/sdk/account/getMyAccountRoutes.test.ts +11 -1
  87. package/test/sdk/account/useSwitchContract.browser.test.ts +21 -0
  88. package/test/sdk/session/isSignInAreaResolved.test.ts +22 -0
  89. package/test/utils/userOrderStatus.test.ts +22 -0
@@ -0,0 +1,135 @@
1
+ import type { OrderDeliverySectionLabels } from './orderDetailsLabels'
2
+
3
+ type DeliveryOptionLabelData = {
4
+ selectedSla?: string | null
5
+ deliveryChannel?: string | null
6
+ deliveryCompany?: string | null
7
+ seller?: string | null
8
+ shippingEstimate?: string | null
9
+ shippingEstimateDate?: string | null
10
+ friendlyDeliveryOptionName?: string | null
11
+ address?: {
12
+ neighborhood?: string | null
13
+ addressId?: string | null
14
+ } | null
15
+ pickupStoreInfo?: {
16
+ address?: { neighborhood?: string | null } | null
17
+ } | null
18
+ deliveryWindow?: {
19
+ startDateUtc?: string | null
20
+ endDateUtc?: string | null
21
+ } | null
22
+ }
23
+
24
+ type EstimateUnit = 'bd' | 'd' | 'h' | 'm'
25
+ type EstimateQuantity = 'zero' | 'one' | 'other'
26
+
27
+ const ESTIMATE_LABEL_KEYS: Record<
28
+ EstimateUnit,
29
+ Record<EstimateQuantity, keyof OrderDeliverySectionLabels>
30
+ > = {
31
+ bd: {
32
+ zero: 'businessDaysZeroTemplate',
33
+ one: 'businessDaysOneTemplate',
34
+ other: 'businessDaysOtherTemplate',
35
+ },
36
+ d: {
37
+ zero: 'daysZeroTemplate',
38
+ one: 'daysOneTemplate',
39
+ other: 'daysOtherTemplate',
40
+ },
41
+ h: {
42
+ zero: 'hoursZeroTemplate',
43
+ one: 'hoursOneTemplate',
44
+ other: 'hoursOtherTemplate',
45
+ },
46
+ m: {
47
+ zero: 'minutesZeroTemplate',
48
+ one: 'minutesOneTemplate',
49
+ other: 'minutesOtherTemplate',
50
+ },
51
+ }
52
+
53
+ const CHANNEL_LABEL_KEYS: Record<
54
+ string,
55
+ keyof OrderDeliverySectionLabels | undefined
56
+ > = {
57
+ delivery: 'deliveryChannelLabel',
58
+ pickup: 'pickupChannelLabel',
59
+ 'pickup-in-point': 'pickupChannelLabel',
60
+ 'take-away': 'takeAwayChannelLabel',
61
+ '': undefined,
62
+ }
63
+
64
+ function isEstimateUnit(unit: string): unit is EstimateUnit {
65
+ return unit === 'bd' || unit === 'd' || unit === 'h' || unit === 'm'
66
+ }
67
+
68
+ function getLocalizedEstimate(
69
+ estimate: string,
70
+ labels: Required<OrderDeliverySectionLabels>
71
+ ): string | undefined {
72
+ const count = estimate.split(/\D+/)[0]
73
+ const unit = estimate.split(/\d+/)[1]
74
+
75
+ if (count === '' || Number.isNaN(Number(count)) || !isEstimateUnit(unit)) {
76
+ return undefined
77
+ }
78
+
79
+ let quantity: EstimateQuantity = 'other'
80
+ if (Number(count) === 0) {
81
+ quantity = 'zero'
82
+ } else if (Number(count) < 2) {
83
+ quantity = 'one'
84
+ }
85
+
86
+ const template = labels[ESTIMATE_LABEL_KEYS[unit][quantity]]
87
+
88
+ return template.replace('{count}', count)
89
+ }
90
+
91
+ export function getDeliveryOptionKey(option: DeliveryOptionLabelData): string {
92
+ return [
93
+ option.selectedSla,
94
+ option.deliveryChannel,
95
+ option.deliveryCompany,
96
+ option.seller,
97
+ option.shippingEstimate,
98
+ option.shippingEstimateDate,
99
+ option.address?.addressId,
100
+ option.deliveryWindow?.startDateUtc,
101
+ option.deliveryWindow?.endDateUtc,
102
+ ].join('|')
103
+ }
104
+
105
+ export function getDeliveryOptionLabel(
106
+ option: DeliveryOptionLabelData,
107
+ labels: Required<OrderDeliverySectionLabels>
108
+ ): string {
109
+ const channelLabelKey =
110
+ CHANNEL_LABEL_KEYS[option.deliveryChannel ?? 'unknown']
111
+ const estimate = option.shippingEstimate
112
+ ? getLocalizedEstimate(option.shippingEstimate, labels)
113
+ : undefined
114
+
115
+ if (channelLabelKey === undefined && option.deliveryChannel) {
116
+ return option.friendlyDeliveryOptionName ?? ''
117
+ }
118
+
119
+ if (!estimate) {
120
+ return channelLabelKey
121
+ ? labels[channelLabelKey]
122
+ : (option.friendlyDeliveryOptionName ?? '')
123
+ }
124
+
125
+ const neighborhood =
126
+ option.address?.neighborhood ??
127
+ option.pickupStoreInfo?.address?.neighborhood
128
+ const destination = neighborhood
129
+ ? labels.toNeighborhoodTemplate.replace('{neighborhood}', neighborhood)
130
+ : ''
131
+
132
+ return [channelLabelKey ? labels[channelLabelKey] : '', estimate, destination]
133
+ .filter(Boolean)
134
+ .join(' ')
135
+ }
@@ -13,15 +13,31 @@ export type OrderDetailsHeaderLabels = {
13
13
  /** Supports the `{policy}` placeholder, replaced with the policy name. */
14
14
  rejectModalMessage?: string
15
15
  rejectModalConfirmText?: string
16
+ /** Supports the `{policy}` placeholder, replaced with the policy name. */
17
+ approveSuccessToast?: string
18
+ approveErrorToast?: string
19
+ /** Supports the `{policy}` placeholder, replaced with the policy name. */
20
+ rejectSuccessToast?: string
21
+ rejectErrorToast?: string
22
+ pendingFurtherApprovalsAlert?: string
16
23
  }
17
24
 
18
25
  export type OrderStatusSectionLabels = {
19
26
  statusTitle?: string
20
27
  orderPlacedStep?: string
28
+ approvedStep?: string
29
+ pendingApprovalStep?: string
30
+ deniedStep?: string
31
+ paymentApprovedStep?: string
21
32
  paymentPendingStep?: string
33
+ paymentAuthorizationStep?: string
34
+ paymentDeniedStep?: string
35
+ readyForDeliveryStep?: string
22
36
  handlingStep?: string
37
+ canceledStep?: string
23
38
  invoicedStep?: string
24
39
  deliveredStep?: string
40
+ shipOrderStep?: string
25
41
  }
26
42
 
27
43
  export type OrderPaymentSectionLabels = {
@@ -50,12 +66,33 @@ export type OrderDeliverySectionLabels = {
50
66
  eachLabel?: string
51
67
  taxesLabel?: string
52
68
  totalLabel?: string
69
+ deliveryChannelLabel?: string
70
+ pickupChannelLabel?: string
71
+ takeAwayChannelLabel?: string
72
+ businessDaysZeroTemplate?: string
73
+ businessDaysOneTemplate?: string
74
+ businessDaysOtherTemplate?: string
75
+ daysZeroTemplate?: string
76
+ daysOneTemplate?: string
77
+ daysOtherTemplate?: string
78
+ hoursZeroTemplate?: string
79
+ hoursOneTemplate?: string
80
+ hoursOtherTemplate?: string
81
+ minutesZeroTemplate?: string
82
+ minutesOneTemplate?: string
83
+ minutesOtherTemplate?: string
84
+ toNeighborhoodTemplate?: string
53
85
  }
54
86
 
55
87
  export type OrderSummarySectionLabels = {
56
88
  summaryTitle?: string
57
89
  totalLabel?: string
58
90
  interestLabel?: string
91
+ itemsTotalLabel?: string
92
+ discountsTotalLabel?: string
93
+ shippingTotalLabel?: string
94
+ taxTotalLabel?: string
95
+ changeTotalLabel?: string
59
96
  }
60
97
 
61
98
  export type OrderOrderedBySectionLabels = {
@@ -91,15 +128,30 @@ export const defaultOrderDetailsHeaderLabels: Required<OrderDetailsHeaderLabels>
91
128
  rejectModalMessage:
92
129
  "You're about to reject this approval request, triggered by the {policy} policy. Rejecting any approval request will deny the entire order.\n\nThis action is permanent and cannot be undone.",
93
130
  rejectModalConfirmText: 'Reject',
131
+ approveSuccessToast: '{policy} policy approved successfully.',
132
+ approveErrorToast: "Policy couldn't be approved due to a technical issue.",
133
+ rejectSuccessToast: '{policy} policy rejected successfully. Order denied.',
134
+ rejectErrorToast: "Policy couldn't be rejected due to a technical issue.",
135
+ pendingFurtherApprovalsAlert:
136
+ 'Your approval is recorded. This order is still pending further approvals.',
94
137
  }
95
138
 
96
139
  export const defaultOrderStatusLabels: Required<OrderStatusSectionLabels> = {
97
140
  statusTitle: 'Status',
98
141
  orderPlacedStep: 'Order placed',
142
+ approvedStep: 'Approved',
143
+ pendingApprovalStep: 'Pending approval',
144
+ deniedStep: 'Denied',
145
+ paymentApprovedStep: 'Payment Approved',
99
146
  paymentPendingStep: 'Payment Pending',
147
+ paymentAuthorizationStep: 'Payment authorization',
148
+ paymentDeniedStep: 'Payment Denied',
149
+ readyForDeliveryStep: 'Ready for Delivery',
100
150
  handlingStep: 'Handling order',
151
+ canceledStep: 'Canceled',
101
152
  invoicedStep: 'Invoiced',
102
153
  deliveredStep: 'Delivered',
154
+ shipOrderStep: 'Ship order',
103
155
  }
104
156
 
105
157
  export const defaultOrderPaymentLabels: Required<OrderPaymentSectionLabels> = {
@@ -129,12 +181,33 @@ export const defaultOrderDeliveryLabels: Required<OrderDeliverySectionLabels> =
129
181
  eachLabel: 'Each',
130
182
  taxesLabel: 'Taxes',
131
183
  totalLabel: 'Total',
184
+ deliveryChannelLabel: 'Delivery',
185
+ pickupChannelLabel: 'Pickup',
186
+ takeAwayChannelLabel: 'Take away',
187
+ businessDaysZeroTemplate: 'Today',
188
+ businessDaysOneTemplate: 'In 1 business day',
189
+ businessDaysOtherTemplate: 'Up to {count} business days',
190
+ daysZeroTemplate: 'Today',
191
+ daysOneTemplate: 'In 1 day',
192
+ daysOtherTemplate: 'Up to {count} days',
193
+ hoursZeroTemplate: 'Now',
194
+ hoursOneTemplate: 'In 1 hour',
195
+ hoursOtherTemplate: 'Up to {count} hours',
196
+ minutesZeroTemplate: 'Now',
197
+ minutesOneTemplate: 'In 1 minute',
198
+ minutesOtherTemplate: 'Up to {count} minutes',
199
+ toNeighborhoodTemplate: 'to {neighborhood}',
132
200
  }
133
201
 
134
202
  export const defaultOrderSummaryLabels: Required<OrderSummarySectionLabels> = {
135
203
  summaryTitle: 'Summary',
136
204
  totalLabel: 'Total',
137
205
  interestLabel: 'Interest',
206
+ itemsTotalLabel: 'Items Total',
207
+ discountsTotalLabel: 'Discounts Total',
208
+ shippingTotalLabel: 'Shipping Total',
209
+ taxTotalLabel: 'Tax Total',
210
+ changeTotalLabel: 'Change Total',
138
211
  }
139
212
 
140
213
  export const defaultOrderOrderedByLabels: Required<OrderOrderedBySectionLabels> =
@@ -3,8 +3,6 @@ import { useCallback, useRef, useState } from 'react'
3
3
 
4
4
  import { Icon as UIIcon, useScrollDirection, useUI } from '@faststore/ui'
5
5
 
6
- import { Skeleton as UISkeleton } from '@faststore/ui'
7
- import { OrganizationSignInButton } from 'src/components/account/Drawer/OrganizationSignInButton'
8
6
  import CartToggle from 'src/components/cart/CartToggle'
9
7
  import type { SearchInputRef } from 'src/components/search/SearchInput'
10
8
  import SearchInput from 'src/components/search/SearchInput'
@@ -13,10 +11,12 @@ import LocalizationButton from 'src/components/ui/LocalizationButton'
13
11
  import Logo from 'src/components/ui/Logo'
14
12
  import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
15
13
  import { useSession } from 'src/sdk/session'
14
+ import { isSignInAreaResolved } from 'src/sdk/session/isSignInAreaResolved'
16
15
  import useScreenResize from 'src/sdk/ui/useScreenResize'
17
16
 
18
17
  import storeConfig from 'discovery.config'
19
18
  import type { NavbarProps as SectionNavbarProps } from '../../sections/Navbar'
19
+ import { NavbarAccountArea } from './NavbarAccountArea'
20
20
 
21
21
  const NavbarLinks = dynamic(
22
22
  () =>
@@ -121,7 +121,11 @@ function Navbar({
121
121
  const scrollDirection = useScrollDirection()
122
122
  const { openNavbar, navbar: displayNavbar } = useUI()
123
123
  const { isDesktop } = useScreenResize()
124
- const { b2b, isSessionReady } = useSession()
124
+ const { b2b, isSessionReady, hasValidated } = useSession()
125
+ const isSignInResolved = isSignInAreaResolved({
126
+ isSessionReady,
127
+ hasValidated,
128
+ })
125
129
 
126
130
  const searchMobileRef = useRef<SearchInputRef>(null)
127
131
  const [searchExpanded, setSearchExpanded] = useState(false)
@@ -232,22 +236,16 @@ function Navbar({
232
236
  />
233
237
  )}
234
238
 
235
- {isDesktop &&
236
- (isSessionReady ? (
237
- isOrganizationEnabled ? (
238
- <OrganizationSignInButton
239
- icon={signInButton.icon}
240
- isRepresentative={isRepresentative}
241
- />
242
- ) : (
243
- <ButtonSignIn.Component {...signInButton} />
244
- )
245
- ) : (
246
- <UISkeleton
247
- data-fs-navbar-signin-skeleton
248
- size={{ width: '140px', height: '2.5rem' }}
249
- />
250
- ))}
239
+ {isDesktop && (
240
+ <NavbarAccountArea
241
+ isSignInResolved={isSignInResolved}
242
+ isOrganizationEnabled={isOrganizationEnabled}
243
+ isRepresentative={isRepresentative}
244
+ signInButton={signInButton}
245
+ ButtonSignIn={ButtonSignIn}
246
+ skeletonAttr="data-fs-navbar-signin-skeleton"
247
+ />
248
+ )}
251
249
 
252
250
  <CartToggle {...cart} />
253
251
  </NavbarButtons.Component>
@@ -0,0 +1,57 @@
1
+ import { Skeleton as UISkeleton } from '@faststore/ui'
2
+
3
+ import { OrganizationSignInButton } from 'src/components/account/Drawer/OrganizationSignInButton'
4
+ import type { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
5
+
6
+ import type { NavbarProps as SectionNavbarProps } from '../../sections/Navbar'
7
+
8
+ type NavbarOverrides = ReturnType<typeof useOverrideComponents<'Navbar'>>
9
+
10
+ export type NavbarAccountAreaProps = {
11
+ /** Whether the B2B session has resolved enough to know what to render. */
12
+ isSignInResolved: boolean
13
+ /** Whether the representative-only Organization sign-in area is enabled. */
14
+ isOrganizationEnabled: boolean | undefined
15
+ isRepresentative?: boolean
16
+ signInButton: SectionNavbarProps['signInButton']
17
+ ButtonSignIn: NavbarOverrides['_experimentalButtonSignIn']
18
+ /** Data attribute toggled on the loading skeleton (Navbar vs NavbarSlider). */
19
+ skeletonAttr:
20
+ | 'data-fs-navbar-signin-skeleton'
21
+ | 'data-fs-navbar-slider-signin-skeleton'
22
+ }
23
+
24
+ /**
25
+ * Renders the account/sign-in area shared by the desktop Navbar and the
26
+ * mobile NavbarSlider: a loading skeleton until the B2B session resolves,
27
+ * then either the Organization sign-in button (representatives) or the
28
+ * storefront's own sign-in button.
29
+ */
30
+ export const NavbarAccountArea = ({
31
+ isSignInResolved,
32
+ isOrganizationEnabled,
33
+ isRepresentative,
34
+ signInButton,
35
+ ButtonSignIn,
36
+ skeletonAttr,
37
+ }: NavbarAccountAreaProps) => {
38
+ if (!isSignInResolved) {
39
+ return (
40
+ <UISkeleton
41
+ {...{ [skeletonAttr]: true }}
42
+ size={{ width: '140px', height: '2.5rem' }}
43
+ />
44
+ )
45
+ }
46
+
47
+ if (isOrganizationEnabled) {
48
+ return (
49
+ <OrganizationSignInButton
50
+ icon={signInButton.icon}
51
+ isRepresentative={isRepresentative}
52
+ />
53
+ )
54
+ }
55
+
56
+ return <ButtonSignIn.Component {...signInButton} />
57
+ }
@@ -1,4 +1,4 @@
1
- import { Skeleton as UISkeleton, useFadeEffect, useUI } from '@faststore/ui'
1
+ import { useFadeEffect, useUI } from '@faststore/ui'
2
2
  import { Suspense } from 'react'
3
3
 
4
4
  import storeConfig from 'discovery.config'
@@ -9,10 +9,11 @@ import LocalizationButton from 'src/components/ui/LocalizationButton'
9
9
  import Logo from 'src/components/ui/Logo'
10
10
 
11
11
  import type { NavbarProps } from '../Navbar'
12
+ import { NavbarAccountArea } from '../Navbar/NavbarAccountArea'
12
13
 
13
- import { OrganizationSignInButton } from 'src/components/account/Drawer/OrganizationSignInButton'
14
14
  import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
15
15
  import { useSession } from 'src/sdk/session'
16
+ import { isSignInAreaResolved } from 'src/sdk/session/isSignInAreaResolved'
16
17
  import styles from './section.module.scss'
17
18
 
18
19
  interface NavbarSliderProps {
@@ -44,7 +45,11 @@ function NavbarSlider({
44
45
 
45
46
  const { closeNavbar } = useUI()
46
47
  const { fade, fadeOut } = useFadeEffect()
47
- const { b2b, isSessionReady } = useSession()
48
+ const { b2b, isSessionReady, hasValidated } = useSession()
49
+ const isSignInResolved = isSignInAreaResolved({
50
+ isSessionReady,
51
+ hasValidated,
52
+ })
48
53
 
49
54
  const isFaststoreMyAccountEnabled =
50
55
  storeConfig.experimental?.enableFaststoreMyAccount
@@ -84,21 +89,14 @@ function NavbarSlider({
84
89
  </NavbarSliderContent.Component>
85
90
  <NavbarSliderFooter.Component {...NavbarSliderFooter.props}>
86
91
  <Suspense fallback={<ButtonSignInFallback />}>
87
- {isSessionReady ? (
88
- isOrganizationEnabled ? (
89
- <OrganizationSignInButton
90
- icon={signInButton.icon}
91
- isRepresentative={isRepresentative}
92
- />
93
- ) : (
94
- <ButtonSignIn.Component {...signInButton} />
95
- )
96
- ) : (
97
- <UISkeleton
98
- data-fs-navbar-slider-signin-skeleton
99
- size={{ width: '140px', height: '2.5rem' }}
100
- />
101
- )}
92
+ <NavbarAccountArea
93
+ isSignInResolved={isSignInResolved}
94
+ isOrganizationEnabled={isOrganizationEnabled}
95
+ isRepresentative={isRepresentative}
96
+ signInButton={signInButton}
97
+ ButtonSignIn={ButtonSignIn}
98
+ skeletonAttr="data-fs-navbar-slider-signin-skeleton"
99
+ />
102
100
  </Suspense>
103
101
  {isLocalizationEnabled && (
104
102
  <LocalizationButton
@@ -4,6 +4,7 @@ import {
4
4
  type OrderDeliverySectionLabels,
5
5
  defaultOrderDeliveryLabels,
6
6
  } from 'src/components/account/orders/OrderDetails/orderDetailsLabels'
7
+ import { getDeliveryOptionKey } from 'src/components/account/orders/OrderDetails/getDeliveryOptionLabel'
7
8
  import type {
8
9
  UserOrderDeliveryOption,
9
10
  UserOrderDeliveryOptionsData,
@@ -35,10 +36,11 @@ const AccountOrderDelivery = (props: AccountOrderDeliveryProps) => {
35
36
  ?.fields || []
36
37
  }
37
38
  title={labels.deliveryTitle}
39
+ labels={labels}
38
40
  />
39
41
  {order.deliveryOptionsData.deliveryOptions.map((option) => (
40
42
  <DeliveryOptionAccordion
41
- key={option.friendlyDeliveryOptionName}
43
+ key={getDeliveryOptionKey(option)}
42
44
  deliveryOption={option as UserOrderDeliveryOption}
43
45
  contact={order.deliveryOptionsData.contact}
44
46
  currencyCode={order.storePreferencesData.currencyCode}
@@ -22,6 +22,14 @@ const AccountOrderDetails = ({
22
22
  cancelErrorToast = defaultOrderDetailsHeaderLabels.cancelErrorToast,
23
23
  approveLabel = defaultOrderDetailsHeaderLabels.approveLabel,
24
24
  rejectLabel = defaultOrderDetailsHeaderLabels.rejectLabel,
25
+ rejectModalTitle = defaultOrderDetailsHeaderLabels.rejectModalTitle,
26
+ rejectModalMessage = defaultOrderDetailsHeaderLabels.rejectModalMessage,
27
+ rejectModalConfirmText = defaultOrderDetailsHeaderLabels.rejectModalConfirmText,
28
+ approveSuccessToast = defaultOrderDetailsHeaderLabels.approveSuccessToast,
29
+ approveErrorToast = defaultOrderDetailsHeaderLabels.approveErrorToast,
30
+ rejectSuccessToast = defaultOrderDetailsHeaderLabels.rejectSuccessToast,
31
+ rejectErrorToast = defaultOrderDetailsHeaderLabels.rejectErrorToast,
32
+ pendingFurtherApprovalsAlert = defaultOrderDetailsHeaderLabels.pendingFurtherApprovalsAlert,
25
33
  }: AccountOrderDetailsProps) => {
26
34
  const { order, orderStatusLabels } =
27
35
  useAccountPageData<AccountOrderDetailsPageData>()
@@ -46,6 +54,14 @@ const AccountOrderDetails = ({
46
54
  cancelErrorToast,
47
55
  approveLabel,
48
56
  rejectLabel,
57
+ rejectModalTitle,
58
+ rejectModalMessage,
59
+ rejectModalConfirmText,
60
+ approveSuccessToast,
61
+ approveErrorToast,
62
+ rejectSuccessToast,
63
+ rejectErrorToast,
64
+ pendingFurtherApprovalsAlert,
49
65
  }}
50
66
  />
51
67
  </Section>
@@ -7,20 +7,34 @@ import {
7
7
  type AccountOrderDetailsPageData,
8
8
  useAccountPageData,
9
9
  } from 'src/sdk/account/accountPageContext'
10
- import type { OrderStatusKey } from 'src/utils/userOrderStatus'
10
+ import type {
11
+ OrderStatusCmsLabels,
12
+ OrderStatusKey,
13
+ } from 'src/utils/userOrderStatus'
11
14
  import Section from '../Section'
12
15
 
13
- export type AccountOrderStatusProps = OrderStatusSectionLabels
16
+ export type AccountOrderStatusProps = OrderStatusSectionLabels &
17
+ OrderStatusCmsLabels
14
18
 
15
19
  const AccountOrderStatus = ({
16
20
  statusTitle = defaultOrderStatusLabels.statusTitle,
17
21
  orderPlacedStep = defaultOrderStatusLabels.orderPlacedStep,
22
+ approvedStep = defaultOrderStatusLabels.approvedStep,
23
+ pendingApprovalStep = defaultOrderStatusLabels.pendingApprovalStep,
24
+ deniedStep = defaultOrderStatusLabels.deniedStep,
25
+ paymentApprovedStep = defaultOrderStatusLabels.paymentApprovedStep,
18
26
  paymentPendingStep = defaultOrderStatusLabels.paymentPendingStep,
27
+ paymentAuthorizationStep = defaultOrderStatusLabels.paymentAuthorizationStep,
28
+ paymentDeniedStep = defaultOrderStatusLabels.paymentDeniedStep,
29
+ readyForDeliveryStep = defaultOrderStatusLabels.readyForDeliveryStep,
19
30
  handlingStep = defaultOrderStatusLabels.handlingStep,
31
+ canceledStep = defaultOrderStatusLabels.canceledStep,
20
32
  invoicedStep = defaultOrderStatusLabels.invoicedStep,
21
33
  deliveredStep = defaultOrderStatusLabels.deliveredStep,
34
+ shipOrderStep = defaultOrderStatusLabels.shipOrderStep,
22
35
  }: AccountOrderStatusProps) => {
23
- const { order } = useAccountPageData<AccountOrderDetailsPageData>()
36
+ const { order, orderStatusLabels } =
37
+ useAccountPageData<AccountOrderDetailsPageData>()
24
38
 
25
39
  if (!order) {
26
40
  return null
@@ -31,13 +45,23 @@ const AccountOrderStatus = ({
31
45
  <StatusCard
32
46
  status={order.status as OrderStatusKey}
33
47
  creationDate={order.creationDate}
48
+ statusLabels={orderStatusLabels}
34
49
  labels={{
35
50
  statusTitle,
36
51
  orderPlacedStep,
52
+ approvedStep,
53
+ pendingApprovalStep,
54
+ deniedStep,
55
+ paymentApprovedStep,
37
56
  paymentPendingStep,
57
+ paymentAuthorizationStep,
58
+ paymentDeniedStep,
59
+ readyForDeliveryStep,
38
60
  handlingStep,
61
+ canceledStep,
39
62
  invoicedStep,
40
63
  deliveredStep,
64
+ shipOrderStep,
41
65
  }}
42
66
  />
43
67
  </Section>
@@ -21,6 +21,8 @@ const AccountOrdersList = ({
21
21
  placedOnLabel = defaultListOrdersLabels.placedOnLabel,
22
22
  deliveryByLabel = defaultListOrdersLabels.deliveryByLabel,
23
23
  pendingApprovalLabel = defaultListOrdersLabels.pendingApprovalLabel,
24
+ statusFilterLabel = defaultListOrdersLabels.statusFilterLabel,
25
+ orderDateFilterLabel = defaultListOrdersLabels.orderDateFilterLabel,
24
26
  paginationOfLabel = defaultListOrdersLabels.paginationOfLabel,
25
27
  previousPageLabel = defaultListOrdersLabels.previousPageLabel,
26
28
  nextPageLabel = defaultListOrdersLabels.nextPageLabel,
@@ -61,6 +63,8 @@ const AccountOrdersList = ({
61
63
  placedOnLabel,
62
64
  deliveryByLabel,
63
65
  pendingApprovalLabel,
66
+ statusFilterLabel,
67
+ orderDateFilterLabel,
64
68
  paginationOfLabel,
65
69
  previousPageLabel,
66
70
  nextPageLabel,