@vtex/faststore-plugin-buyer-portal 1.3.5 → 1.3.6

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 (60) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/cypress/constants.ts +2 -0
  3. package/cypress/integration/organizational-units.test.ts +1 -1
  4. package/cypress/integration/{collections.test.ts → product-assortment.test.ts} +54 -50
  5. package/cypress/integration/profile.test.ts +1 -1
  6. package/cypress/integration/users.test.ts +9 -0
  7. package/package.json +1 -1
  8. package/plugin.config.js +2 -2
  9. package/src/features/{collections/clients/CollectionsClient.ts → product-assortment/clients/ProductAssortmentClient.ts} +18 -20
  10. package/src/features/product-assortment/components/AddProductAssortmentDrawer/AddProductAssortmentDrawer.tsx +144 -0
  11. package/src/features/{collections/components/AddCollectionsDrawer/add-collections-drawer.scss → product-assortment/components/AddProductAssortmentDrawer/add-product-assortment-drawer.scss} +9 -10
  12. package/src/features/product-assortment/components/ProductAssortmentTable/ProductAssortmentTable.tsx +99 -0
  13. package/src/features/product-assortment/components/ProductAssortmentTable/product-assortment-table.scss +45 -0
  14. package/src/features/{collections/components/RemoveCollectionDrawer/RemoveCollectionDrawer.tsx → product-assortment/components/RemoveProductAssortmentDrawer/RemoveProductAssortmentDrawer.tsx} +21 -20
  15. package/src/features/product-assortment/components/RemoveProductAssortmentDrawer/remove-product-assortment-drawer.scss +9 -0
  16. package/src/features/product-assortment/components/index.tsx +2 -0
  17. package/src/features/{collections/components/table/AddCollectionsDrawerTable.tsx → product-assortment/components/table/AddProductAssortmentDrawerTable.tsx} +9 -9
  18. package/src/features/product-assortment/components/table/add-product-assortment-drawer-table.scss +14 -0
  19. package/src/features/product-assortment/hooks/useAddProductAssortmentToScope.ts +25 -0
  20. package/src/features/product-assortment/hooks/useRemoveProductAssortmentFromScope.ts +26 -0
  21. package/src/features/{collections/layouts/CollectionsLayout/CollectionsLayout.tsx → product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx} +43 -49
  22. package/src/features/{collections/layouts/CollectionsLayout/collections-layout.scss → product-assortment/layouts/ProductAssortmentLayout/product-assortment-layout.scss} +7 -7
  23. package/src/features/product-assortment/layouts/index.ts +1 -0
  24. package/src/features/product-assortment/services/add-product-assortment-to-scope.service.ts +16 -0
  25. package/src/features/product-assortment/services/get-product-assortment-from-contract.service.ts +13 -0
  26. package/src/features/product-assortment/services/get-product-assortment-from-scope.service.ts +28 -0
  27. package/src/features/product-assortment/services/remove-product-assortment-from-scope.ts +9 -0
  28. package/src/features/product-assortment/types/index.ts +80 -0
  29. package/src/features/shared/utils/buyerPortalRoutes.ts +5 -2
  30. package/src/features/shared/utils/constants.ts +1 -1
  31. package/src/features/shared/utils/getContractSettingsLinks.ts +2 -2
  32. package/src/features/shared/utils/routeLayoutMapping.ts +2 -2
  33. package/src/features/users/clients/UsersClient.ts +2 -0
  34. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +19 -2
  35. package/src/features/users/components/UpdateUserDrawer/UpdateUserDrawer.tsx +31 -5
  36. package/src/features/users/components/UserDropdownMenu/UserDropdownMenu.tsx +1 -1
  37. package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +8 -0
  38. package/src/features/users/services/add-user-to-org-unit.service.ts +1 -0
  39. package/src/features/users/services/get-user-by-id.service.ts +2 -1
  40. package/src/features/users/services/update-user.service.ts +3 -0
  41. package/src/features/users/types/UserData.ts +1 -0
  42. package/src/features/users/types/UserDataService.ts +1 -0
  43. package/src/pages/{collections.tsx → productAssortment.tsx} +30 -51
  44. package/src/themes/layouts.scss +2 -2
  45. package/src/features/collections/components/AddCollectionsDrawer/AddCollectionsDrawer.tsx +0 -146
  46. package/src/features/collections/components/CollectionsTable/CollectionsTable.tsx +0 -94
  47. package/src/features/collections/components/CollectionsTable/collections-table.scss +0 -140
  48. package/src/features/collections/components/RemoveCollectionDrawer/remove-collection-drawer.scss +0 -15
  49. package/src/features/collections/components/index.tsx +0 -5
  50. package/src/features/collections/components/table/add-collections-drawer-table.scss +0 -71
  51. package/src/features/collections/hooks/useAddCollectionsToScope.ts +0 -23
  52. package/src/features/collections/hooks/useGetCollectionsFromContract.ts +0 -26
  53. package/src/features/collections/hooks/useGetCollectionsFromScope.ts +0 -27
  54. package/src/features/collections/hooks/useRemoveCollectionsFromScope.ts +0 -26
  55. package/src/features/collections/layouts/index.ts +0 -4
  56. package/src/features/collections/services/add-collections-to-scope.service.ts +0 -15
  57. package/src/features/collections/services/get-collections-from-contract.service.ts +0 -9
  58. package/src/features/collections/services/get-collections-from-scope.service.ts +0 -24
  59. package/src/features/collections/services/remove-collections-from-scope.ts +0 -7
  60. package/src/features/collections/types/index.ts +0 -20
@@ -1,146 +0,0 @@
1
- import { useEffect, useMemo, useState } from "react";
2
-
3
- import { useRouter } from "next/router";
4
-
5
- import { Link, useUI } from "@faststore/ui";
6
-
7
- import {
8
- type BasicDrawerProps,
9
- BasicDrawer,
10
- Icon,
11
- InternalSearch,
12
- Paginator,
13
- } from "../../../shared/components";
14
- import { useBuyerPortal } from "../../../shared/hooks";
15
- import { useAddCollectionsToScope } from "../../hooks/useAddCollectionsToScope";
16
- import { AddCollectionsDrawerTable } from "../table/AddCollectionsDrawerTable";
17
-
18
- import type { CollectionsSummary, ScopeCollection } from "../../types";
19
-
20
- export type AddCollectionsDrawerProps = Omit<BasicDrawerProps, "children"> & {
21
- collections: ScopeCollection[];
22
- };
23
-
24
- export const PAGE_SIZE = 10;
25
-
26
- export const AddCollectionsDrawer = ({
27
- close,
28
- collections,
29
- ...props
30
- }: AddCollectionsDrawerProps) => {
31
- const { pushToast } = useUI();
32
- const [drawerSearch, setDrawerSearch] = useState("");
33
- const { currentOrgUnit, currentContract } = useBuyerPortal();
34
- const { reload } = useRouter();
35
-
36
- const unitId = currentOrgUnit?.id;
37
- const contractId = currentContract?.id;
38
- const isLoading = false;
39
-
40
- useEffect(() => {
41
- setDrawerSearch("");
42
- }, [props.isOpen]);
43
-
44
- const drawerCollections = useMemo(() => {
45
- return collections.filter((c) =>
46
- c.name.toLowerCase().includes(drawerSearch.toLowerCase())
47
- );
48
- }, [collections, drawerSearch]);
49
-
50
- const addColectionMutation = useAddCollectionsToScope();
51
-
52
- const [selectedCollections, setSelectedCollections] = useState<
53
- CollectionsSummary[]
54
- >([]);
55
-
56
- const handleSuccess = async () => {
57
- await addColectionMutation.mutate({
58
- unitId: unitId ?? "",
59
- contractId: contractId ?? "",
60
- data: selectedCollections.map((s) => ({ name: s.name })),
61
- });
62
-
63
- pushToast({
64
- message: "Collections added successfully",
65
- status: "INFO",
66
- });
67
-
68
- close();
69
- reload();
70
- };
71
-
72
- return (
73
- <BasicDrawer
74
- data-fs-bp-add-collections-drawer
75
- id="basicDrawer"
76
- close={close}
77
- {...props}
78
- >
79
- <BasicDrawer.Heading title="Add collections" onClose={close} />
80
-
81
- <BasicDrawer.Body>
82
- <span data-fs-bp-add-collections-text-drawer>
83
- Add colections to <Link href="#">{currentOrgUnit?.name}</Link>
84
- </span>
85
-
86
- <div data-fs-bp-add-collections-wrapper>
87
- <InternalSearch
88
- textSearch={(searchTerm) => {
89
- setDrawerSearch(searchTerm);
90
- }}
91
- />
92
-
93
- <Paginator.Counter
94
- total={drawerCollections.length}
95
- itemsLength={drawerCollections.length}
96
- />
97
- </div>
98
- <section>
99
- {drawerCollections.length ? (
100
- <div>
101
- <AddCollectionsDrawerTable
102
- data={drawerCollections}
103
- onChange={setSelectedCollections}
104
- />
105
- {drawerCollections.length > 0 && (
106
- <div data-fs-bp-drawer-collections-paginator>
107
- {drawerCollections.length > 0 ? (
108
- <Paginator.NextPageButton>
109
- {isLoading ? "Loading" : "Load More"}
110
- </Paginator.NextPageButton>
111
- ) : (
112
- <span />
113
- )}
114
-
115
- <Paginator.Counter
116
- total={drawerCollections.length}
117
- itemsLength={drawerCollections.length}
118
- />
119
- </div>
120
- )}
121
- </div>
122
- ) : (
123
- <div data-fs-bp-add-collections-drawer-empty-state>
124
- <Icon name="Shapes" />
125
- <p>No collections found</p>
126
- </div>
127
- )}
128
- </section>
129
- </BasicDrawer.Body>
130
- <BasicDrawer.Footer data-fs-bp-add-collections-drawer-footer>
131
- <BasicDrawer.Button variant="ghost" onClick={close}>
132
- Cancel
133
- </BasicDrawer.Button>
134
- <BasicDrawer.Button
135
- variant="confirm"
136
- disabled={selectedCollections.length === 0}
137
- onClick={handleSuccess}
138
- isLoading={addColectionMutation.isLoading}
139
- >
140
- Add
141
- {selectedCollections.length > 0 && `(${selectedCollections.length})`}
142
- </BasicDrawer.Button>
143
- </BasicDrawer.Footer>
144
- </BasicDrawer>
145
- );
146
- };
@@ -1,94 +0,0 @@
1
- import { useState } from "react";
2
-
3
- import { useSearchParams } from "next/navigation";
4
-
5
- import { IconButton, Tooltip } from "@faststore/ui";
6
-
7
- import { Icon, Table } from "../../../shared/components";
8
- import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
9
- import { useDrawerProps } from "../../../shared/hooks";
10
- import { CollectionSelectedProps } from "../../layouts/CollectionsLayout/CollectionsLayout";
11
- import { ScopeCollection } from "../../types";
12
- import { RemoveCollectionDrawer } from "../RemoveCollectionDrawer/RemoveCollectionDrawer";
13
-
14
- export function CollectionsTable({
15
- collections,
16
- }: {
17
- collections: ScopeCollection[];
18
- }) {
19
- const [collectionSelected, setCollectionSelected] =
20
- useState<CollectionSelectedProps | null>();
21
-
22
- const {
23
- open: openRemoveCollectionDrawer,
24
- isOpen: isRemoveCollectionDrawerOpen,
25
- ...removeCollectionDrawerProps
26
- } = useDrawerProps();
27
-
28
- const searchParams = useSearchParams();
29
-
30
- const searchTerm = searchParams.get("search");
31
-
32
- const enabledCollections = collections.filter(
33
- (c) =>
34
- c.isEnabled &&
35
- (!searchTerm ||
36
- (searchTerm && c.name.toLowerCase().includes(searchTerm.toString())))
37
- );
38
- const removeDisabled = enabledCollections.length === 1;
39
- const removeTooltipContent = removeDisabled
40
- ? "This collection can’t be removed. Each unit must have at least one active collection. Add another one to proceed with the removal."
41
- : "Remove from unit";
42
-
43
- function handleRemoveSelectedCollection(collection: CollectionSelectedProps) {
44
- setCollectionSelected(collection);
45
- openRemoveCollectionDrawer();
46
- }
47
-
48
- const columns = getTableColumns({ actionsLength: 1 });
49
-
50
- return (
51
- <div data-fs-bp-collection-table>
52
- <Table layoutFixed>
53
- <Table.Head columns={columns} />
54
- <Table.Body>
55
- {collections.map((item) => (
56
- <Table.Row
57
- iconName="Shapes"
58
- title={item.name}
59
- key={item.id}
60
- iconSize={24}
61
- searchTerm={searchTerm ?? undefined}
62
- actionIcons={
63
- <Tooltip
64
- content={removeTooltipContent}
65
- placement={"left-center"}
66
- >
67
- <IconButton
68
- data-fs-collections-row-action-button
69
- icon={<Icon name={"MinusCircle"} width={20} height={20} />}
70
- aria-label="Remove collections"
71
- disabled={removeDisabled}
72
- onClick={() =>
73
- handleRemoveSelectedCollection({
74
- id: item.id,
75
- name: item.name,
76
- })
77
- }
78
- />
79
- </Tooltip>
80
- }
81
- />
82
- ))}
83
- </Table.Body>
84
- </Table>
85
- {collectionSelected && (
86
- <RemoveCollectionDrawer
87
- isOpen={isRemoveCollectionDrawerOpen}
88
- collection={collectionSelected}
89
- {...removeCollectionDrawerProps}
90
- />
91
- )}
92
- </div>
93
- );
94
- }
@@ -1,140 +0,0 @@
1
- [data-fs-bp-collection-table] {
2
- @import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
3
- @import "../AddCollectionsDrawer/add-collections-drawer.scss";
4
- @import "../../../shared/components/Table/table.scss";
5
-
6
- width: 100%;
7
-
8
- [data-fs-table] {
9
- overflow-x: visible;
10
- }
11
-
12
- [data-fs-bp-head-row] {
13
- border-bottom: var(--fs-table-bordered-border-width) solid
14
- var(--fs-table-bordered-border-color);
15
-
16
- color: #5c5c5c;
17
- height: var(--fs-spacing-8);
18
- }
19
-
20
- [data-fs-table-head="true"] {
21
- [data-fs-bp-head-row="true"] {
22
- &:hover {
23
- background-color: initial;
24
- }
25
- }
26
- }
27
-
28
- [data-fs-tooltip] {
29
- --fs-tooltip-background: #1f1f1f;
30
- border-bottom: none;
31
- text-wrap: balance;
32
- text-align: justify;
33
-
34
- [data-fs-tooltip-placement="left-center"] {
35
- [data-fs-tooltip-indicator="true"] {
36
- margin-left: -0.1%;
37
- }
38
- }
39
- [data-fs-tooltip-placement="top-center"] {
40
- [data-fs-tooltip-indicator="true"] {
41
- margin-top: -1%;
42
- }
43
- }
44
- }
45
-
46
- [data-fs-collections-row-action-button] {
47
- width: var(--fs-spacing-6);
48
- height: var(--fs-spacing-6);
49
- display: inline-flex;
50
- border-radius: var(--fs-border-radius-pill);
51
- justify-content: center;
52
- align-items: center;
53
-
54
- &:hover:not(:disabled) {
55
- background-color: #ebebeb;
56
- cursor: pointer;
57
- }
58
-
59
- [data-fs-button-icon] {
60
- display: block;
61
- width: calc(var(--fs-spacing-4) - var(--fs-spacing-0));
62
- height: calc(var(--fs-spacing-4) - var(--fs-spacing-0));
63
- }
64
- }
65
-
66
- [data-fs-bp-table-row-options] {
67
- [data-fs-collections-row-action-button] {
68
- margin: 0 var(--fs-spacing-1);
69
- border-radius: var(--fs-border-radius-pill);
70
- width: var(--fs-spacing-5);
71
- aspect-ratio: 1;
72
- display: flex;
73
- justify-content: center;
74
- align-items: center;
75
- cursor: pointer;
76
-
77
- &:disabled {
78
- cursor: not-allowed;
79
-
80
- [data-fs-icon] {
81
- color: #adadad;
82
-
83
- &[data-fs-icon-loading="true"] {
84
- @keyframes rotate {
85
- from {
86
- transform: rotate(0deg);
87
- }
88
- to {
89
- transform: rotate(360deg);
90
- }
91
- }
92
- animation: rotate 2s linear infinite;
93
- }
94
- }
95
- }
96
-
97
- &:hover {
98
- background-color: #e0e0e0;
99
- }
100
-
101
- &:active {
102
- opacity: 0.8;
103
- }
104
-
105
- [data-fs-icon] {
106
- color: #000;
107
- }
108
- }
109
- }
110
-
111
- [data-fs-table-row] {
112
- height: var(--fs-spacing-8);
113
-
114
- &:hover {
115
- background-color: var(--fs-color-neutral-bkg);
116
- }
117
-
118
- [data-fs-table-cell="header"] {
119
- display: flex;
120
- height: var(--fs-spacing-8);
121
- cursor: pointer;
122
- }
123
-
124
- [data-fs-bp-table-row-options] {
125
- width: 3rem;
126
- }
127
-
128
- [data-fs-table-cell="data"] {
129
- padding: var(--fs-spacing-0);
130
- }
131
- }
132
-
133
- [data-fs-bp-text-medium] {
134
- font-family: Inter;
135
- font-weight: var(--fs-text-weight-medium);
136
- font-size: var(--fs-text-size-1);
137
- line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
138
- letter-spacing: -1%;
139
- }
140
- }
@@ -1,15 +0,0 @@
1
- [data-fs-bp-remove-collections-drawer] {
2
- @import "@faststore/ui/src/components/atoms/Checkbox/styles.scss";
3
-
4
- span {
5
- display: block;
6
- color: var(--fs-color-neutral-7);
7
- margin-bottom: 1.25rem;
8
- }
9
-
10
- [data-fs-bp-remove-collections-checkbox-wrapper] {
11
- display: flex;
12
- align-items: center;
13
- gap: var(--fs-spacing-1);
14
- }
15
- }
@@ -1,5 +0,0 @@
1
- export {
2
- AddCollectionsDrawer,
3
- type AddCollectionsDrawerProps,
4
- } from "./AddCollectionsDrawer/AddCollectionsDrawer";
5
- export { AddCollectionsDrawerTable } from "./table/AddCollectionsDrawerTable";
@@ -1,71 +0,0 @@
1
- [data-fs-bp-add-collections-drawer-table] {
2
- @import "@faststore/ui/src/components/atoms/Checkbox/styles.scss";
3
- @import "../../../shared/components/Table/table.scss";
4
-
5
- margin-top: 1.25rem;
6
- [data-fs-table-content] {
7
- table-layout: initial;
8
- }
9
-
10
- [data-fs-table-head="true"] {
11
- [data-fs-table-row="true"] {
12
- border-bottom: 1px solid #d6d6d6;
13
-
14
- [data-fs-table-cell="header"] {
15
- height: 2.5rem;
16
- padding: 0 0.875rem;
17
-
18
- font-weight: var(--fs-text-weight-regular);
19
- color: #5c5c5c;
20
- font-size: var(--fs-text-size-1);
21
- }
22
- }
23
- }
24
-
25
- [data-fs-table-body="true"] {
26
- [data-fs-table-row="true"] {
27
- &[data-selected="true"] {
28
- background-color: #f1f8fe;
29
- }
30
-
31
- &:last-child {
32
- border-bottom: 1px solid #d6d6d6;
33
- }
34
-
35
- [data-fs-table-cell] {
36
- height: 3.5rem;
37
- font-weight: var(--fs-text-weight-medium);
38
- color: #1f1f1f;
39
- font-size: var(--fs-text-size-1);
40
- padding: 0 0.875rem;
41
- text-align: left;
42
-
43
- [data-fs-bp-add-collections-drawer-cell-span] {
44
- display: flex;
45
- align-items: center;
46
- }
47
-
48
- &:first-child {
49
- width: 2.5rem;
50
- text-align: center;
51
-
52
- > svg {
53
- margin: 0;
54
- }
55
- }
56
- }
57
- }
58
- }
59
-
60
- [data-fs-skeleton] {
61
- display: inline-block;
62
- }
63
-
64
- [data-fs-tooltip] {
65
- --fs-tooltip-background: #1f1f1f;
66
- }
67
-
68
- [data-fs-bp-collections-checkbox] {
69
- margin: 0 auto;
70
- }
71
- }
@@ -1,23 +0,0 @@
1
- import { MutationOptions, useMutation } from "../../shared/hooks";
2
- import { addCollectionsToScopeService } from "../services/add-collections-to-scope.service";
3
-
4
- export const useAddCollectionsToScope = (
5
- options?: MutationOptions<AwaitedType<typeof addCollectionsToScopeService>>
6
- ) => {
7
- const mutation = useMutation<
8
- AwaitedType<typeof addCollectionsToScopeService>,
9
- Omit<
10
- Parameters<typeof addCollectionsToScopeService>[0],
11
- "cookie" | "customerId"
12
- >
13
- >(
14
- (variables, clientContext) =>
15
- addCollectionsToScopeService({
16
- ...variables,
17
- cookie: clientContext.cookie,
18
- }),
19
- options
20
- );
21
-
22
- return mutation;
23
- };
@@ -1,26 +0,0 @@
1
- import { QueryOptions, useQuery } from "../../shared/hooks";
2
- import { getCollectionsFromContractService } from "../services/get-collections-from-contract.service";
3
-
4
- export const useGetCollectionsFromContract = (
5
- unitId: string,
6
- contractId: string,
7
- options?: QueryOptions<AwaitedType<typeof getCollectionsFromContractService>>
8
- ) => {
9
- const { data, error, isLoading, refetch } = useQuery(
10
- `collections/get-collections-from-contract`,
11
- ({ cookie }) =>
12
- getCollectionsFromContractService({
13
- unitId,
14
- contractId,
15
- cookie,
16
- }),
17
- options
18
- );
19
-
20
- return {
21
- collections: data ?? [],
22
- hasCollectionsError: error,
23
- isCollectionsLoading: isLoading,
24
- refetchCollections: refetch,
25
- };
26
- };
@@ -1,27 +0,0 @@
1
- import { QueryOptions, useQuery } from "../../shared/hooks";
2
- import { getCollectionsFromScopeService } from "../services/get-collections-from-scope.service";
3
-
4
- export const useGetCollectionsFromScope = (
5
- params: { unitId: string; contractId: string; page: number; name?: string },
6
- options?: QueryOptions<AwaitedType<typeof getCollectionsFromScopeService>>
7
- ) => {
8
- const { data, error, isLoading, refetch } = useQuery(
9
- `collections/${params.unitId}/${params.contractId}/${params.name}`,
10
- ({ cookie }) => {
11
- return getCollectionsFromScopeService({
12
- ...params,
13
- cookie,
14
- filterByScope: false,
15
- });
16
- },
17
- options
18
- );
19
-
20
- return {
21
- collections: data ?? [],
22
- total: data?.length ?? 0,
23
- hasCollectionsError: error,
24
- isCollectionsLoading: isLoading,
25
- refetchCollections: refetch,
26
- };
27
- };
@@ -1,26 +0,0 @@
1
- import { MutationOptions, useMutation } from "../../shared/hooks";
2
- import { removeCollectionFromScopeService } from "../services/remove-collections-from-scope";
3
-
4
- export const useRemoveCollectionsFromScope = (
5
- options?: MutationOptions<
6
- AwaitedType<typeof removeCollectionFromScopeService>
7
- >
8
- ) => {
9
- const mutation = useMutation<
10
- AwaitedType<typeof removeCollectionFromScopeService>,
11
- Omit<
12
- Parameters<typeof removeCollectionFromScopeService>[0],
13
- "cookie" | "customerId"
14
- >
15
- >(
16
- (variables, clientContext) =>
17
- removeCollectionFromScopeService({
18
- ...variables,
19
-
20
- cookie: clientContext.cookie,
21
- }),
22
- options
23
- );
24
-
25
- return mutation;
26
- };
@@ -1,4 +0,0 @@
1
- export {
2
- CollectionsLayout,
3
- type CollectionsLayoutProps,
4
- } from "./CollectionsLayout/CollectionsLayout";
@@ -1,15 +0,0 @@
1
- import {
2
- AddCollectionsPayload,
3
- collectionsClient,
4
- } from "../clients/CollectionsClient";
5
-
6
- export const addCollectionsToScopeService = async (params: {
7
- contractId: string;
8
- cookie: string;
9
- unitId: string;
10
- data: AddCollectionsPayload;
11
- }) => {
12
- const response = await collectionsClient.addCollectionsToScope(params);
13
-
14
- return response;
15
- };
@@ -1,9 +0,0 @@
1
- import { collectionsClient } from "../clients/CollectionsClient";
2
-
3
- export const getCollectionsFromContractService = async (
4
- params: Parameters<typeof collectionsClient.getCollectionFromContract>[0]
5
- ) => {
6
- const data = await collectionsClient.getCollectionFromContract(params);
7
-
8
- return data;
9
- };
@@ -1,24 +0,0 @@
1
- import { isRightFormat } from "../../shared/utils/isRightFormat";
2
- import { collectionsClient } from "../clients/CollectionsClient";
3
-
4
- export const getCollectionsFromScopeService = async (
5
- args: Parameters<typeof collectionsClient.getCollectionsListInScope>[0]
6
- ) => {
7
- try {
8
- const data = await collectionsClient.getCollectionsListInScope(args);
9
-
10
- return data;
11
- } catch (error) {
12
- if (error instanceof Error) {
13
- const err = JSON.parse(error.message) as unknown;
14
- if (
15
- isRightFormat(err) &&
16
- err.message.startsWith("No Collection found for the name")
17
- ) {
18
- return [];
19
- }
20
- }
21
-
22
- throw error;
23
- }
24
- };
@@ -1,7 +0,0 @@
1
- import { collectionsClient } from "../clients/CollectionsClient";
2
-
3
- export const removeCollectionFromScopeService = async (
4
- params: Parameters<typeof collectionsClient.removeCollectionFromScope>[0]
5
- ) => {
6
- await collectionsClient.removeCollectionFromScope(params);
7
- };
@@ -1,20 +0,0 @@
1
- export type CollectionsSummary = {
2
- id: string;
3
- name: string;
4
- };
5
-
6
- export type ContractCollection = CollectionsSummary & { isEnabled: boolean };
7
- export type ScopeCollection = CollectionsSummary & { isEnabled: boolean };
8
-
9
- export type GetCollectionsFromContractResponse = {
10
- collections: Array<ContractCollection>;
11
- };
12
-
13
- export type GetCollectionsFromScopeResponse = {
14
- collections: Array<ScopeCollection>;
15
- };
16
-
17
- export type AddCollectionResponse = {
18
- message: string;
19
- addedCollections: string[];
20
- };