@vtex/faststore-plugin-buyer-portal 1.1.87 → 1.1.89
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 +39 -28
- package/README.md +2 -2
- package/cypress/constants.ts +1 -1
- package/cypress/integration/collections.test.ts +9 -5
- package/cypress/integration/credit-cards.test.ts +24 -20
- package/cypress/integration/roles.test.ts +3 -1
- package/cypress/support/commands.ts +1 -1
- package/package.json +1 -1
- package/plugin.config.js +20 -20
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +72 -41
- package/src/features/addresses/data/USA.ts +69 -64
- package/src/features/addresses/data/countries.ts +6 -1
- package/src/features/addresses/data/states.ts +4 -2
- package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +10 -1
- package/src/features/addresses/utils/index.ts +1 -0
- package/src/features/addresses/utils/stateUtils.ts +63 -0
- package/src/features/budgets/components/BudgetAddForm/budget-add-form.scss +9 -3
- package/src/features/budgets/components/BudgetAllocationsSelection/budget-allocations-selection.scss +2 -2
- package/src/features/budgets/components/BudgetAllocationsTable/budget-allocations-table.scss +29 -0
- package/src/features/budgets/components/BudgetDeleteDrawer/budget-delete-drawer.scss +13 -0
- package/src/features/budgets/components/BudgetRemainingBalance/BudgetRemainingBalance.tsx +5 -1
- package/src/features/budgets/components/BudgetRemainingBalance/budget-remaining-balance.scss +18 -1
- package/src/features/budgets/components/BudgetSettingsInfo/budget-settings-info.scss +19 -0
- package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +12 -2
- package/src/features/budgets/components/BudgetsTable/budgets-table.scss +30 -1
- package/src/features/budgets/components/CreateBudgetAllocationDrawer/create-budget-allocation-drawer.scss +22 -6
- package/src/features/budgets/components/CreateBudgetDrawer/create-budget-drawer.scss +15 -6
- package/src/features/budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss +15 -1
- package/src/features/budgets/components/EditBudgetDrawer/edit-budget-drawer.scss +11 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +76 -75
- package/src/features/budgets/layouts/BudgetsDetailsLayout/budget-details-layout.scss +22 -19
- package/src/features/budgets/layouts/BudgetsLayout/budgets-layout.scss +6 -0
- package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/basic-buying-policy-drawer.scss +4 -0
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss +41 -6
- package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx +1 -1
- package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/buying-policy-details-layout.scss +17 -1
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +93 -68
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/add-payment-methods-drawer.scss +66 -30
- package/src/features/payment-methods/components/SearchPaymentMethods/SearchPaymentMethods.tsx +6 -4
- package/src/features/payment-methods/components/SearchPaymentMethods/search-payment-methods.scss +3 -0
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +65 -54
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/payment-methods-layout.scss +121 -103
- package/src/features/shared/components/CustomDropdown/custom-dropdown.scss +5 -0
- package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +1 -1
- package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +1 -1
- package/src/features/shared/components/Pagination/Pagination.tsx +18 -8
- package/src/features/shared/components/Pagination/pagination.scss +14 -0
- package/src/features/shared/layouts/BaseTabsLayout/sidebar-drawer/sidebar-drawer.scss +5 -3
- package/src/features/shared/utils/buyerPortalRoutes.ts +1 -1
- package/src/features/shared/utils/routeLayoutMapping.ts +22 -21
- package/src/pages/org-units.tsx +1 -1
- package/src/pages/user-details.tsx +1 -1
|
@@ -153,8 +153,8 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
153
153
|
role: user?.role ?? "",
|
|
154
154
|
}}
|
|
155
155
|
>
|
|
156
|
-
<
|
|
157
|
-
<
|
|
156
|
+
<div data-fs-bp-budgets-details-layout>
|
|
157
|
+
<header data-fs-bp-budgets-details-header-wrapper>
|
|
158
158
|
<div data-fs-bp-budgets-details-header-arrow>
|
|
159
159
|
<Icon
|
|
160
160
|
name="ArrowPointLeft"
|
|
@@ -189,87 +189,88 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
189
189
|
</DropdownItem>
|
|
190
190
|
</BasicDropdownMenu>
|
|
191
191
|
</Dropdown>
|
|
192
|
-
</
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/>
|
|
198
|
-
|
|
199
|
-
<BudgetSettingsInfoBalance
|
|
200
|
-
initialBudget={budget}
|
|
201
|
-
budgetId={budget.id}
|
|
202
|
-
orgUnitId={orgUnit?.id ?? ""}
|
|
203
|
-
contractId={contract?.id ?? ""}
|
|
204
|
-
/>
|
|
205
|
-
|
|
206
|
-
{hasMounted && (
|
|
207
|
-
<BudgetAllocationsTable
|
|
208
|
-
loading={isAllocationsLoading && !loadingLoadMore}
|
|
209
|
-
data={budgets.allocation.data}
|
|
210
|
-
budgetId={budgets.budget.id}
|
|
211
|
-
orgUnitId={orgUnit?.id ?? ""}
|
|
212
|
-
contractId={contract?.id ?? ""}
|
|
213
|
-
onSearch={setAllocationSearch}
|
|
214
|
-
pagination={{
|
|
215
|
-
current: budgets.allocation.data?.length ?? 0,
|
|
216
|
-
loading: isAllocationsLoading,
|
|
217
|
-
total: budgets.allocation.total,
|
|
218
|
-
loadMore,
|
|
219
|
-
}}
|
|
192
|
+
</header>
|
|
193
|
+
<section data-fs-bp-budgets-details-section>
|
|
194
|
+
<BudgetRemainingBalance
|
|
195
|
+
remaining={budget.remaining}
|
|
196
|
+
total={Number(budget.amount)}
|
|
220
197
|
/>
|
|
221
|
-
)}
|
|
222
198
|
|
|
223
|
-
|
|
224
|
-
|
|
199
|
+
<BudgetSettingsInfoBalance
|
|
200
|
+
initialBudget={budget}
|
|
201
|
+
budgetId={budget.id}
|
|
225
202
|
orgUnitId={orgUnit?.id ?? ""}
|
|
226
203
|
contractId={contract?.id ?? ""}
|
|
227
|
-
budgetName={budget.name}
|
|
228
|
-
budgetId={budget.id}
|
|
229
|
-
redirect={handleBudgetPage}
|
|
230
|
-
isOpen={isDeleteDrawerOpen}
|
|
231
|
-
{...deleteDrawerProps}
|
|
232
204
|
/>
|
|
233
|
-
)}
|
|
234
205
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
206
|
+
{hasMounted && (
|
|
207
|
+
<BudgetAllocationsTable
|
|
208
|
+
loading={isAllocationsLoading && !loadingLoadMore}
|
|
209
|
+
data={budgets.allocation.data}
|
|
210
|
+
budgetId={budgets.budget.id}
|
|
211
|
+
orgUnitId={orgUnit?.id ?? ""}
|
|
212
|
+
contractId={contract?.id ?? ""}
|
|
213
|
+
onSearch={setAllocationSearch}
|
|
214
|
+
pagination={{
|
|
215
|
+
current: budgets.allocation.data?.length ?? 0,
|
|
216
|
+
loading: isAllocationsLoading,
|
|
217
|
+
total: budgets.allocation.total,
|
|
218
|
+
loadMore,
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
)}
|
|
245
222
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
)}
|
|
223
|
+
{isDeleteDrawerOpen && (
|
|
224
|
+
<BudgetDeleteDrawer
|
|
225
|
+
orgUnitId={orgUnit?.id ?? ""}
|
|
226
|
+
contractId={contract?.id ?? ""}
|
|
227
|
+
budgetName={budget.name}
|
|
228
|
+
budgetId={budget.id}
|
|
229
|
+
redirect={handleBudgetPage}
|
|
230
|
+
isOpen={isDeleteDrawerOpen}
|
|
231
|
+
{...deleteDrawerProps}
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
258
234
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
235
|
+
{isAddAllocationDrawerOpen && (
|
|
236
|
+
<CreateBudgetAllocationDrawer
|
|
237
|
+
{...addAllocationDrawerProps}
|
|
238
|
+
allocationList={budgets.allocation.data}
|
|
239
|
+
contractId={contract?.id ?? ""}
|
|
240
|
+
budgetId={budgets.budget.id}
|
|
241
|
+
orgUnitId={orgUnit?.id ?? ""}
|
|
242
|
+
isOpen={isAddAllocationDrawerOpen}
|
|
243
|
+
/>
|
|
244
|
+
)}
|
|
245
|
+
|
|
246
|
+
{isDeleteDrawerOpen && (
|
|
247
|
+
<BudgetDeleteDrawer
|
|
248
|
+
{...deleteDrawerProps}
|
|
249
|
+
isOpen={isDeleteDrawerOpen}
|
|
250
|
+
budgetId={budgets.budget.id}
|
|
251
|
+
budgetName={budgets.budget.name}
|
|
252
|
+
orgUnitId={orgUnit?.id ?? ""}
|
|
253
|
+
contractId={contract?.id ?? ""}
|
|
254
|
+
{...deleteDrawerProps}
|
|
255
|
+
redirect={handleBudgetPage}
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
258
|
+
|
|
259
|
+
{isEditDrawerOpen && (
|
|
260
|
+
<EditBudgetDrawer
|
|
261
|
+
{...editDrawerProps}
|
|
262
|
+
isOpen={isEditDrawerOpen}
|
|
263
|
+
budgetId={budgets.budget.id}
|
|
264
|
+
contractId={contract?.id ?? ""}
|
|
265
|
+
orgUnitId={orgUnit?.id ?? ""}
|
|
266
|
+
initialBudget={{
|
|
267
|
+
...budgets.budget,
|
|
268
|
+
amount: budgets.budget.amount,
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
272
|
+
</section>
|
|
273
|
+
</div>
|
|
273
274
|
</ContractTabsLayout>
|
|
274
275
|
</GlobalLayout>
|
|
275
276
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@import "../../components/EditBudgetDrawer/edit-budget-drawer.scss";
|
|
2
|
-
|
|
2
|
+
@import "../../components/CreateBudgetDrawer/create-budget-drawer.scss";
|
|
3
3
|
@import "../../components/BudgetAllocationsTable/budget-allocations-table.scss";
|
|
4
4
|
@import "../../components/BudgetAllocationsSelection/budget-allocations-selection.scss";
|
|
5
5
|
@import "../../../budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss";
|
|
@@ -18,28 +18,11 @@
|
|
|
18
18
|
@import "../../../shared/components/EmptyState/empty-state.scss";
|
|
19
19
|
@import "../../components/EmptyState.tsx/empty-state.scss";
|
|
20
20
|
|
|
21
|
-
padding: calc(var(--fs-spacing-13) - var(--fs-spacing-0))
|
|
22
|
-
calc(var(--fs-spacing-8) + var(--fs-spacing-0))
|
|
23
|
-
calc(var(--fs-spacing-13) - var(--fs-spacing-0))
|
|
24
|
-
calc(var(--fs-spacing-8) + var(--fs-spacing-0));
|
|
25
|
-
min-height: calc(100vh - calc(var(--fs-spacing-9) + var(--fs-spacing-0)));
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
gap: var(--fs-spacing-6);
|
|
29
|
-
|
|
30
|
-
&[data-fs-bp-basic-drawer] {
|
|
31
|
-
max-width: 60rem !important;
|
|
32
|
-
width: 100% !important;
|
|
33
|
-
& > [data-fs-bp-basic-drawer-footer] {
|
|
34
|
-
justify-content: flex-end !important;
|
|
35
|
-
gap: var(--fs-spacing-1);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
21
|
[data-fs-bp-budgets-details-header-wrapper] {
|
|
40
22
|
display: flex;
|
|
41
23
|
justify-content: space-between;
|
|
42
24
|
align-items: center;
|
|
25
|
+
margin: var(--fs-spacing-6) 0;
|
|
43
26
|
}
|
|
44
27
|
|
|
45
28
|
[data-fs-bp-budgets-details-header-arrow] {
|
|
@@ -54,4 +37,24 @@
|
|
|
54
37
|
cursor: pointer;
|
|
55
38
|
}
|
|
56
39
|
}
|
|
40
|
+
|
|
41
|
+
[data-fs-bp-budgets-details-section] {
|
|
42
|
+
min-height: calc(100vh - calc(var(--fs-spacing-9) + var(--fs-spacing-0)));
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: var(--fs-spacing-6);
|
|
46
|
+
|
|
47
|
+
@include media("<tablet") {
|
|
48
|
+
gap: var(--fs-spacing-4);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&[data-fs-bp-basic-drawer] {
|
|
52
|
+
max-width: 60rem !important;
|
|
53
|
+
width: 100% !important;
|
|
54
|
+
& > [data-fs-bp-basic-drawer-footer] {
|
|
55
|
+
justify-content: flex-end !important;
|
|
56
|
+
gap: var(--fs-spacing-1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
57
60
|
}
|
|
@@ -100,6 +100,12 @@
|
|
|
100
100
|
align-items: center;
|
|
101
101
|
margin-bottom: var(--fs-spacing-4);
|
|
102
102
|
|
|
103
|
+
@include media("<tablet") {
|
|
104
|
+
[data-fs-buyer-portal-internal-search] {
|
|
105
|
+
width: 100%;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
103
109
|
[data-fs-bp-pagination] {
|
|
104
110
|
color: #5c5c5c;
|
|
105
111
|
text-align: right;
|
package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss
CHANGED
|
@@ -11,10 +11,25 @@
|
|
|
11
11
|
@import "../../../shared/components/Paginator/paginator.scss";
|
|
12
12
|
@import "../../../shared/components/EmptyState/empty-state.scss";
|
|
13
13
|
|
|
14
|
-
height: 100%;
|
|
14
|
+
min-height: 100%;
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
|
|
18
|
+
@include media("<=tablet") {
|
|
19
|
+
padding-bottom: 3rem;
|
|
20
|
+
|
|
21
|
+
[data-fs-bp-header-inside] {
|
|
22
|
+
[data-fs-header-inside-button] {
|
|
23
|
+
position: fixed;
|
|
24
|
+
bottom: 20px;
|
|
25
|
+
right: 20px;
|
|
26
|
+
padding: 12px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
z-index: 10;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
[data-fs-empty-state-section] {
|
|
19
34
|
flex: 1;
|
|
20
35
|
color: #858585;
|
|
@@ -24,6 +39,21 @@
|
|
|
24
39
|
display: flex;
|
|
25
40
|
justify-content: space-between;
|
|
26
41
|
padding: 0 0 var(--fs-spacing-4);
|
|
42
|
+
[data-fs-bp-paginator-counter] {
|
|
43
|
+
font-size: var(--fs-text-size-1);
|
|
44
|
+
color: #5c5c5c;
|
|
45
|
+
display: block;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@include media("<=tablet") {
|
|
49
|
+
[data-fs-buyer-portal-internal-search] {
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[data-fs-bp-paginator-counter] {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
27
57
|
}
|
|
28
58
|
|
|
29
59
|
[data-fs-buying-policies-heading] {
|
|
@@ -36,11 +66,16 @@
|
|
|
36
66
|
}
|
|
37
67
|
|
|
38
68
|
[data-fs-bp-buying-policies-paginator] {
|
|
39
|
-
display:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
69
|
+
display: none;
|
|
70
|
+
@include media("<=tablet") {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: space-between;
|
|
74
|
+
margin-top: var(--fs-spacing-0);
|
|
75
|
+
padding: var(--fs-spacing-2) 0;
|
|
76
|
+
font-size: var(--fs-text-size-1);
|
|
77
|
+
color: #5c5c5c;
|
|
78
|
+
}
|
|
44
79
|
}
|
|
45
80
|
|
|
46
81
|
[data-fs-bp-table] {
|
package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export const BuyingPolicyDetailsLayout = ({
|
|
|
51
51
|
</Dropdown>
|
|
52
52
|
</HeaderInside>
|
|
53
53
|
|
|
54
|
-
<div data-fs-buying-policy-details-line>
|
|
54
|
+
<div data-fs-buying-policy-details-line-initial>
|
|
55
55
|
<span data-fs-buying-policy-details-title>Settings</span>
|
|
56
56
|
<button
|
|
57
57
|
type="button"
|
|
@@ -7,8 +7,14 @@
|
|
|
7
7
|
[data-fs-buying-policy-details-section] {
|
|
8
8
|
@import "../../../shared/components/HeaderInside/header-inside.scss";
|
|
9
9
|
@import "../../../shared/components/InternalSearch/internal-search.scss";
|
|
10
|
+
[data-fs-bp-header-inside-title] {
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
text-overflow: ellipsis;
|
|
14
|
+
}
|
|
10
15
|
|
|
11
|
-
[data-fs-buying-policy-details-line]
|
|
16
|
+
[data-fs-buying-policy-details-line],
|
|
17
|
+
[data-fs-buying-policy-details-line-initial] {
|
|
12
18
|
padding: calc(var(--fs-spacing-4) - var(--fs-spacing-0)) 0;
|
|
13
19
|
border-top: var(--fs-border-width) solid #e0e0e0;
|
|
14
20
|
display: flex;
|
|
@@ -17,6 +23,10 @@
|
|
|
17
23
|
border-top: none;
|
|
18
24
|
}
|
|
19
25
|
|
|
26
|
+
@include media("<=tablet") {
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
[data-fs-buying-policy-details-title] {
|
|
21
31
|
font-weight: 600;
|
|
22
32
|
font-size: var(--fs-text-size-2);
|
|
@@ -80,4 +90,10 @@
|
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
}
|
|
93
|
+
|
|
94
|
+
[data-fs-buying-policy-details-line-initial] {
|
|
95
|
+
@include media("<=tablet") {
|
|
96
|
+
flex-direction: row;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
83
99
|
}
|
package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Checkbox, Skeleton, useUI } from "@faststore/ui";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
type BasicDrawerProps,
|
|
9
9
|
BasicDrawer,
|
|
10
|
+
EmptyState,
|
|
10
11
|
Icon,
|
|
11
12
|
} from "../../../shared/components";
|
|
12
13
|
import { useBuyerPortal } from "../../../shared/hooks";
|
|
@@ -49,8 +50,9 @@ export const AddPaymentMethodsDrawer = ({
|
|
|
49
50
|
search: querySearch,
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
const availableMethods =
|
|
53
|
-
(method) => !method?.isEnabled
|
|
53
|
+
const availableMethods = useMemo(
|
|
54
|
+
() => (paymentMethods ?? []).filter((method) => !method?.isEnabled),
|
|
55
|
+
[paymentMethods]
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
const handleSuccess = () => {
|
|
@@ -95,13 +97,10 @@ export const AddPaymentMethodsDrawer = ({
|
|
|
95
97
|
|
|
96
98
|
const toggleItem = useCallback((id: number) => {
|
|
97
99
|
setSelectedMethods((prev) => {
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
newSet.add(id);
|
|
103
|
-
}
|
|
104
|
-
return newSet;
|
|
100
|
+
const next = new Set(prev);
|
|
101
|
+
if (next.has(id)) next.delete(id);
|
|
102
|
+
else next.add(id);
|
|
103
|
+
return next;
|
|
105
104
|
});
|
|
106
105
|
}, []);
|
|
107
106
|
|
|
@@ -116,6 +115,86 @@ export const AddPaymentMethodsDrawer = ({
|
|
|
116
115
|
addPaymentMethods({ customerId, unitId, paymentMethodsIds });
|
|
117
116
|
};
|
|
118
117
|
|
|
118
|
+
const renderListHeader = () => (
|
|
119
|
+
<li
|
|
120
|
+
data-fs-bp-payment-methods-list-title
|
|
121
|
+
data-fs-bp-payment-methods-list-title-drawer
|
|
122
|
+
aria-label="Payment methods header"
|
|
123
|
+
>
|
|
124
|
+
<Checkbox
|
|
125
|
+
data-fs-bp-payment-methods-checkbox
|
|
126
|
+
ref={selectAllRef}
|
|
127
|
+
checked={allSelected}
|
|
128
|
+
onChange={toggleAll}
|
|
129
|
+
disabled={readonly || availableMethods.length === 0}
|
|
130
|
+
aria-label="Select all payment methods"
|
|
131
|
+
/>
|
|
132
|
+
Name
|
|
133
|
+
</li>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const renderList = () => (
|
|
137
|
+
<ul data-fs-payment-methods-list>
|
|
138
|
+
{renderListHeader()}
|
|
139
|
+
{availableMethods.map(({ id, name }) => (
|
|
140
|
+
<li key={id} data-fs-payment-methods-line>
|
|
141
|
+
<div
|
|
142
|
+
data-fs-payment-methods-row
|
|
143
|
+
data-fs-payment-methods-row-selected={selectedMethods.has(id)}
|
|
144
|
+
>
|
|
145
|
+
<div data-fs-payment-methods-row-information>
|
|
146
|
+
<Checkbox
|
|
147
|
+
data-fs-bp-payment-methods-checkbox
|
|
148
|
+
checked={selectedMethods.has(id)}
|
|
149
|
+
onChange={() => toggleItem(id)}
|
|
150
|
+
disabled={readonly}
|
|
151
|
+
aria-label={`Select ${name}`}
|
|
152
|
+
/>
|
|
153
|
+
<span data-fs-payment-methods-row-icon-wrapper>
|
|
154
|
+
<Icon name="AccountBalanceWallet" width={20} height={20} />
|
|
155
|
+
</span>
|
|
156
|
+
<div data-fs-payment-methods-name>{name}</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</li>
|
|
160
|
+
))}
|
|
161
|
+
</ul>
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const renderLoading = () => (
|
|
165
|
+
<div data-fs-payment-methods-loading>
|
|
166
|
+
{Array.from({ length: 5 }).map((_, index) => (
|
|
167
|
+
<Skeleton key={index} size={{ width: "100%", height: "1.5rem" }} />
|
|
168
|
+
))}
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const renderEmpty = () => (
|
|
173
|
+
<EmptyState
|
|
174
|
+
title="No results found"
|
|
175
|
+
description={
|
|
176
|
+
querySearch.length > 0
|
|
177
|
+
? "Try using different terms"
|
|
178
|
+
: "No payment methods found"
|
|
179
|
+
}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const renderBodyContent = () => {
|
|
184
|
+
if (isLoadingPaymentMethods) return renderLoading();
|
|
185
|
+
|
|
186
|
+
if ((paymentMethods?.length ?? 0) === 0) return renderEmpty();
|
|
187
|
+
|
|
188
|
+
if (availableMethods.length > 0) return renderList();
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<EmptyState
|
|
192
|
+
title="All methods already added"
|
|
193
|
+
description="There are no additional payment methods to add for this unit."
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
119
198
|
return (
|
|
120
199
|
<BasicDrawer data-fs-bp-add-payment-methods-drawer close={close} {...props}>
|
|
121
200
|
<BasicDrawer.Heading title="Add payment methods" onClose={close} />
|
|
@@ -134,62 +213,7 @@ export const AddPaymentMethodsDrawer = ({
|
|
|
134
213
|
textSearch={setQuerySearch}
|
|
135
214
|
/>
|
|
136
215
|
|
|
137
|
-
{
|
|
138
|
-
<div data-fs-payment-methods-loading>
|
|
139
|
-
{Array.from({ length: 5 }).map((_, index) => (
|
|
140
|
-
<Skeleton
|
|
141
|
-
key={index}
|
|
142
|
-
size={{ width: "100%", height: "1.5rem" }}
|
|
143
|
-
/>
|
|
144
|
-
))}
|
|
145
|
-
</div>
|
|
146
|
-
) : (
|
|
147
|
-
<ul data-fs-payment-methods-list>
|
|
148
|
-
<div
|
|
149
|
-
data-fs-bp-payment-methods-list-title
|
|
150
|
-
data-fs-bp-payment-methods-list-title-drawer
|
|
151
|
-
>
|
|
152
|
-
<Checkbox
|
|
153
|
-
data-fs-bp-payment-methods-checkbox
|
|
154
|
-
ref={selectAllRef}
|
|
155
|
-
checked={allSelected}
|
|
156
|
-
onChange={toggleAll}
|
|
157
|
-
disabled={readonly}
|
|
158
|
-
aria-label="Select all payment methods"
|
|
159
|
-
/>
|
|
160
|
-
Name
|
|
161
|
-
</div>
|
|
162
|
-
|
|
163
|
-
{availableMethods.map(({ id, name }) => (
|
|
164
|
-
<li key={id} data-fs-payment-methods-line>
|
|
165
|
-
<div
|
|
166
|
-
data-fs-payment-methods-row
|
|
167
|
-
data-fs-payment-methods-row-selected={selectedMethods.has(
|
|
168
|
-
id
|
|
169
|
-
)}
|
|
170
|
-
>
|
|
171
|
-
<div data-fs-payment-methods-row-information>
|
|
172
|
-
<Checkbox
|
|
173
|
-
data-fs-bp-payment-methods-checkbox
|
|
174
|
-
checked={selectedMethods.has(id)}
|
|
175
|
-
onChange={() => toggleItem(id)}
|
|
176
|
-
disabled={readonly}
|
|
177
|
-
aria-label={`Select ${name}`}
|
|
178
|
-
/>
|
|
179
|
-
<span data-fs-payment-methods-row-icon-wrapper>
|
|
180
|
-
<Icon
|
|
181
|
-
name="AccountBalanceWallet"
|
|
182
|
-
width={20}
|
|
183
|
-
height={20}
|
|
184
|
-
/>
|
|
185
|
-
</span>
|
|
186
|
-
<div data-fs-payment-methods-name>{name}</div>
|
|
187
|
-
</div>
|
|
188
|
-
</div>
|
|
189
|
-
</li>
|
|
190
|
-
))}
|
|
191
|
-
</ul>
|
|
192
|
-
)}
|
|
216
|
+
{renderBodyContent()}
|
|
193
217
|
</section>
|
|
194
218
|
</BasicDrawer.Body>
|
|
195
219
|
|
|
@@ -197,11 +221,12 @@ export const AddPaymentMethodsDrawer = ({
|
|
|
197
221
|
<BasicDrawer.Button variant="ghost" onClick={close}>
|
|
198
222
|
Cancel
|
|
199
223
|
</BasicDrawer.Button>
|
|
224
|
+
|
|
200
225
|
<BasicDrawer.Button
|
|
201
226
|
variant="confirm"
|
|
202
227
|
isLoading={isAddPaymentMethodsLoading}
|
|
203
228
|
onClick={handleSubmit}
|
|
204
|
-
disabled={
|
|
229
|
+
disabled={isAddPaymentMethodsLoading || selectedMethods.size === 0}
|
|
205
230
|
>
|
|
206
231
|
Add
|
|
207
232
|
</BasicDrawer.Button>
|