@vtex/faststore-plugin-buyer-portal 2.0.27 → 2.0.29
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/plugin.config.js +4 -0
- package/src/features/accounting-fields/layouts/AccountingFieldLayout/AccountingFieldLayout.tsx +1 -1
- package/src/features/addresses/components/AddressDropdownMenu/AddressDropdownMenu.tsx +86 -39
- package/src/features/addresses/components/AddressLocationsList/AddressLocationsList.tsx +45 -30
- package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +19 -11
- package/src/features/addresses/components/CreateAddressDrawer/create-address-drawer.scss +1 -1
- package/src/features/addresses/components/CreateAddressSettingsDrawer/CreateAddressSettingsDrawer.tsx +28 -17
- package/src/features/addresses/components/CreateAddressSettingsDrawer/create-address-settings-drawer.scss +1 -1
- package/src/features/addresses/components/RemoveAddressDrawer/remove-address-drawer.scss +1 -1
- package/src/features/addresses/components/index.ts +0 -2
- package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +302 -70
- package/src/features/addresses/layouts/AddressDetailsLayout/address-details-layout.scss +3 -1
- package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +11 -4
- package/src/features/addresses/layouts/AddressesLayout/addresses-layout.scss +1 -1
- package/src/features/addresses/utils/index.ts +1 -0
- package/src/features/addresses/utils/resolveAddressDetailsTab.test.ts +40 -0
- package/src/features/addresses/utils/resolveAddressDetailsTab.ts +27 -0
- package/src/features/contracts/components/AddContractsDrawer/AddContractsDrawer.tsx +1 -2
- package/src/features/contracts/hooks/useContractListing.ts +2 -2
- package/src/features/contracts/layouts/ContractInformationLayout/ContractInformationLayout.tsx +11 -0
- package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +1 -0
- package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +18 -3
- package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +12 -6
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +7 -4
- package/src/features/recipients/clients/ContractRecipientsClient.ts +129 -0
- package/src/features/recipients/clients/__tests__/ContractRecipientsClient.test.ts +366 -0
- package/src/features/recipients/clients/index.ts +2 -0
- package/src/features/recipients/components/AddRecipientsDrawer/AddRecipientsDrawer.tsx +131 -0
- package/src/features/recipients/components/AddRecipientsDrawer/add-recipients-drawer.scss +14 -0
- package/src/features/recipients/components/DeleteRecipientDrawer/DeleteRecipientDrawer.tsx +138 -0
- package/src/features/recipients/components/DeleteRecipientDrawer/delete-recipient-drawer.scss +9 -0
- package/src/features/{addresses/components/EditRecipientAddressDrawer/EditRecipientAddressDrawer.tsx → recipients/components/EditRecipientDrawer/EditRecipientDrawer.tsx} +68 -75
- package/src/features/{addresses/components/EditRecipientAddressDrawer/edit-recipient-address-drawer.scss → recipients/components/EditRecipientDrawer/edit-recipient-drawer.scss} +3 -6
- package/src/features/recipients/components/RecipientsList/RecipientsList.tsx +104 -0
- package/src/features/recipients/components/RecipientsList/recipients-list.scss +12 -0
- package/src/features/recipients/components/index.ts +21 -0
- package/src/features/recipients/hooks/__tests__/useListContractRecipients.test.ts +134 -0
- package/src/features/recipients/hooks/index.ts +7 -0
- package/src/features/recipients/hooks/useAddContractRecipients.ts +27 -0
- package/src/features/recipients/hooks/useDeleteContractRecipient.ts +27 -0
- package/src/features/recipients/hooks/useEditContractRecipient.ts +27 -0
- package/src/features/recipients/hooks/useListContractRecipients.ts +38 -0
- package/src/features/recipients/index.ts +6 -0
- package/src/features/recipients/layouts/RecipientsLayout/RecipientsLayout.tsx +271 -0
- package/src/features/recipients/layouts/RecipientsLayout/recipients-layout.scss +66 -0
- package/src/features/recipients/layouts/index.ts +1 -0
- package/src/features/recipients/services/__tests__/add-contract-recipients.service.test.ts +141 -0
- package/src/features/recipients/services/__tests__/delete-contract-recipient.service.test.ts +92 -0
- package/src/features/recipients/services/__tests__/edit-contract-recipient.service.test.ts +132 -0
- package/src/features/recipients/services/__tests__/get-contract-recipients.service.test.ts +165 -0
- package/src/features/recipients/services/add-contract-recipients.service.ts +40 -0
- package/src/features/recipients/services/delete-contract-recipient.service.ts +38 -0
- package/src/features/recipients/services/edit-contract-recipient.service.ts +43 -0
- package/src/features/recipients/services/get-contract-recipients.service.ts +55 -0
- package/src/features/recipients/services/index.ts +16 -0
- package/src/features/recipients/types/RecipientData.ts +42 -0
- package/src/features/recipients/types/index.ts +1 -0
- package/src/features/recipients/utils/__tests__/formatRecipientName.test.ts +25 -0
- package/src/features/recipients/utils/formatRecipientName.ts +7 -0
- package/src/features/recipients/utils/index.ts +1 -0
- package/src/features/shared/clients/Auth.ts +14 -0
- package/src/features/shared/clients/Client.ts +13 -2
- package/src/features/shared/clients/__tests__/Client.test.ts +68 -0
- package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +7 -0
- package/src/features/shared/components/Paginator/Interval.tsx +1 -2
- package/src/features/shared/components/index.ts +1 -0
- package/src/features/shared/hooks/index.ts +1 -0
- package/src/features/shared/hooks/useIsAddressEditingRestricted.ts +12 -0
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +2 -1
- package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +6 -4
- package/src/features/shared/services/__tests__/has-storefront-resource.service.test.ts +69 -0
- package/src/features/shared/services/feature-flags/__tests__/get-feature-flags.service.test.ts +6 -1
- package/src/features/shared/services/feature-flags/get-feature-flags.service.ts +3 -0
- package/src/features/shared/services/has-storefront-resource.service.ts +27 -0
- package/src/features/shared/services/index.ts +4 -0
- package/src/features/shared/utils/__tests__/getContractSettingsLinks.test.ts +87 -0
- package/src/features/shared/utils/__tests__/isAddressEditingRestricted.test.ts +44 -0
- package/src/features/shared/utils/__tests__/withAuthLoader.test.ts +49 -1
- package/src/features/shared/utils/buyerPortalRoutes.ts +2 -0
- package/src/features/shared/utils/constants.ts +13 -2
- package/src/features/shared/utils/getContractSettingsLinks.ts +39 -23
- package/src/features/shared/utils/index.ts +5 -0
- package/src/features/shared/utils/isAddressEditingRestricted.ts +10 -0
- package/src/features/shared/utils/phoneNumber.ts +4 -0
- package/src/features/shared/utils/withAuthLoader.ts +28 -4
- package/src/pages/address-details.tsx +33 -16
- package/src/pages/recipients.tsx +140 -0
- package/src/themes/layouts.scss +3 -0
- package/src/features/addresses/components/AddRecipientsDrawer/AddRecipientsDrawer.tsx +0 -140
- package/src/features/addresses/components/AddressRecipientsList/AddressRecipientsList.tsx +0 -250
- package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +0 -142
- /package/src/features/{addresses → recipients}/components/RecipientsForm/RecipientItem/RecipientItem.tsx +0 -0
- /package/src/features/{addresses → recipients}/components/RecipientsForm/RecipientItem/recipient-item.scss +0 -0
- /package/src/features/{addresses → recipients}/components/RecipientsForm/RecipientsForm.tsx +0 -0
- /package/src/features/{addresses → recipients}/components/RecipientsForm/recipients-form.scss +0 -0
package/package.json
CHANGED
package/plugin.config.js
CHANGED
|
@@ -20,6 +20,10 @@ module.exports = {
|
|
|
20
20
|
path: "/pvt/organization-account/addresses/[orgUnitId]/[contractId]",
|
|
21
21
|
appLayout: false,
|
|
22
22
|
},
|
|
23
|
+
recipients: {
|
|
24
|
+
path: "/pvt/organization-account/recipients/[orgUnitId]/[contractId]",
|
|
25
|
+
appLayout: false,
|
|
26
|
+
},
|
|
23
27
|
budgets: {
|
|
24
28
|
path: "/pvt/organization-account/budgets/[orgUnitId]/[contractId]",
|
|
25
29
|
appLayout: false,
|
package/src/features/accounting-fields/layouts/AccountingFieldLayout/AccountingFieldLayout.tsx
CHANGED
|
@@ -25,6 +25,7 @@ import { ContractTabsLayout, GlobalLayout } from "../../../shared/layouts";
|
|
|
25
25
|
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
26
26
|
import { getValidPage } from "../../../shared/utils";
|
|
27
27
|
import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
28
|
+
import { DEFAULT_PAGE_SIZE as PAGE_SIZE } from "../../../shared/utils/constants";
|
|
28
29
|
import {
|
|
29
30
|
AccountingFieldEmptyAlert,
|
|
30
31
|
AccountingValueDropdown,
|
|
@@ -44,7 +45,6 @@ type AccountingFieldLayoutProps = {
|
|
|
44
45
|
const HEADER_ICON_SIZE = 24;
|
|
45
46
|
const PAGE_PARAM = "page";
|
|
46
47
|
const SEARCH_PARAM = "search";
|
|
47
|
-
const PAGE_SIZE = 25;
|
|
48
48
|
|
|
49
49
|
export const AccountingFieldLayout = ({
|
|
50
50
|
accountingField,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
|
|
1
3
|
import { useRouter } from "next/router";
|
|
2
4
|
|
|
3
5
|
import { DropdownItem, Icon as UIIcon, useUI } from "@faststore/ui";
|
|
@@ -5,16 +7,23 @@ import { DropdownItem, Icon as UIIcon, useUI } from "@faststore/ui";
|
|
|
5
7
|
import {
|
|
6
8
|
EditAddressDrawer,
|
|
7
9
|
LocationDrawer,
|
|
8
|
-
AddRecipientsDrawer,
|
|
9
10
|
RemoveAddressDrawer,
|
|
10
11
|
DeleteAddressDrawer,
|
|
11
12
|
} from "..";
|
|
13
|
+
import { AddRecipientsDrawer } from "../../../recipients/components";
|
|
12
14
|
import { BasicDropdownMenu, Icon } from "../../../shared/components";
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
useBuyerPortal,
|
|
17
|
+
useDrawerProps,
|
|
18
|
+
useIsAddressEditingRestricted,
|
|
19
|
+
} from "../../../shared/hooks";
|
|
14
20
|
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
21
|
+
import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
22
|
+
import { useAddRecipientsToAddress } from "../../hooks/useAddRecipientsToAddress";
|
|
15
23
|
import { useSetDefaultAddress } from "../../hooks/useSetDefaultAddress";
|
|
16
24
|
import { useUnsetDefaultAddress } from "../../hooks/useUnsetDefaultAddress";
|
|
17
25
|
|
|
26
|
+
import type { RecipientInput } from "../../../recipients/types";
|
|
18
27
|
import type { AddressData } from "../../types";
|
|
19
28
|
|
|
20
29
|
export type AddressDropdownMenuProps = {
|
|
@@ -37,6 +46,11 @@ export const AddressDropdownMenu = ({
|
|
|
37
46
|
const router = useRouter();
|
|
38
47
|
const { pushToast } = useUI();
|
|
39
48
|
const { t } = useLocalization();
|
|
49
|
+
const isAddressEditingRestricted = useIsAddressEditingRestricted();
|
|
50
|
+
const { featureFlags } = useBuyerPortal();
|
|
51
|
+
const isRecipientsContractLevelEnabled = Boolean(
|
|
52
|
+
featureFlags?.enableRecipientsContractLevel
|
|
53
|
+
);
|
|
40
54
|
|
|
41
55
|
const resolvedLocationsLabel =
|
|
42
56
|
locationsLabel ?? t("addresses.labels.locations");
|
|
@@ -122,6 +136,25 @@ ${t("shared.messages.changesTimeout")}`,
|
|
|
122
136
|
onOpen?.();
|
|
123
137
|
};
|
|
124
138
|
|
|
139
|
+
const addRecipientsErrorRef = useRef<Error | null>(null);
|
|
140
|
+
const { addRecipientsToAddress, isAddRecipientToAddressLoading } =
|
|
141
|
+
useAddRecipientsToAddress({
|
|
142
|
+
onError: (error) => {
|
|
143
|
+
addRecipientsErrorRef.current = error;
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const handleAddRecipientsSubmit = async (recipients: RecipientInput[]) => {
|
|
148
|
+
addRecipientsErrorRef.current = null;
|
|
149
|
+
await addRecipientsToAddress({
|
|
150
|
+
unitId: orgUnitId,
|
|
151
|
+
contractId: customerId,
|
|
152
|
+
addressId: currentAddress.id,
|
|
153
|
+
recipients,
|
|
154
|
+
});
|
|
155
|
+
if (addRecipientsErrorRef.current) throw addRecipientsErrorRef.current;
|
|
156
|
+
};
|
|
157
|
+
|
|
125
158
|
const {
|
|
126
159
|
open: openEditDrawerProps,
|
|
127
160
|
isOpen: isEditDrawerOpen,
|
|
@@ -161,24 +194,30 @@ ${t("shared.messages.changesTimeout")}`,
|
|
|
161
194
|
<Icon name="OpenNewTab" {...sizeProps} />
|
|
162
195
|
Open
|
|
163
196
|
</DropdownItem>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
197
|
+
{!isAddressEditingRestricted && (
|
|
198
|
+
<>
|
|
199
|
+
<DropdownItem onClick={openEditDrawerProps}>
|
|
200
|
+
<Icon name="Edit" {...sizeProps} />
|
|
201
|
+
{t("addresses.dropdown.editDetails")}
|
|
202
|
+
</DropdownItem>
|
|
203
|
+
<DropdownItem
|
|
204
|
+
data-fs-bp-testid="dropdown-item-add-location"
|
|
205
|
+
onClick={openLocationDrawer}
|
|
206
|
+
>
|
|
207
|
+
<UIIcon name="PlusCircle" {...sizeProps} />
|
|
208
|
+
{t("addresses.actions.addLocations", [resolvedLocationsLabel])}
|
|
209
|
+
</DropdownItem>
|
|
210
|
+
{!isRecipientsContractLevelEnabled && (
|
|
211
|
+
<DropdownItem
|
|
212
|
+
data-fs-bp-testid="dropdown-item-add-recipient"
|
|
213
|
+
onClick={openRecipientsDrawer}
|
|
214
|
+
>
|
|
215
|
+
<UIIcon name="PlusCircle" {...sizeProps} />
|
|
216
|
+
{t("addresses.actions.addRecipients")}
|
|
217
|
+
</DropdownItem>
|
|
218
|
+
)}
|
|
219
|
+
</>
|
|
220
|
+
)}
|
|
182
221
|
{currentAddress.isDefault ? (
|
|
183
222
|
<DropdownItem onClick={handleUnsetAsDefault}>
|
|
184
223
|
<Icon name="BookmarkRemove" {...sizeProps} />
|
|
@@ -199,16 +238,15 @@ ${t("shared.messages.changesTimeout")}`,
|
|
|
199
238
|
<UIIcon name="MinusCircle" {...sizeProps} />
|
|
200
239
|
{t("addresses.actions.removeFromUnit")}
|
|
201
240
|
</DropdownItem>
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
{/* )} */}
|
|
241
|
+
{!isAddressEditingRestricted && (
|
|
242
|
+
<DropdownItem
|
|
243
|
+
onClick={openDeleteAddressDrawer}
|
|
244
|
+
data-fs-bp-dropdown-menu-item-mode="danger"
|
|
245
|
+
>
|
|
246
|
+
<Icon name="Delete" {...sizeProps} data-fs-bp-delete-address />
|
|
247
|
+
<span data-fs-bp-delete-address>{t("shared.buttons.delete")}</span>
|
|
248
|
+
</DropdownItem>
|
|
249
|
+
)}
|
|
212
250
|
</BasicDropdownMenu>
|
|
213
251
|
{isEditDrawerOpen && (
|
|
214
252
|
<EditAddressDrawer
|
|
@@ -227,15 +265,24 @@ ${t("shared.messages.changesTimeout")}`,
|
|
|
227
265
|
locationsLabel={resolvedLocationsLabel}
|
|
228
266
|
/>
|
|
229
267
|
)}
|
|
230
|
-
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
268
|
+
{!isAddressEditingRestricted &&
|
|
269
|
+
!isRecipientsContractLevelEnabled &&
|
|
270
|
+
isOpenRecipientsDrawer && (
|
|
271
|
+
<AddRecipientsDrawer
|
|
272
|
+
readonly
|
|
273
|
+
{...recipientDrawerProps}
|
|
274
|
+
isOpen={isOpenRecipientsDrawer}
|
|
275
|
+
isSubmitting={isAddRecipientToAddressLoading}
|
|
276
|
+
onSubmit={handleAddRecipientsSubmit}
|
|
277
|
+
onSubmitted={() => router.reload()}
|
|
278
|
+
addressId={currentAddress.id}
|
|
279
|
+
viewLink={`${buyerPortalRoutes.addressDetails({
|
|
280
|
+
orgUnitId,
|
|
281
|
+
contractId: customerId,
|
|
282
|
+
addressId: currentAddress.id,
|
|
283
|
+
})}?tab=recipient-tab`}
|
|
284
|
+
/>
|
|
285
|
+
)}
|
|
239
286
|
{isOpenRemoveAddressDrawer && (
|
|
240
287
|
<RemoveAddressDrawer
|
|
241
288
|
readonly
|
|
@@ -15,6 +15,7 @@ import { getTableColumns } from "../../../shared/components/Table/utils/tableCol
|
|
|
15
15
|
import {
|
|
16
16
|
useBuyerPortal,
|
|
17
17
|
useDrawerProps,
|
|
18
|
+
useIsAddressEditingRestricted,
|
|
18
19
|
usePageItems,
|
|
19
20
|
} from "../../../shared/hooks";
|
|
20
21
|
import { PAGE_PARAMS, SEARCH_PARAMS } from "../../../shared/hooks/usePageItems";
|
|
@@ -78,6 +79,7 @@ export const AddressLocationsList = forwardRef<
|
|
|
78
79
|
const [totalLocations, setTotalLocations] = useState(total);
|
|
79
80
|
const { currentOrgUnit } = useBuyerPortal();
|
|
80
81
|
const router = useRouter();
|
|
82
|
+
const isAddressEditingRestricted = useIsAddressEditingRestricted();
|
|
81
83
|
const { listLocationData, listLocationRefresh } = useAddressLocationList({
|
|
82
84
|
addressId: (router.query.addressId as string) || "",
|
|
83
85
|
page,
|
|
@@ -118,8 +120,40 @@ export const AddressLocationsList = forwardRef<
|
|
|
118
120
|
refreshLocations: handleRefreshLocations,
|
|
119
121
|
}));
|
|
120
122
|
|
|
123
|
+
const locationActions = isAddressEditingRestricted
|
|
124
|
+
? []
|
|
125
|
+
: [
|
|
126
|
+
{
|
|
127
|
+
testId: "location-action-delete",
|
|
128
|
+
iconName: "Trash",
|
|
129
|
+
ariaLabel: "remove location action",
|
|
130
|
+
onSelect: openDeleteLocation,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
testId: "location-action-edit",
|
|
134
|
+
iconName: "Edit",
|
|
135
|
+
ariaLabel: "edit location action",
|
|
136
|
+
onSelect: openEditLocation,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const renderActions = (item: LocationData) =>
|
|
141
|
+
locationActions.map(({ testId, iconName, ariaLabel, onSelect }) => (
|
|
142
|
+
<IconButton
|
|
143
|
+
key={testId}
|
|
144
|
+
data-fs-bp-address-tabs-actions-icon
|
|
145
|
+
data-fs-bp-testid={testId}
|
|
146
|
+
icon={<Icon name={iconName} width={20} height={20} />}
|
|
147
|
+
aria-label={ariaLabel}
|
|
148
|
+
onClick={() => {
|
|
149
|
+
selectLocation(item);
|
|
150
|
+
onSelect();
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
));
|
|
154
|
+
|
|
121
155
|
const columns = getTableColumns({
|
|
122
|
-
actionsLength:
|
|
156
|
+
actionsLength: locationActions.length,
|
|
123
157
|
nameColumnLabel: t("shared.labels.name"),
|
|
124
158
|
});
|
|
125
159
|
|
|
@@ -141,13 +175,15 @@ export const AddressLocationsList = forwardRef<
|
|
|
141
175
|
iconSize={56}
|
|
142
176
|
title={t("addresses.empty.noResults")}
|
|
143
177
|
>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
178
|
+
{!isAddressEditingRestricted && (
|
|
179
|
+
<Button
|
|
180
|
+
variant="primary"
|
|
181
|
+
onClick={() => onOpenAddDrawer?.()}
|
|
182
|
+
data-fs-bp-address-tabs-empty-state
|
|
183
|
+
>
|
|
184
|
+
{t("addresses.buttons.addLocations")}
|
|
185
|
+
</Button>
|
|
186
|
+
)}
|
|
151
187
|
</EmptyState>
|
|
152
188
|
) : (
|
|
153
189
|
<div data-fs-bp-address-tabs-table>
|
|
@@ -162,28 +198,7 @@ export const AddressLocationsList = forwardRef<
|
|
|
162
198
|
key={item.id}
|
|
163
199
|
title={item.value}
|
|
164
200
|
searchTerm={search}
|
|
165
|
-
actionIcons={
|
|
166
|
-
<IconButton
|
|
167
|
-
data-fs-bp-address-tabs-actions-icon
|
|
168
|
-
data-fs-bp-testid="location-action-delete"
|
|
169
|
-
icon={<Icon name="Trash" width={20} height={20} />}
|
|
170
|
-
aria-label={"remove location action"}
|
|
171
|
-
onClick={() => {
|
|
172
|
-
selectLocation(item);
|
|
173
|
-
openDeleteLocation();
|
|
174
|
-
}}
|
|
175
|
-
/>,
|
|
176
|
-
<IconButton
|
|
177
|
-
data-fs-bp-address-tabs-actions-icon
|
|
178
|
-
data-fs-bp-testid="location-action-edit"
|
|
179
|
-
icon={<Icon name="Edit" width={20} height={20} />}
|
|
180
|
-
aria-label={"edit location action"}
|
|
181
|
-
onClick={() => {
|
|
182
|
-
selectLocation(item);
|
|
183
|
-
openEditLocation();
|
|
184
|
-
}}
|
|
185
|
-
/>,
|
|
186
|
-
]}
|
|
201
|
+
actionIcons={renderActions(item)}
|
|
187
202
|
/>
|
|
188
203
|
))
|
|
189
204
|
)}
|
|
@@ -2,7 +2,8 @@ import { useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useUI, Alert } from "@faststore/ui";
|
|
4
4
|
|
|
5
|
-
import { AddressForm, LocationForm
|
|
5
|
+
import { AddressForm, LocationForm } from "../";
|
|
6
|
+
import { RecipientsForm } from "../../../recipients/components";
|
|
6
7
|
import {
|
|
7
8
|
type BasicDrawerProps,
|
|
8
9
|
BasicDrawer,
|
|
@@ -40,7 +41,10 @@ export const CreateAddressDrawer = ({
|
|
|
40
41
|
const { t } = useLocalization();
|
|
41
42
|
const [isTouched, setIsTouched] = useState(false);
|
|
42
43
|
const [useExistingAddress, setUseExistingAddress] = useState(false);
|
|
43
|
-
const { currentOrgUnit } = useBuyerPortal();
|
|
44
|
+
const { currentOrgUnit, featureFlags } = useBuyerPortal();
|
|
45
|
+
const isRecipientsContractLevelEnabled = Boolean(
|
|
46
|
+
featureFlags?.enableRecipientsContractLevel
|
|
47
|
+
);
|
|
44
48
|
const { trackEvent, trackEntityCreated, trackEntityCreateError } =
|
|
45
49
|
useAnalytics({
|
|
46
50
|
entityType: "address",
|
|
@@ -186,9 +190,11 @@ export const CreateAddressDrawer = ({
|
|
|
186
190
|
<TabBar>
|
|
187
191
|
<TabOption id="address-tab">{t("addresses.tabs.details")}</TabOption>
|
|
188
192
|
<TabOption id="location-tab">{resolvedLocationsLabel}</TabOption>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
{!isRecipientsContractLevelEnabled && (
|
|
194
|
+
<TabOption id="recipient-tab">
|
|
195
|
+
{t("addresses.tabs.recipients")}
|
|
196
|
+
</TabOption>
|
|
197
|
+
)}
|
|
192
198
|
</TabBar>
|
|
193
199
|
|
|
194
200
|
{invalidAddress && (
|
|
@@ -233,12 +239,14 @@ export const CreateAddressDrawer = ({
|
|
|
233
239
|
/>
|
|
234
240
|
</TabContent>
|
|
235
241
|
|
|
236
|
-
|
|
237
|
-
<
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
{!isRecipientsContractLevelEnabled && (
|
|
243
|
+
<TabContent id="recipient-tab">
|
|
244
|
+
<RecipientsForm
|
|
245
|
+
recipients={recipients}
|
|
246
|
+
setRecipients={setRecipients}
|
|
247
|
+
/>
|
|
248
|
+
</TabContent>
|
|
249
|
+
)}
|
|
242
250
|
</BasicDrawer.Body>
|
|
243
251
|
</Tab>
|
|
244
252
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
@import "../../../shared/components/ErrorMessage/error-message.scss";
|
|
7
7
|
@import "../ExistingAddress/existing-address.scss";
|
|
8
8
|
@import "../LocationForm/location-form.scss";
|
|
9
|
-
@import "
|
|
9
|
+
@import "../../../recipients/components/RecipientsForm/recipients-form.scss";
|
|
10
10
|
|
|
11
11
|
@import "@faststore/ui/src/components/molecules/Alert/styles.scss";
|
|
12
12
|
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
} from "../../../shared/components";
|
|
15
15
|
import { OptionSelected } from "../../../shared/components/OptionSelected/OptionSelected";
|
|
16
16
|
import { SearchHighlight } from "../../../shared/components/SearchHighlight/SearchHighlight";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
SCOPE_KEYS,
|
|
19
|
+
useIsAddressEditingRestricted,
|
|
20
|
+
useSetScopeConfig,
|
|
21
|
+
} from "../../../shared/hooks";
|
|
18
22
|
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
19
23
|
import { useEditAddressLocationSettings } from "../../hooks";
|
|
20
24
|
import { useDebouncedSearchAddressByUnitId } from "../../hooks/useDebouncedSearchAddressByUnitId";
|
|
@@ -41,6 +45,7 @@ export const CreateAddressSettingsDrawer = ({
|
|
|
41
45
|
}: CreateAddressSettingsDrawerProps) => {
|
|
42
46
|
const { pushToast } = useUI();
|
|
43
47
|
const { t } = useLocalization();
|
|
48
|
+
const isAddressEditingRestricted = useIsAddressEditingRestricted();
|
|
44
49
|
const addressListTypeOptions = createListTypeOptions("addresses", t);
|
|
45
50
|
const router = useRouter();
|
|
46
51
|
const locationLabelText = initialLocationsLabel;
|
|
@@ -172,7 +177,9 @@ export const CreateAddressSettingsDrawer = ({
|
|
|
172
177
|
});
|
|
173
178
|
const formData = getFormData();
|
|
174
179
|
const locationLabelChanged =
|
|
175
|
-
|
|
180
|
+
!isAddressEditingRestricted &&
|
|
181
|
+
!!locationsLabel &&
|
|
182
|
+
locationsLabel !== initialLocationsLabel;
|
|
176
183
|
|
|
177
184
|
if (formData.length === 0 && !locationLabelChanged) {
|
|
178
185
|
// Close drawer and trigger update when only list type changed
|
|
@@ -337,21 +344,25 @@ export const CreateAddressSettingsDrawer = ({
|
|
|
337
344
|
/>
|
|
338
345
|
)}
|
|
339
346
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
347
|
+
{!isAddressEditingRestricted && (
|
|
348
|
+
<>
|
|
349
|
+
<h4
|
|
350
|
+
data-fs-bp-default-addresses-title
|
|
351
|
+
data-fs-bp-default-addresses-locations-field
|
|
352
|
+
>
|
|
353
|
+
{t("addresses.labels.locations")}
|
|
354
|
+
</h4>
|
|
355
|
+
<h4 data-fs-bp-default-addresses-subtitle>
|
|
356
|
+
{t("addresses.forms.setLocationsFieldName", [locationLabelText])}
|
|
357
|
+
</h4>
|
|
358
|
+
<InputText
|
|
359
|
+
label={t("addresses.forms.fieldLabel")}
|
|
360
|
+
value={locationsLabel}
|
|
361
|
+
onChange={(event) => setLocationsLabel(event.target.value)}
|
|
362
|
+
name="locations-label"
|
|
363
|
+
/>
|
|
364
|
+
</>
|
|
365
|
+
)}
|
|
355
366
|
</div>
|
|
356
367
|
</SettingsDrawer>
|
|
357
368
|
);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
@import "../ExistingAddress/existing-address.scss";
|
|
9
9
|
@import "../LocationForm/location-form.scss";
|
|
10
|
-
@import "
|
|
10
|
+
@import "../../../recipients/components/RecipientsForm/recipients-form.scss";
|
|
11
11
|
|
|
12
12
|
@import "@faststore/ui/src/components/molecules/Alert/styles.scss";
|
|
13
13
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
@import "../../../shared/components/ErrorMessage/error-message.scss";
|
|
6
6
|
@import "../ExistingAddress/existing-address.scss";
|
|
7
7
|
@import "../LocationForm/location-form.scss";
|
|
8
|
-
@import "
|
|
8
|
+
@import "../../../recipients/components/RecipientsForm/recipients-form.scss";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
[data-fs-bp-drawer-label] {
|
|
@@ -2,13 +2,11 @@ export { AddressLine, type AddressLineProps } from "./AddressLine/AddressLine";
|
|
|
2
2
|
export { default as AddressesCard } from "./AddressesCard/AddressesCard";
|
|
3
3
|
export { CreateAddressDrawer } from "./CreateAddressDrawer/CreateAddressDrawer";
|
|
4
4
|
export { LocationForm } from "./LocationForm/LocationForm";
|
|
5
|
-
export { RecipientsForm } from "./RecipientsForm/RecipientsForm";
|
|
6
5
|
export { AddressForm } from "./AddressForm/AddressForm";
|
|
7
6
|
export { ExistingAddress } from "./ExistingAddress/ExistingAddress";
|
|
8
7
|
export { EditAddressDrawer } from "./EditAddressDrawer/EditAddressDrawer";
|
|
9
8
|
export { AddressDropdownMenu } from "./AddressDropdownMenu/AddressDropdownMenu";
|
|
10
9
|
export { LocationDrawer } from "./LocationsDrawer/LocationsDrawer";
|
|
11
|
-
export { AddRecipientsDrawer } from "./AddRecipientsDrawer/AddRecipientsDrawer";
|
|
12
10
|
export { RemoveAddressDrawer } from "./RemoveAddressDrawer/RemoveAddressDrawer";
|
|
13
11
|
export { DeleteAddressDrawer } from "./DeleteAddressDrawer/DeleteAddressDrawer";
|
|
14
12
|
export { AddressLocationsList } from "./AddressLocationsList/AddressLocationsList";
|