@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
@@ -60,6 +60,86 @@
60
60
  "type": "string",
61
61
  "title": "Total Label",
62
62
  "default": "Total"
63
+ },
64
+ "deliveryChannelLabel": {
65
+ "type": "string",
66
+ "title": "Delivery Channel Label",
67
+ "default": "Delivery"
68
+ },
69
+ "pickupChannelLabel": {
70
+ "type": "string",
71
+ "title": "Pickup Channel Label",
72
+ "default": "Pickup"
73
+ },
74
+ "takeAwayChannelLabel": {
75
+ "type": "string",
76
+ "title": "Take Away Channel Label",
77
+ "default": "Take away"
78
+ },
79
+ "businessDaysZeroTemplate": {
80
+ "type": "string",
81
+ "title": "Business Days Zero Template",
82
+ "default": "Today"
83
+ },
84
+ "businessDaysOneTemplate": {
85
+ "type": "string",
86
+ "title": "Business Days One Template",
87
+ "default": "In 1 business day"
88
+ },
89
+ "businessDaysOtherTemplate": {
90
+ "type": "string",
91
+ "title": "Business Days Other Template",
92
+ "default": "Up to {count} business days"
93
+ },
94
+ "daysZeroTemplate": {
95
+ "type": "string",
96
+ "title": "Days Zero Template",
97
+ "default": "Today"
98
+ },
99
+ "daysOneTemplate": {
100
+ "type": "string",
101
+ "title": "Days One Template",
102
+ "default": "In 1 day"
103
+ },
104
+ "daysOtherTemplate": {
105
+ "type": "string",
106
+ "title": "Days Other Template",
107
+ "default": "Up to {count} days"
108
+ },
109
+ "hoursZeroTemplate": {
110
+ "type": "string",
111
+ "title": "Hours Zero Template",
112
+ "default": "Now"
113
+ },
114
+ "hoursOneTemplate": {
115
+ "type": "string",
116
+ "title": "Hours One Template",
117
+ "default": "In 1 hour"
118
+ },
119
+ "hoursOtherTemplate": {
120
+ "type": "string",
121
+ "title": "Hours Other Template",
122
+ "default": "Up to {count} hours"
123
+ },
124
+ "minutesZeroTemplate": {
125
+ "type": "string",
126
+ "title": "Minutes Zero Template",
127
+ "default": "Now"
128
+ },
129
+ "minutesOneTemplate": {
130
+ "type": "string",
131
+ "title": "Minutes One Template",
132
+ "default": "In 1 minute"
133
+ },
134
+ "minutesOtherTemplate": {
135
+ "type": "string",
136
+ "title": "Minutes Other Template",
137
+ "default": "Up to {count} minutes"
138
+ },
139
+ "toNeighborhoodTemplate": {
140
+ "type": "string",
141
+ "title": "To Neighborhood Template",
142
+ "default": "to {neighborhood}"
63
143
  }
64
144
  },
65
145
  "readOnly": false,
@@ -70,6 +70,31 @@
70
70
  "type": "string",
71
71
  "title": "Reject Modal Confirm Text",
72
72
  "default": "Reject"
73
+ },
74
+ "approveSuccessToast": {
75
+ "type": "string",
76
+ "title": "Approve Success Toast",
77
+ "default": "{policy} policy approved successfully."
78
+ },
79
+ "approveErrorToast": {
80
+ "type": "string",
81
+ "title": "Approve Error Toast",
82
+ "default": "Policy couldn't be approved due to a technical issue."
83
+ },
84
+ "rejectSuccessToast": {
85
+ "type": "string",
86
+ "title": "Reject Success Toast",
87
+ "default": "{policy} policy rejected successfully. Order denied."
88
+ },
89
+ "rejectErrorToast": {
90
+ "type": "string",
91
+ "title": "Reject Error Toast",
92
+ "default": "Policy couldn't be rejected due to a technical issue."
93
+ },
94
+ "pendingFurtherApprovalsAlert": {
95
+ "type": "string",
96
+ "title": "Pending Further Approvals Alert",
97
+ "default": "Your approval is recorded. This order is still pending further approvals."
73
98
  }
74
99
  },
75
100
  "readOnly": false,
@@ -61,6 +61,16 @@
61
61
  "title": "Pending Approval Label",
62
62
  "default": "Pending my approval"
63
63
  },
64
+ "statusFilterLabel": {
65
+ "type": "string",
66
+ "title": "Status Filter Label",
67
+ "default": "Status"
68
+ },
69
+ "orderDateFilterLabel": {
70
+ "type": "string",
71
+ "title": "Order Date Filter Label",
72
+ "default": "Order Date"
73
+ },
64
74
  "paginationOfLabel": {
65
75
  "type": "string",
66
76
  "title": "Pagination Of Label",
@@ -16,16 +16,56 @@
16
16
  "title": "Order Placed Step",
17
17
  "default": "Order placed"
18
18
  },
19
+ "approvedStep": {
20
+ "type": "string",
21
+ "title": "Approved Step",
22
+ "default": "Approved"
23
+ },
24
+ "pendingApprovalStep": {
25
+ "type": "string",
26
+ "title": "Pending Approval Step",
27
+ "default": "Pending approval"
28
+ },
29
+ "deniedStep": {
30
+ "type": "string",
31
+ "title": "Denied Step",
32
+ "default": "Denied"
33
+ },
34
+ "paymentApprovedStep": {
35
+ "type": "string",
36
+ "title": "Payment Approved Step",
37
+ "default": "Payment Approved"
38
+ },
19
39
  "paymentPendingStep": {
20
40
  "type": "string",
21
41
  "title": "Payment Pending Step",
22
42
  "default": "Payment Pending"
23
43
  },
44
+ "paymentAuthorizationStep": {
45
+ "type": "string",
46
+ "title": "Payment Authorization Step",
47
+ "default": "Payment authorization"
48
+ },
49
+ "paymentDeniedStep": {
50
+ "type": "string",
51
+ "title": "Payment Denied Step",
52
+ "default": "Payment Denied"
53
+ },
54
+ "readyForDeliveryStep": {
55
+ "type": "string",
56
+ "title": "Ready For Delivery Step",
57
+ "default": "Ready for Delivery"
58
+ },
24
59
  "handlingStep": {
25
60
  "type": "string",
26
61
  "title": "Handling Step",
27
62
  "default": "Handling order"
28
63
  },
64
+ "canceledStep": {
65
+ "type": "string",
66
+ "title": "Canceled Step",
67
+ "default": "Canceled"
68
+ },
29
69
  "invoicedStep": {
30
70
  "type": "string",
31
71
  "title": "Invoiced Step",
@@ -35,6 +75,56 @@
35
75
  "type": "string",
36
76
  "title": "Delivered Step",
37
77
  "default": "Delivered"
78
+ },
79
+ "shipOrderStep": {
80
+ "type": "string",
81
+ "title": "Ship Order Step",
82
+ "default": "Ship order"
83
+ },
84
+ "orderPlacedStatus": {
85
+ "type": "string",
86
+ "title": "Order Placed Status",
87
+ "default": "Order Placed"
88
+ },
89
+ "pendingApprovalStatus": {
90
+ "type": "string",
91
+ "title": "Pending Approval Status",
92
+ "default": "Pending approval"
93
+ },
94
+ "paymentPendingStatus": {
95
+ "type": "string",
96
+ "title": "Payment Pending Status",
97
+ "default": "Payment Pending"
98
+ },
99
+ "paymentApprovedStatus": {
100
+ "type": "string",
101
+ "title": "Payment Approved Status",
102
+ "default": "Payment Approved"
103
+ },
104
+ "paymentDeniedStatus": {
105
+ "type": "string",
106
+ "title": "Payment Denied Status",
107
+ "default": "Payment Denied"
108
+ },
109
+ "readyForDeliveryStatus": {
110
+ "type": "string",
111
+ "title": "Ready For Delivery Status",
112
+ "default": "Ready for Delivery"
113
+ },
114
+ "invoicedStatus": {
115
+ "type": "string",
116
+ "title": "Invoiced Status",
117
+ "default": "Invoiced"
118
+ },
119
+ "cancellationRequestedStatus": {
120
+ "type": "string",
121
+ "title": "Cancellation Requested Status",
122
+ "default": "Cancellation Requested"
123
+ },
124
+ "canceledStatus": {
125
+ "type": "string",
126
+ "title": "Canceled Status",
127
+ "default": "Canceled"
38
128
  }
39
129
  },
40
130
  "readOnly": false,
@@ -20,6 +20,31 @@
20
20
  "type": "string",
21
21
  "title": "Interest Label",
22
22
  "default": "Interest"
23
+ },
24
+ "itemsTotalLabel": {
25
+ "type": "string",
26
+ "title": "Items Total Label",
27
+ "default": "Items Total"
28
+ },
29
+ "discountsTotalLabel": {
30
+ "type": "string",
31
+ "title": "Discounts Total Label",
32
+ "default": "Discounts Total"
33
+ },
34
+ "shippingTotalLabel": {
35
+ "type": "string",
36
+ "title": "Shipping Total Label",
37
+ "default": "Shipping Total"
38
+ },
39
+ "taxTotalLabel": {
40
+ "type": "string",
41
+ "title": "Tax Total Label",
42
+ "default": "Tax Total"
43
+ },
44
+ "changeTotalLabel": {
45
+ "type": "string",
46
+ "title": "Change Total Label",
47
+ "default": "Change Total"
23
48
  }
24
49
  },
25
50
  "readOnly": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "4.8.1-dev.0",
3
+ "version": "4.8.1-dev.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -71,11 +71,11 @@
71
71
  "style-loader": "^3.3.1",
72
72
  "swr": "^2.2.5",
73
73
  "use-sync-external-store": "^1.6.0",
74
- "@faststore/api": "4.8.1-dev.0",
75
- "@faststore/sdk": "4.8.1-dev.0",
76
- "@faststore/ui": "4.8.1-dev.0",
77
- "@faststore/lighthouse": "4.8.1-dev.0",
78
- "@faststore/diagnostics": "4.8.1-dev.0"
74
+ "@faststore/api": "4.8.1-dev.2",
75
+ "@faststore/diagnostics": "4.8.1-dev.2",
76
+ "@faststore/sdk": "4.8.1-dev.2",
77
+ "@faststore/lighthouse": "4.8.1-dev.2",
78
+ "@faststore/ui": "4.8.1-dev.2"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@cypress/code-coverage": "^3.12.1",
@@ -12,16 +12,12 @@ export type ContractSwitcherProps = {
12
12
  onClose: () => void
13
13
  }
14
14
 
15
- /**
16
- * Contract that can be displayed by the switcher. `isDefault` is optional so the
17
- * component compiles against both the local mock and the real
18
- * `useAvailableContracts` hook (which does not expose a default yet).
19
- */
15
+ /** Contract that can be displayed by the switcher. */
20
16
  type SwitcherContract = {
21
17
  id: string
22
18
  corporateName: string
23
19
  isActive: boolean
24
- isDefault?: boolean
20
+ isDefault: boolean
25
21
  }
26
22
 
27
23
  const initialOf = (name: string) => name.trim().charAt(0).toUpperCase()
@@ -73,6 +69,7 @@ const ContractSwitcherCurrentSession = ({
73
69
  name="Star"
74
70
  width={20}
75
71
  height={20}
72
+ aria-label="Default contract"
76
73
  />
77
74
  )}
78
75
  </div>
@@ -159,6 +156,7 @@ const ContractSwitcherOptionList = ({
159
156
  name="Star"
160
157
  width={20}
161
158
  height={20}
159
+ aria-label="Default contract"
162
160
  />
163
161
  )}
164
162
  </button>
@@ -2,6 +2,7 @@ import { SlideOver, useFadeEffect } from '@faststore/ui'
2
2
  import { useEffect, useState } from 'react'
3
3
 
4
4
  import { getStoreURL } from 'src/sdk/localization/useLocalizationConfig'
5
+ import { useAvailableContracts } from 'src/sdk/account/useAvailableContracts'
5
6
  import { useSession } from 'src/sdk/session'
6
7
  import {
7
8
  expireCookieClient,
@@ -23,6 +24,8 @@ type OrganizationDrawerProps = {
23
24
  isOpen: boolean
24
25
  closeDrawer: () => void
25
26
  isRepresentative: boolean
27
+ /** Open straight into the contract switcher (My Account "Switch" button). */
28
+ initialView?: OrganizationDrawerView
26
29
  }
27
30
 
28
31
  const clearBrowserStorageForCurrentDomain = async () => {
@@ -140,16 +143,17 @@ export const OrganizationDrawer = ({
140
143
  isOpen,
141
144
  closeDrawer,
142
145
  isRepresentative,
146
+ initialView = 'menu',
143
147
  }: OrganizationDrawerProps) => {
144
148
  const { fade, fadeOut } = useFadeEffect()
145
149
  const { b2b, person } = useSession()
146
- const [view, setView] = useState<OrganizationDrawerView>('menu')
150
+ const [view, setView] = useState<OrganizationDrawerView>(initialView)
147
151
 
148
152
  useEffect(() => {
149
153
  if (!isOpen) {
150
- setView('menu')
154
+ setView(initialView)
151
155
  }
152
- }, [isOpen])
156
+ }, [isOpen, initialView])
153
157
 
154
158
  const contractName =
155
159
  b2b?.contractName?.trim() ||
@@ -168,6 +172,16 @@ export const OrganizationDrawer = ({
168
172
  const canSwitchContract = Boolean(b2b?.unitId)
169
173
  const isOrgMember = Boolean(b2b?.unitId)
170
174
 
175
+ // Only fetch the contract list while the drawer is open for an org member,
176
+ // so nothing is requested on initial page render (TTFB budget).
177
+ const { contracts } = useAvailableContracts(isOpen && canSwitchContract)
178
+ const activeContractId = b2b?.customerId?.trim() ?? ''
179
+ const activeContract =
180
+ (activeContractId
181
+ ? contracts.find((contract) => contract.id === activeContractId)
182
+ : undefined) ?? contracts.find((contract) => contract.isActive)
183
+ const isActiveContractDefault = Boolean(activeContract?.isDefault)
184
+
171
185
  return (
172
186
  <SlideOver
173
187
  data-fs-organization-drawer
@@ -190,6 +204,7 @@ export const OrganizationDrawer = ({
190
204
  onCloseDrawer={closeDrawer}
191
205
  contractName={contractName}
192
206
  contractUrl={contractUrl}
207
+ isDefault={isActiveContractDefault}
193
208
  onChangeContract={
194
209
  canSwitchContract ? () => setView('switch') : undefined
195
210
  }
@@ -1,4 +1,5 @@
1
1
  import { Icon, IconButton, Link } from '@faststore/ui'
2
+ import { useAccountNavigationLabels } from 'src/sdk/account/accountPageContext'
2
3
 
3
4
  export interface OrganizationDrawerFooterProps {
4
5
  orgName: string
@@ -6,6 +7,8 @@ export interface OrganizationDrawerFooterProps {
6
7
  userEmail?: string
7
8
  showManageLink?: boolean
8
9
  manageUrl?: string
10
+ manageLabel?: string
11
+ logoutLabel?: string
9
12
  onLogoutClick?: () => void
10
13
  }
11
14
 
@@ -15,8 +18,16 @@ export const OrganizationDrawerFooter = ({
15
18
  userEmail,
16
19
  showManageLink,
17
20
  manageUrl,
21
+ manageLabel: manageLabelProp,
22
+ logoutLabel: logoutLabelProp,
18
23
  onLogoutClick,
19
24
  }: OrganizationDrawerFooterProps) => {
25
+ const navigationLabels = useAccountNavigationLabels()
26
+ const manageLabel =
27
+ manageLabelProp ?? navigationLabels?.manageLabel ?? 'Manage'
28
+ const logoutLabel =
29
+ logoutLabelProp ?? navigationLabels?.logoutLabel ?? 'Logout'
30
+
20
31
  return (
21
32
  <div data-fs-organization-drawer-footer>
22
33
  <div data-fs-organization-drawer-footer-org>
@@ -31,7 +42,7 @@ export const OrganizationDrawerFooter = ({
31
42
  </div>
32
43
  {showManageLink && manageUrl && (
33
44
  <Link href={manageUrl} data-fs-organization-drawer-footer-manage>
34
- Manage
45
+ {manageLabel}
35
46
  </Link>
36
47
  )}
37
48
  </div>
@@ -45,7 +56,7 @@ export const OrganizationDrawerFooter = ({
45
56
  </div>
46
57
  <IconButton
47
58
  data-fs-organization-drawer-footer-logout
48
- aria-label="Log out"
59
+ aria-label={logoutLabel}
49
60
  icon={<Icon name="SignOut" width={20} height={20} />}
50
61
  onClick={onLogoutClick}
51
62
  />
@@ -59,6 +59,7 @@ export const OrganizationDrawerHeader = ({
59
59
  name="Star"
60
60
  width={20}
61
61
  height={20}
62
+ aria-label="Default contract"
62
63
  />
63
64
  )}
64
65
  {onChangeContract && (
@@ -128,6 +128,10 @@
128
128
  [data-fs-organization-drawer-header-default] {
129
129
  flex-shrink: 0;
130
130
  color: var(--fs-color-link);
131
+
132
+ // The Star symbol only declares stroke="currentColor", so without this
133
+ // the fill falls back to the SVG default (black).
134
+ fill: currentColor;
131
135
  }
132
136
 
133
137
  [data-fs-organization-drawer-header-change] {
@@ -331,6 +335,9 @@
331
335
  [data-fs-contract-switcher-default] {
332
336
  flex-shrink: 0;
333
337
  color: var(--fs-color-link);
338
+
339
+ // See the drawer header star: the symbol carries no fill of its own.
340
+ fill: currentColor;
334
341
  }
335
342
 
336
343
  // Footer: Cancel / Confirm
@@ -13,21 +13,19 @@ export const OrganizationSignInButton = ({
13
13
  }) => {
14
14
  const [isOpen, setIsOpen] = useState(false)
15
15
 
16
- const { person } = useSession()
16
+ const { person, b2b } = useSession()
17
17
  const navigationLabels = useAccountNavigationLabels()
18
18
  const companyLabel = navigationLabels?.companyLabel ?? 'Company'
19
19
  const contractLabel = navigationLabels?.contractLabel ?? 'Contract'
20
+ const activeContractName = b2b?.contractName?.trim()
21
+ const label =
22
+ activeContractName || (person?.id ? companyLabel : contractLabel)
20
23
 
21
24
  const openDrawer = (
22
25
  event: MouseEvent<HTMLAnchorElement> | MouseEvent<HTMLButtonElement>
23
26
  ) => {
24
- // if (session.person) {
25
- // biome-ignore lint/correctness/noConstantCondition: <explanation>
26
- if (true) {
27
- event.preventDefault()
28
-
29
- setIsOpen(true)
30
- }
27
+ event.preventDefault()
28
+ setIsOpen(true)
31
29
  }
32
30
 
33
31
  const closeDrawer = () => {
@@ -45,7 +43,7 @@ export const OrganizationSignInButton = ({
45
43
  icon={<Icon name={icon} width={18} height={18} weight="bold" />}
46
44
  iconPosition="left"
47
45
  >
48
- {person?.id ? companyLabel : contractLabel}
46
+ {label}
49
47
  </Button>
50
48
 
51
49
  {isOpen && (
@@ -1,10 +1,13 @@
1
1
  import { Button } from '@faststore/ui'
2
2
  import { useRouter } from 'next/router'
3
+ import { useState } from 'react'
3
4
 
4
5
  import Link from 'src/components/ui/Link'
5
6
  import styles from '../section.module.scss'
6
7
 
8
+ import { OrganizationDrawer } from '../Drawer/OrganizationDrawer/OrganizationDrawer'
7
9
  import { useAccountNavigationLabels } from 'src/sdk/account/accountPageContext'
10
+ import { useSession } from 'src/sdk/session'
8
11
  import useScreenResize from 'src/sdk/ui/useScreenResize'
9
12
 
10
13
  interface NavItem {
@@ -43,6 +46,9 @@ const Menu = ({ avatarImageUrl, accountName, items }: MenuProps) => {
43
46
  const { isDesktop } = useScreenResize()
44
47
  const navigationLabels = useAccountNavigationLabels()
45
48
  const switchLabel = navigationLabels?.switchLabel ?? 'Switch'
49
+ const { b2b } = useSession()
50
+ const [isSwitcherOpen, setIsSwitcherOpen] = useState(false)
51
+ const canSwitchContract = Boolean(b2b?.unitId)
46
52
 
47
53
  return (
48
54
  <div className={styles.menu}>
@@ -56,16 +62,27 @@ const Menu = ({ avatarImageUrl, accountName, items }: MenuProps) => {
56
62
  )}
57
63
  <h2>{accountName}</h2>
58
64
  </div>
59
- <Button
60
- className={styles.switchButton}
61
- variant="secondary"
62
- size="small"
63
- >
64
- {switchLabel}
65
- </Button>
65
+ {canSwitchContract && (
66
+ <Button
67
+ className={styles.switchButton}
68
+ variant="secondary"
69
+ size="small"
70
+ onClick={() => setIsSwitcherOpen(true)}
71
+ >
72
+ {switchLabel}
73
+ </Button>
74
+ )}
66
75
  </div>
67
76
  ) : null}
68
77
  <Nav items={items} />
78
+ {isSwitcherOpen && (
79
+ <OrganizationDrawer
80
+ isOpen
81
+ closeDrawer={() => setIsSwitcherOpen(false)}
82
+ isRepresentative={Boolean(b2b?.isRepresentative)}
83
+ initialView="switch"
84
+ />
85
+ )}
69
86
  </div>
70
87
  )
71
88
  }
@@ -3,6 +3,10 @@ import { useMemo } from 'react'
3
3
  import type { SelectedFacet } from 'src/sdk/search/useMyAccountFilter'
4
4
 
5
5
  export interface FilterFacetPendingApprovalProps {
6
+ /**
7
+ * Localized label shown next to the toggle.
8
+ */
9
+ label: string
6
10
  /**
7
11
  * Current selected facets from filter context
8
12
  */
@@ -14,9 +18,10 @@ export interface FilterFacetPendingApprovalProps {
14
18
  }
15
19
 
16
20
  function FilterFacetPendingApproval({
21
+ label,
17
22
  selected,
18
23
  dispatch,
19
- }: FilterFacetPendingApprovalProps) {
24
+ }: Readonly<FilterFacetPendingApprovalProps>) {
20
25
  const isSelected = useMemo(
21
26
  () =>
22
27
  selected.some((f) => f.key === 'pendingMyApproval' && f.value === 'true'),
@@ -52,9 +57,9 @@ function FilterFacetPendingApproval({
52
57
  testId="pending-approval-toggle"
53
58
  checked={isSelected}
54
59
  onChange={handleToggleChange}
55
- aria-label="Filter orders pending approval"
60
+ aria-label={label}
56
61
  />
57
- <label htmlFor="pending-approval-toggle">Pending my approval</label>
62
+ <label htmlFor="pending-approval-toggle">{label}</label>
58
63
  </div>
59
64
  )
60
65
  }
@@ -220,6 +220,7 @@ function FilterSlider({
220
220
  )}
221
221
  {type === 'StoreFacetPendingApproval' && isExpanded && (
222
222
  <FilterFacetPendingApproval
223
+ label={label}
223
224
  selected={selected}
224
225
  dispatch={dispatch}
225
226
  />
@@ -111,7 +111,7 @@ function getAllFacets({
111
111
  {
112
112
  __typename: 'StoreFacetBoolean',
113
113
  key: 'status',
114
- label: 'Status',
114
+ label: labels.statusFilterLabel,
115
115
  values: FastStoreOrderStatus.map((status, index) => ({
116
116
  label: statusFacetLabels[index] ?? status,
117
117
  quantity: 0,
@@ -122,7 +122,7 @@ function getAllFacets({
122
122
  {
123
123
  __typename: 'StoreFacetRange',
124
124
  key: 'dateRange',
125
- label: 'Order Date',
125
+ label: labels.orderDateFilterLabel,
126
126
  from: filters.dateInitial,
127
127
  to: filters.dateFinal,
128
128
  },
@@ -13,6 +13,8 @@ export type ListOrdersSectionLabels = {
13
13
  placedOnLabel?: string
14
14
  deliveryByLabel?: string
15
15
  pendingApprovalLabel?: string
16
+ statusFilterLabel?: string
17
+ orderDateFilterLabel?: string
16
18
  paginationOfLabel?: string
17
19
  previousPageLabel?: string
18
20
  nextPageLabel?: string
@@ -44,6 +46,8 @@ export const defaultListOrdersLabels: Required<ListOrdersSectionLabels> = {
44
46
  placedOnLabel: 'Placed on',
45
47
  deliveryByLabel: 'Delivery by',
46
48
  pendingApprovalLabel: 'Pending my approval',
49
+ statusFilterLabel: 'Status',
50
+ orderDateFilterLabel: 'Order Date',
47
51
  paginationOfLabel: 'of',
48
52
  previousPageLabel: 'Previous Page',
49
53
  nextPageLabel: 'Next Page',