@vtex/faststore-plugin-buyer-portal 1.3.37 → 1.3.38
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 +9 -1
- package/package.json +1 -1
- package/src/features/payment-methods/clients/PaymentMethodsClient.ts +9 -4
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +75 -10
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/add-payment-methods-drawer.scss +17 -0
- package/src/features/payment-methods/hooks/useDebouncedSearchPaymentMethods.ts +4 -4
- package/src/features/payment-methods/hooks/useGetPaymentMethodsByUnitId.ts +2 -3
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +80 -59
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/payment-methods-layout.scss +147 -122
- package/src/features/payment-methods/services/get-payment-methods-by-unit-id.service.ts +7 -5
- package/src/features/payment-methods/types/PaymentMethod.ts +7 -0
- package/src/features/payment-methods/types/index.ts +1 -1
- package/src/features/product-assortment/clients/ProductAssortmentClient.ts +15 -9
- package/src/features/product-assortment/components/AddProductAssortmentDrawer/AddProductAssortmentDrawer.tsx +73 -28
- package/src/features/product-assortment/components/AddProductAssortmentDrawer/add-product-assortment-drawer.scss +4 -0
- package/src/features/product-assortment/components/ProductAssortmentTable/ProductAssortmentTable.tsx +2 -2
- package/src/features/product-assortment/hooks/index.ts +3 -0
- package/src/features/product-assortment/hooks/useGetProductAssortments.ts +35 -0
- package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +33 -13
- package/src/features/product-assortment/services/get-product-assortment-from-contract.service.ts +4 -5
- package/src/features/product-assortment/services/get-product-assortment-from-scope.service.ts +9 -4
- package/src/features/product-assortment/services/index.ts +4 -0
- package/src/features/product-assortment/types/index.ts +19 -14
- package/src/features/shared/utils/constants.ts +1 -1
- package/src/pages/payment-methods.tsx +23 -4
- package/src/pages/productAssortment.tsx +18 -17
package/src/features/payment-methods/layouts/PaymentMethodsLayout/payment-methods-layout.scss
CHANGED
|
@@ -5,129 +5,154 @@
|
|
|
5
5
|
|
|
6
6
|
[data-fs-payment-methods-section] [data-fs-payment-methods-list],
|
|
7
7
|
[data-fs-payment-methods-drawer] [data-fs-payment-methods-list] {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
8
|
+
width: 100%;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
padding-bottom: var(--fs-spacing-3);
|
|
12
|
+
|
|
13
|
+
[data-fs-bp-payment-methods-list-title] {
|
|
14
|
+
color: #5c5c5c;
|
|
15
|
+
margin-bottom: var(--fs-spacing-1);
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: start;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--fs-spacing-3);
|
|
20
|
+
|
|
21
|
+
&[data-fs-bp-payment-methods-list-title-drawer="true"] {
|
|
22
|
+
padding-left: var(--fs-spacing-3);
|
|
23
|
+
padding-right: var(--fs-spacing-3);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[data-fs-payment-methods-line] {
|
|
28
|
+
border-top: var(--fs-border-width) solid #e5e5e5;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-fs-payment-methods-row] {
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
background-color: #f5f5f5;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:visited {
|
|
40
|
+
color: #1f1f1f;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&[data-fs-payment-methods-row-selected="true"] {
|
|
44
|
+
background-color: #f1f8fd;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-fs-payment-methods-row-information] {
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: var(--fs-spacing-2);
|
|
50
|
+
align-items: center;
|
|
51
|
+
margin-left: var(--fs-spacing-3);
|
|
52
|
+
padding: var(--fs-spacing-2) 0;
|
|
53
|
+
size: var(--fs-text-size-1);
|
|
54
|
+
color: #0366dd;
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
flex: 1;
|
|
57
|
+
|
|
58
|
+
[data-fs-payment-methods-row-icon-wrapper] {
|
|
59
|
+
color: #0366dd;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
width: var(--fs-spacing-6);
|
|
64
|
+
height: var(--fs-spacing-6);
|
|
65
|
+
|
|
66
|
+
margin-right: calc(var(--fs-spacing-2) - var(--fs-spacing-0));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[data-fs-payment-methods-name] {
|
|
70
|
+
width: var(--data-fs-users-table-width);
|
|
71
|
+
font-weight: var(--fs-text-weight-medium);
|
|
72
|
+
font-size: var(--fs-text-size-1);
|
|
73
|
+
line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
color: #000;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
[data-fs-payment-methods-section] {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
82
|
+
@import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
|
|
83
|
+
|
|
84
|
+
@import "../../../shared/components/InternalSearch/internal-search.scss";
|
|
85
|
+
@import "../../../shared/components/HeaderInside/header-inside.scss";
|
|
86
|
+
@import "../../../shared/components/Table/table.scss";
|
|
87
|
+
@import "../../../shared/components/EmptyState/empty-state.scss";
|
|
88
|
+
|
|
89
|
+
@include media(">=notebook") {
|
|
90
|
+
padding: 0 calc(var(--fs-spacing-9) - var(--fs-spacing-0));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-fs-payment-methods-tooltip] {
|
|
94
|
+
--fs-tooltip-background: var(--fs-text-color-secondary);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-fs-bp-payment-method-table-row] {
|
|
98
|
+
td:nth-child(3) {
|
|
99
|
+
vertical-align: middle;
|
|
100
|
+
text-align: right;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[data-fs-payment-methods-filter] {
|
|
105
|
+
display: flex;
|
|
106
|
+
justify-content: space-between;
|
|
107
|
+
align-items: center;
|
|
108
|
+
height: 2.5rem;
|
|
109
|
+
|
|
110
|
+
@include media("<=tablet") {
|
|
111
|
+
[data-fs-buyer-portal-internal-search] {
|
|
112
|
+
width: 100%;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[data-fs-bp-paginator-counter] {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
[data-fs-bp-payment-methods-paginator] {
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: space-between;
|
|
125
|
+
margin-top: var(--fs-spacing-0);
|
|
126
|
+
padding: var(--fs-spacing-2) 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[data-fs-bp-payment-methods-search-container-counter-bottom] {
|
|
130
|
+
font-size: var(--fs-text-size-1);
|
|
131
|
+
color: #5c5c5c;
|
|
132
|
+
text-align: end;
|
|
133
|
+
display: none;
|
|
134
|
+
margin-top: var(--fs-spacing-3);
|
|
135
|
+
@include media("<=tablet") {
|
|
136
|
+
display: block;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@include media("<=phonemid") {
|
|
141
|
+
padding-bottom: var(--fs-spacing-7);
|
|
142
|
+
|
|
143
|
+
[data-fs-buyer-portal-internal-search] {
|
|
144
|
+
width: 100% !important;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[data-fs-bp-header-inside] {
|
|
148
|
+
[data-fs-header-inside-button] {
|
|
149
|
+
position: fixed;
|
|
150
|
+
bottom: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
151
|
+
right: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
152
|
+
padding: var(--fs-spacing-2);
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
z-index: 10;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
133
158
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { paymentMethodsClient } from "../clients/PaymentMethodsClient";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { PaginatedPaymentMethod } from "../types";
|
|
4
4
|
|
|
5
5
|
export type GetPaymentMethodsByUnitIdServiceProps = {
|
|
6
6
|
customerId: string;
|
|
@@ -8,6 +8,7 @@ export type GetPaymentMethodsByUnitIdServiceProps = {
|
|
|
8
8
|
cookie: string;
|
|
9
9
|
filterByScope?: boolean;
|
|
10
10
|
search?: string;
|
|
11
|
+
page?: number;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export const getPaymentMethodsByUnitIdService = async ({
|
|
@@ -16,19 +17,20 @@ export const getPaymentMethodsByUnitIdService = async ({
|
|
|
16
17
|
cookie,
|
|
17
18
|
filterByScope,
|
|
18
19
|
search,
|
|
19
|
-
|
|
20
|
+
page = 1,
|
|
21
|
+
}: GetPaymentMethodsByUnitIdServiceProps): Promise<PaginatedPaymentMethod> => {
|
|
20
22
|
try {
|
|
21
23
|
const paymentMethods = await paymentMethodsClient.getPaymentMethodsByUnitId(
|
|
22
24
|
{
|
|
23
25
|
customerId,
|
|
24
26
|
unitId,
|
|
25
27
|
cookie,
|
|
26
|
-
options: { filterByScope, name: search },
|
|
28
|
+
options: { filterByScope, name: search, page: page },
|
|
27
29
|
}
|
|
28
30
|
);
|
|
29
|
-
return paymentMethods
|
|
31
|
+
return paymentMethods;
|
|
30
32
|
} catch (err) {
|
|
31
33
|
console.error("Failed to fetch payment methods", err);
|
|
32
|
-
return
|
|
34
|
+
return {} as PaginatedPaymentMethod;
|
|
33
35
|
}
|
|
34
36
|
};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { PageControl } from "../../product-assortment/types";
|
|
2
|
+
|
|
1
3
|
export type PaymentMethodData = {
|
|
2
4
|
id: number;
|
|
3
5
|
name: string;
|
|
4
6
|
isEnabled?: boolean;
|
|
5
7
|
};
|
|
8
|
+
|
|
9
|
+
export type PaginatedPaymentMethod = {
|
|
10
|
+
items: PaymentMethodData[];
|
|
11
|
+
paging: PageControl;
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./PaymentMethod";
|
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
AddProductAssortmentPayload,
|
|
6
6
|
AddProductAssortmentResponse,
|
|
7
7
|
GetProductAssortmentFromContractResponse,
|
|
8
|
-
GetProductAssortmentFromScopeResponse,
|
|
9
8
|
} from "../types";
|
|
10
9
|
|
|
11
10
|
type DefaultArgs = {
|
|
@@ -19,14 +18,20 @@ export class ProductAssortmentClient extends Client {
|
|
|
19
18
|
super(getApiUrl());
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
getProductAssortmentsInfoInContract(
|
|
22
|
+
args: DefaultArgs & { name?: string; page?: number }
|
|
23
|
+
) {
|
|
24
|
+
const { contractId, cookie, name, unitId, page } = args;
|
|
24
25
|
|
|
25
|
-
return this.get<GetProductAssortmentFromContractResponse
|
|
26
|
-
`customers/${contractId}/units/${unitId}/collections`,
|
|
26
|
+
return this.get<GetProductAssortmentFromContractResponse>(
|
|
27
|
+
`customers/${contractId}/units/${unitId}/collections/paginated`,
|
|
27
28
|
{
|
|
28
29
|
headers: { Cookie: cookie },
|
|
29
|
-
params: {
|
|
30
|
+
params: {
|
|
31
|
+
...(name ? { name } : undefined),
|
|
32
|
+
filterByScope: true,
|
|
33
|
+
...(page ? { page } : undefined),
|
|
34
|
+
},
|
|
30
35
|
}
|
|
31
36
|
);
|
|
32
37
|
}
|
|
@@ -39,14 +44,15 @@ export class ProductAssortmentClient extends Client {
|
|
|
39
44
|
filterByScope: boolean;
|
|
40
45
|
}
|
|
41
46
|
) {
|
|
42
|
-
const { contractId, cookie, name, unitId, filterByScope } = args;
|
|
47
|
+
const { contractId, cookie, name, unitId, filterByScope, page } = args;
|
|
43
48
|
|
|
44
|
-
return this.get<
|
|
45
|
-
`customers/${contractId}/units/${unitId}/collections`,
|
|
49
|
+
return this.get<GetProductAssortmentFromContractResponse>(
|
|
50
|
+
`customers/${contractId}/units/${unitId}/collections/paginated`,
|
|
46
51
|
{
|
|
47
52
|
headers: { Cookie: cookie },
|
|
48
53
|
params: {
|
|
49
54
|
...(name ? { name } : undefined),
|
|
55
|
+
page,
|
|
50
56
|
filterByScope,
|
|
51
57
|
v: new Date().getTime(),
|
|
52
58
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
|
-
import { Link, useUI } from "@faststore/ui";
|
|
5
|
+
import { Link, Skeleton, useUI } from "@faststore/ui";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
BasicDrawer,
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
InternalSearch,
|
|
11
11
|
Paginator,
|
|
12
12
|
} from "../../../shared/components";
|
|
13
|
-
import { useBuyerPortal } from "../../../shared/hooks";
|
|
13
|
+
import { useBuyerPortal, useDebounce } from "../../../shared/hooks";
|
|
14
|
+
import { DEBOUNCE_TIMEOUT } from "../../../shared/utils";
|
|
15
|
+
import { useGetProductAssorments } from "../../hooks";
|
|
14
16
|
import { useAddProductAssortmentToScope } from "../../hooks/useAddProductAssortmentToScope";
|
|
15
17
|
import { AddProductAssortmentDrawerTable } from "../table/AddProductAssortmentDrawerTable";
|
|
16
18
|
|
|
@@ -19,31 +21,46 @@ import type {
|
|
|
19
21
|
ProductAssortmentSummary,
|
|
20
22
|
} from "../../types";
|
|
21
23
|
|
|
22
|
-
export const PAGE_SIZE = 10;
|
|
23
|
-
|
|
24
24
|
export const AddProductAssortmentDrawer = ({
|
|
25
25
|
close,
|
|
26
|
-
productAssortment,
|
|
27
26
|
...props
|
|
28
27
|
}: AddProductAssortmentDrawerProps) => {
|
|
29
28
|
const { pushToast } = useUI();
|
|
30
29
|
const [drawerSearch, setDrawerSearch] = useState("");
|
|
30
|
+
const [drawerPage, setDrawerPage] = useState(1);
|
|
31
31
|
const { currentOrgUnit, currentContract } = useBuyerPortal();
|
|
32
32
|
const { reload } = useRouter();
|
|
33
33
|
|
|
34
|
+
const { productAssortments: productAssortment, isLoadingProductAssortments } =
|
|
35
|
+
useGetProductAssorments({
|
|
36
|
+
contractId: currentContract?.id ?? "",
|
|
37
|
+
unitId: currentOrgUnit?.id ?? "",
|
|
38
|
+
filterByScope: false,
|
|
39
|
+
page: drawerPage,
|
|
40
|
+
name: drawerSearch,
|
|
41
|
+
});
|
|
42
|
+
|
|
34
43
|
const unitId = currentOrgUnit?.id;
|
|
35
44
|
const contractId = currentContract?.id;
|
|
36
|
-
const isLoading =
|
|
45
|
+
const isLoading = isLoadingProductAssortments;
|
|
46
|
+
const [isLastPage, setIsLastPage] = useState(true);
|
|
37
47
|
|
|
38
48
|
useEffect(() => {
|
|
39
49
|
setDrawerSearch("");
|
|
40
50
|
}, [props.isOpen]);
|
|
41
51
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
useDebounce(drawerSearch, DEBOUNCE_TIMEOUT, {
|
|
53
|
+
onDebounce: (value) => {
|
|
54
|
+
setDrawerSearch(value);
|
|
55
|
+
setDrawerPage(1);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (productAssortment?.paging) {
|
|
61
|
+
setIsLastPage(productAssortment.paging.pages === drawerPage);
|
|
62
|
+
}
|
|
63
|
+
}, [productAssortment.paging]);
|
|
47
64
|
|
|
48
65
|
const addProductAssortmentMutation = useAddProductAssortmentToScope();
|
|
49
66
|
|
|
@@ -84,36 +101,64 @@ export const AddProductAssortmentDrawer = ({
|
|
|
84
101
|
|
|
85
102
|
<div data-fs-bp-add-product-assortment-wrapper>
|
|
86
103
|
<InternalSearch
|
|
87
|
-
textSearch={
|
|
88
|
-
|
|
89
|
-
}}
|
|
104
|
+
textSearch={setDrawerSearch}
|
|
105
|
+
defaultValue={drawerSearch}
|
|
90
106
|
/>
|
|
91
107
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
{productAssortment.paging && productAssortment.items.length > 0 && (
|
|
109
|
+
<Paginator.Counter
|
|
110
|
+
total={productAssortment.paging.total}
|
|
111
|
+
itemsLength={
|
|
112
|
+
isLastPage
|
|
113
|
+
? productAssortment.paging.total
|
|
114
|
+
: drawerPage * productAssortment.paging.perPage
|
|
115
|
+
}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
96
118
|
</div>
|
|
97
119
|
<section>
|
|
98
|
-
{
|
|
120
|
+
{isLoading ? (
|
|
121
|
+
<div data-fs-bp-drawer-product-assortment-skeleton>
|
|
122
|
+
<Skeleton size={{ height: "3.5rem", width: "100%" }} />
|
|
123
|
+
</div>
|
|
124
|
+
) : productAssortment.items && productAssortment.items.length ? (
|
|
99
125
|
<div>
|
|
100
126
|
<AddProductAssortmentDrawerTable
|
|
101
|
-
data={
|
|
127
|
+
data={productAssortment.items}
|
|
102
128
|
onChange={setSelectedAssortment}
|
|
103
129
|
/>
|
|
104
|
-
{
|
|
130
|
+
{productAssortment.items.length > 0 && (
|
|
105
131
|
<div data-fs-bp-drawer-product-assortment-paginator>
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
132
|
+
{productAssortment.items.length > 0 &&
|
|
133
|
+
productAssortment.paging.page > 1 ? (
|
|
134
|
+
<Paginator.NextPageButton
|
|
135
|
+
onClick={() => setDrawerPage(drawerPage - 1)}
|
|
136
|
+
disabled={isLoading}
|
|
137
|
+
>
|
|
138
|
+
{isLoading ? "Loading" : "Previous page"}
|
|
139
|
+
</Paginator.NextPageButton>
|
|
140
|
+
) : (
|
|
141
|
+
<></>
|
|
142
|
+
)}
|
|
143
|
+
|
|
144
|
+
{productAssortment.items.length > 0 && !isLastPage ? (
|
|
145
|
+
<Paginator.NextPageButton
|
|
146
|
+
onClick={() => setDrawerPage(drawerPage + 1)}
|
|
147
|
+
disabled={isLoading}
|
|
148
|
+
>
|
|
149
|
+
{isLoading ? "Loading" : "Next page"}
|
|
109
150
|
</Paginator.NextPageButton>
|
|
110
151
|
) : (
|
|
111
|
-
|
|
152
|
+
<></>
|
|
112
153
|
)}
|
|
113
154
|
|
|
114
155
|
<Paginator.Counter
|
|
115
|
-
total={
|
|
116
|
-
itemsLength={
|
|
156
|
+
total={productAssortment.paging.total}
|
|
157
|
+
itemsLength={
|
|
158
|
+
isLastPage
|
|
159
|
+
? productAssortment.paging.total
|
|
160
|
+
: drawerPage * productAssortment.paging.perPage
|
|
161
|
+
}
|
|
117
162
|
/>
|
|
118
163
|
</div>
|
|
119
164
|
)}
|
package/src/features/product-assortment/components/ProductAssortmentTable/ProductAssortmentTable.tsx
CHANGED
|
@@ -11,13 +11,13 @@ import { RemoveProductAssortmentDrawer } from "../RemoveProductAssortmentDrawer/
|
|
|
11
11
|
|
|
12
12
|
import type {
|
|
13
13
|
ProductAssortmentSelectedProps,
|
|
14
|
-
|
|
14
|
+
ProductAssortmentWithAdditionalInformation,
|
|
15
15
|
} from "../../types";
|
|
16
16
|
|
|
17
17
|
export function ProductAssortmentTable({
|
|
18
18
|
productAssortment,
|
|
19
19
|
}: {
|
|
20
|
-
productAssortment:
|
|
20
|
+
productAssortment: ProductAssortmentWithAdditionalInformation[];
|
|
21
21
|
}) {
|
|
22
22
|
const [assortmentSelected, setAssortmentSelected] =
|
|
23
23
|
useState<ProductAssortmentSelectedProps | null>();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type QueryOptions, useQuery } from "../../shared/hooks";
|
|
2
|
+
import {
|
|
3
|
+
getProductAssortmentFromScopeService,
|
|
4
|
+
type GetProductAssortmentFromScopeServiceProps,
|
|
5
|
+
} from "../services";
|
|
6
|
+
import { GetProductAssortmentFromContractResponse } from "../types";
|
|
7
|
+
|
|
8
|
+
export const useGetProductAssorments = (
|
|
9
|
+
params: Omit<GetProductAssortmentFromScopeServiceProps["args"], "cookie">,
|
|
10
|
+
options?: QueryOptions<
|
|
11
|
+
AwaitedType<typeof getProductAssortmentFromScopeService>
|
|
12
|
+
>
|
|
13
|
+
) => {
|
|
14
|
+
const { data, isLoading, error, refetch } = useQuery<
|
|
15
|
+
AwaitedType<typeof getProductAssortmentFromScopeService>
|
|
16
|
+
>(
|
|
17
|
+
`api/search/product-assortments/${JSON.stringify(params)}`,
|
|
18
|
+
(clientContext: { cookie: string }) =>
|
|
19
|
+
getProductAssortmentFromScopeService({
|
|
20
|
+
args: {
|
|
21
|
+
...params,
|
|
22
|
+
cookie: clientContext.cookie,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
options
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
productAssortments: (data ??
|
|
30
|
+
{}) as GetProductAssortmentFromContractResponse,
|
|
31
|
+
isLoadingProductAssortments: isLoading,
|
|
32
|
+
hasProductAssormentsError: error,
|
|
33
|
+
refetchProductAssortments: refetch,
|
|
34
|
+
};
|
|
35
|
+
};
|