@vtex/faststore-plugin-buyer-portal 1.1.26 → 1.1.28
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/package.json +1 -1
- package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx +5 -0
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +31 -13
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss +10 -0
- package/src/features/buying-policies/services/get-buying-policies.service.ts +26 -8
- package/src/features/collections/clients/CollectionsClient.ts +3 -2
- package/src/features/collections/hooks/useGetCollectionsFromContract.ts +2 -0
- package/src/features/shared/components/EmptyState/EmptyState.tsx +1 -1
- package/src/features/shared/components/index.ts +2 -0
- package/src/pages/collections.tsx +5 -1
package/package.json
CHANGED
package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx
CHANGED
|
@@ -5,9 +5,13 @@ import { useUI } from "@faststore/ui";
|
|
|
5
5
|
import { BasicBuyingPolicyDrawer, type BasicBuyingPolicyDrawerProps } from "..";
|
|
6
6
|
import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
7
7
|
import { useAddBuyingPolicy } from "../../hooks";
|
|
8
|
+
import { buyingPolicyDefault } from "../../utils";
|
|
8
9
|
|
|
9
10
|
import type { BuyingPolicy } from "../../types";
|
|
10
11
|
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
const { id, ...defaultBuyingPolicyValues } = buyingPolicyDefault;
|
|
14
|
+
|
|
11
15
|
export type AddBuyingPolicyDrawerProps = Omit<
|
|
12
16
|
BasicBuyingPolicyDrawerProps,
|
|
13
17
|
"children"
|
|
@@ -80,6 +84,7 @@ export const AddBuyingPolicyDrawer = ({
|
|
|
80
84
|
}
|
|
81
85
|
orgUnitId={orgUnitId}
|
|
82
86
|
contractId={contractId}
|
|
87
|
+
initialValues={defaultBuyingPolicyValues}
|
|
83
88
|
{...props}
|
|
84
89
|
/>
|
|
85
90
|
);
|
|
@@ -2,7 +2,11 @@ import { useEffect } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
EmptyState,
|
|
7
|
+
HeaderInside,
|
|
8
|
+
InternalSearch,
|
|
9
|
+
} from "../../../shared/components";
|
|
6
10
|
import { Paginator } from "../../../shared/components";
|
|
7
11
|
import { Table } from "../../../shared/components/Table/Table";
|
|
8
12
|
import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
|
|
@@ -97,15 +101,29 @@ export const BuyingPoliciesLayout = ({
|
|
|
97
101
|
/>
|
|
98
102
|
</div>
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
<Table
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
{isLoading ? (
|
|
105
|
+
<Table>
|
|
106
|
+
<Table.Head
|
|
107
|
+
columns={getTableColumns({
|
|
108
|
+
withType: false,
|
|
109
|
+
withActions: false,
|
|
110
|
+
})}
|
|
111
|
+
/>{" "}
|
|
112
|
+
<Table.Body>
|
|
106
113
|
<Table.Loading />
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
</Table.Body>
|
|
115
|
+
</Table>
|
|
116
|
+
) : buyingPolicies.length === 0 ? (
|
|
117
|
+
<EmptyState
|
|
118
|
+
title="No buying policies yet"
|
|
119
|
+
iconName="Rebase"
|
|
120
|
+
iconSize={40}
|
|
121
|
+
/>
|
|
122
|
+
) : (
|
|
123
|
+
<Table>
|
|
124
|
+
<Table.Head columns={getTableColumns({ withType: false })} />
|
|
125
|
+
<Table.Body>
|
|
126
|
+
{buyingPolicies.map((buyingPolicy) => (
|
|
109
127
|
<Table.Row
|
|
110
128
|
key={buyingPolicy.id}
|
|
111
129
|
title={buyingPolicy.name}
|
|
@@ -125,10 +143,10 @@ export const BuyingPoliciesLayout = ({
|
|
|
125
143
|
/>
|
|
126
144
|
}
|
|
127
145
|
/>
|
|
128
|
-
))
|
|
129
|
-
|
|
130
|
-
</Table
|
|
131
|
-
|
|
146
|
+
))}
|
|
147
|
+
</Table.Body>
|
|
148
|
+
</Table>
|
|
149
|
+
)}
|
|
132
150
|
|
|
133
151
|
<div data-fs-bp-buying-policies-paginator>
|
|
134
152
|
{totalBuyingPolicies > buyingPolicies.length ? (
|
package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss
CHANGED
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
@import "../../../shared/components/Table/table.scss";
|
|
10
10
|
@import "../../../shared/components/LevelDivider/level-divider.scss";
|
|
11
11
|
@import "../../../shared/components/Paginator/paginator.scss";
|
|
12
|
+
@import "../../../shared/components/EmptyState/empty-state.scss";
|
|
13
|
+
|
|
14
|
+
height: 100%;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
|
|
18
|
+
[data-fs-empty-state-section] {
|
|
19
|
+
flex: 1;
|
|
20
|
+
color: #858585;
|
|
21
|
+
}
|
|
12
22
|
|
|
13
23
|
[data-fs-buying-policies-filter] {
|
|
14
24
|
display: flex;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buyingPoliciesClient } from "../clients/BuyingPoliciesClient";
|
|
2
|
+
import { BuyingPolicy } from "../types";
|
|
2
3
|
|
|
3
4
|
export type GetBuyingPoliciesServiceProps = {
|
|
4
5
|
orgUnitId: string;
|
|
@@ -14,12 +15,29 @@ export const getBuyingPoliciesService = async ({
|
|
|
14
15
|
contractId,
|
|
15
16
|
cookie,
|
|
16
17
|
orgUnitId,
|
|
17
|
-
}: GetBuyingPoliciesServiceProps)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
}: GetBuyingPoliciesServiceProps): Promise<{
|
|
19
|
+
data: BuyingPolicy[];
|
|
20
|
+
total: number;
|
|
21
|
+
}> => {
|
|
22
|
+
try {
|
|
23
|
+
return await buyingPoliciesClient.getBuyingPoliciesByOrgUnitId(
|
|
24
|
+
contractId,
|
|
25
|
+
orgUnitId,
|
|
26
|
+
cookie,
|
|
27
|
+
search,
|
|
28
|
+
page
|
|
29
|
+
);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error("Error in getBuyingPoliciesService:", {
|
|
32
|
+
error,
|
|
33
|
+
orgUnitId,
|
|
34
|
+
contractId,
|
|
35
|
+
errorMessage: (error as { message?: string })?.message,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
data: [],
|
|
40
|
+
total: 0,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
25
43
|
};
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
type DefaultArgs = {
|
|
11
11
|
contractId: string;
|
|
12
12
|
cookie: string;
|
|
13
|
+
unitId: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export type UpdateCollectionsPayload = Array<{ name: string }>;
|
|
@@ -21,10 +22,10 @@ export class CollectionsClient extends Client {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
getCollectionFromContract(args: DefaultArgs & { name?: string }) {
|
|
24
|
-
const { contractId, cookie, name } = args;
|
|
25
|
+
const { contractId, cookie, name, unitId } = args;
|
|
25
26
|
|
|
26
27
|
return this.get<GetCollectionsFromContractResponse["collections"]>(
|
|
27
|
-
`customers/${contractId}/collections`,
|
|
28
|
+
`customers/${contractId}/units/${unitId}/collections`,
|
|
28
29
|
{
|
|
29
30
|
headers: { Cookie: cookie },
|
|
30
31
|
params: { ...(name ? { name } : undefined), filteredByContract: false },
|
|
@@ -2,6 +2,7 @@ import { QueryOptions, useQuery } from "../../shared/hooks";
|
|
|
2
2
|
import { getCollectionsFromContractService } from "../services/get-collections-from-contract.service";
|
|
3
3
|
|
|
4
4
|
export const useGetCollectionsFromContract = (
|
|
5
|
+
unitId: string,
|
|
5
6
|
contractId: string,
|
|
6
7
|
options?: QueryOptions<AwaitedType<typeof getCollectionsFromContractService>>
|
|
7
8
|
) => {
|
|
@@ -9,6 +10,7 @@ export const useGetCollectionsFromContract = (
|
|
|
9
10
|
`collections/get-collections-from-contract`,
|
|
10
11
|
({ cookie }) =>
|
|
11
12
|
getCollectionsFromContractService({
|
|
13
|
+
unitId,
|
|
12
14
|
contractId,
|
|
13
15
|
cookie,
|
|
14
16
|
}),
|
|
@@ -75,3 +75,5 @@ export {
|
|
|
75
75
|
export { Paginator } from "./Paginator/Paginator";
|
|
76
76
|
export type { CounterProps as PaginatorCounterProps } from "./Paginator/Counter";
|
|
77
77
|
export type { NextPageButtonProps as PaginatorNextPageButtonProps } from "./Paginator/NextPageButton";
|
|
78
|
+
|
|
79
|
+
export { EmptyState, type EmptyStateProps } from "./EmptyState/EmptyState";
|
|
@@ -66,7 +66,11 @@ export async function loader(
|
|
|
66
66
|
filterByScope: false,
|
|
67
67
|
page: 1,
|
|
68
68
|
}),
|
|
69
|
-
getCollectionsFromContractService({
|
|
69
|
+
getCollectionsFromContractService({
|
|
70
|
+
contractId,
|
|
71
|
+
cookie,
|
|
72
|
+
unitId: orgUnitId,
|
|
73
|
+
}),
|
|
70
74
|
]);
|
|
71
75
|
|
|
72
76
|
const isContractEmpty = contractCollections.every((c) => !c.inContract);
|