@vtex/faststore-plugin-buyer-portal 1.3.77 → 1.3.79

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 (63) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/package.json +1 -1
  3. package/src/features/addresses/clients/AddressesClient.ts +8 -26
  4. package/src/features/addresses/components/AddRecipientsDrawer/AddRecipientsDrawer.tsx +2 -1
  5. package/src/features/addresses/components/AddressDropdownMenu/AddressDropdownMenu.tsx +3 -2
  6. package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +2 -1
  7. package/src/features/addresses/components/CreateAddressSettingsDrawer/CreateAddressSettingsDrawer.tsx +3 -2
  8. package/src/features/addresses/components/DeleteAddressDrawer/DeleteAddressDrawer.tsx +2 -1
  9. package/src/features/addresses/components/DeleteAddressLocationDrawer/DeleteAddressLocationDrawer.tsx +2 -1
  10. package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +2 -1
  11. package/src/features/addresses/components/EditAddressDrawer/EditAddressDrawer.tsx +2 -1
  12. package/src/features/addresses/components/EditAddressLocationDrawer/EditAddressLocationDrawer.tsx +5 -2
  13. package/src/features/addresses/components/EditRecipientAddressDrawer/EditRecipientAddressDrawer.tsx +5 -2
  14. package/src/features/addresses/components/LocationsDrawer/LocationsDrawer.tsx +2 -1
  15. package/src/features/addresses/components/RemoveAddressDrawer/RemoveAddressDrawer.tsx +2 -1
  16. package/src/features/addresses/hooks/index.ts +1 -0
  17. package/src/features/addresses/hooks/useDebouncedSearchAddressByUnitId.ts +8 -9
  18. package/src/features/addresses/hooks/useListAddresses.ts +36 -0
  19. package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +133 -151
  20. package/src/features/addresses/layouts/AddressesLayout/addresses-layout.scss +17 -2
  21. package/src/features/addresses/layouts/index.ts +1 -4
  22. package/src/features/budgets/components/BudgetDeleteDrawer/BudgetDeleteDrawer.tsx +2 -1
  23. package/src/features/budgets/components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer.tsx +5 -1
  24. package/src/features/budgets/components/CreateBudgetAllocationDrawer/CreateBudgetAllocationDrawer.tsx +2 -1
  25. package/src/features/budgets/components/CreateBudgetDrawer/CreateBudgetDrawer.tsx +4 -3
  26. package/src/features/budgets/components/DeleteBudgetAllocationDrawer/DeleteBudgetAllocationDrawer.tsx +2 -1
  27. package/src/features/budgets/components/EditBudgetDrawer/EditBudgetDrawer.tsx +5 -1
  28. package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx +2 -1
  29. package/src/features/buying-policies/components/DeleteBuyingPolicyDrawer/DeleteBuyingPolicyDrawer.tsx +2 -1
  30. package/src/features/buying-policies/components/UpdateBuyingPolicyDrawer/UpdateBuyingPolicyDrawer.tsx +2 -1
  31. package/src/features/credit-cards/components/CreateCreditCardDrawer/CreateCreditCardDrawer.tsx +2 -1
  32. package/src/features/credit-cards/components/CreditCardDropdownMenu/CreditCardDropdownMenu.tsx +3 -2
  33. package/src/features/credit-cards/components/CreditCardSettingsDrawer/CreditCardSettingsDrawer.tsx +2 -1
  34. package/src/features/credit-cards/components/DeleteCreditCardDrawer/DeleteCreditCardDrawer.tsx +2 -1
  35. package/src/features/credit-cards/components/EditCreditCardDrawer/EditCreditCardDrawer.tsx +2 -1
  36. package/src/features/credit-cards/components/RemoveCreditCardDrawer/RemoveCreditCardDrawer.tsx +2 -1
  37. package/src/features/custom-fields/components/CreateCustomFieldValueDrawer/CreateCustomFieldValueDrawer.tsx +3 -2
  38. package/src/features/custom-fields/components/CustomFieldSettingsDrawer/CustomFieldSettingsDrawer.tsx +2 -1
  39. package/src/features/custom-fields/components/DeleteCustomFieldValueDrawer/DeleteCustomFieldValueDrawer.tsx +3 -2
  40. package/src/features/custom-fields/components/UpdateCustomFieldValueDrawer/UpdateCustomFieldValueDrawer.tsx +2 -1
  41. package/src/features/custom-fields/layouts/CustomFieldsLayout/CustomFieldsLayout.tsx +3 -2
  42. package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +2 -1
  43. package/src/features/org-units/components/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +2 -1
  44. package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +2 -1
  45. package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +2 -1
  46. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +2 -1
  47. package/src/features/payment-methods/components/PaymentMethodSettingsDrawer/PaymentMethodSettingsDrawer.tsx +2 -1
  48. package/src/features/payment-methods/hooks/useRemovePaymentMethodSubmit.ts +2 -1
  49. package/src/features/product-assortment/components/AddProductAssortmentDrawer/AddProductAssortmentDrawer.tsx +2 -1
  50. package/src/features/product-assortment/components/CollectionsSettingsDrawer/CollectionsSettingsDrawer.tsx +2 -1
  51. package/src/features/product-assortment/components/RemoveProductAssortmentDrawer/RemoveProductAssortmentDrawer.tsx +2 -1
  52. package/src/features/shared/components/Toast/toast.scss +1 -0
  53. package/src/features/shared/hooks/index.ts +1 -0
  54. package/src/features/shared/hooks/useUrlPaginatedSearch.ts +79 -0
  55. package/src/features/shared/utils/constants.ts +4 -1
  56. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +2 -1
  57. package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +2 -1
  58. package/src/features/users/components/DeleteUserDrawer/DeleteUserDrawer.tsx +2 -1
  59. package/src/features/users/components/ReassignOrgUnitDrawer/ReassignOrgUnitDrawer.tsx +2 -1
  60. package/src/features/users/components/UpdateUserDrawer/UpdateUserDrawer.tsx +2 -1
  61. package/src/features/users/components/UpdateUserDrawerWithUsername/UpdateUserDrawerWithUsername.tsx +2 -1
  62. package/src/pages/addresses.tsx +16 -62
  63. package/src/features/addresses/hooks/useSearchAddressByUnitId.ts +0 -27
package/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.79] - 2026-04-23
11
+
12
+ ### Added
13
+ - Add propagation delay message to CRUD success toasts
14
+
15
+ ## [1.3.78] - 2026-04-23
16
+
17
+ ### Changed
18
+ - Move addresses list requests from server to client side
19
+
20
+ ### Fixed
21
+ - Remove `for` loop from `AddressesClient.getAddressesByUnitId` to prevent failed requests
22
+
10
23
  ## [1.3.77] - 2026-04-14
11
24
 
12
25
  ### Changed
@@ -573,7 +586,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
573
586
  - Add CHANGELOG file
574
587
  - Add README file
575
588
 
576
- [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.77...HEAD
589
+ [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.79...HEAD
577
590
  [1.3.55]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.54...v1.3.55
578
591
  [1.3.54]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.53...v1.3.54
579
592
  [1.3.53]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.52...v1.3.53
@@ -641,6 +654,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
641
654
  [1.3.65]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.64...v1.3.65
642
655
  [1.3.64]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.64
643
656
  [1.3.69]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.69
657
+ [1.3.79]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.78...v1.3.79
658
+ [1.3.78]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.77...v1.3.78
644
659
  [1.3.77]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.76...v1.3.77
645
660
  [1.3.76]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.75...v1.3.76
646
661
  [1.3.75]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.74...v1.3.75
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.3.77",
3
+ "version": "1.3.79",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,32 +32,14 @@ export default class AddressesClient extends Client {
32
32
  addressType,
33
33
  page = 1,
34
34
  }: GetAddressesByUnitIdParams) {
35
- let allAddresses: AddressData[] = [];
36
- let total = 0;
37
-
38
- for (let currentPage = 1; currentPage <= page; currentPage++) {
39
- const params = new URLSearchParams();
40
- if (name) params.append("name", name);
41
- if (currentPage > 1) params.append("page", String(currentPage));
42
- if (addressType) params.append("addressType", addressType);
43
- const queryString = params.toString();
44
- const url = queryString
45
- ? `units/${orgUnitId}/addresses?${queryString}`
46
- : `units/${orgUnitId}/addresses`;
47
-
48
- const response = await this.get<AddressResponse>(url, {
49
- headers: {
50
- Cookie: cookie,
51
- },
52
- });
53
-
54
- if (response?.addresses) {
55
- allAddresses = allAddresses.concat(response.addresses);
56
- total = response.total;
57
- }
58
- }
59
-
60
- return { addresses: allAddresses, total };
35
+ return this.get<AddressResponse>(`units/${orgUnitId}/addresses`, {
36
+ headers: { Cookie: cookie },
37
+ params: {
38
+ page,
39
+ name: name ?? "",
40
+ addressType: addressType ?? "",
41
+ },
42
+ });
61
43
  }
62
44
 
63
45
  getAddressById(
@@ -9,6 +9,7 @@ import { type BasicDrawerProps, BasicDrawer } from "../../../shared/components";
9
9
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
10
10
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
11
11
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
12
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
12
13
  import { useAddRecipientsToAddress } from "../../hooks/useAddRecipientsToAddress";
13
14
 
14
15
  import type { RecipientInput } from "../../types";
@@ -50,7 +51,7 @@ export const AddRecipientsDrawer = ({
50
51
  });
51
52
 
52
53
  pushToast({
53
- message: "Recipients added successfully ",
54
+ message: `Recipients added successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
54
55
  status: "INFO",
55
56
  icon: (
56
57
  <button
@@ -11,6 +11,7 @@ import {
11
11
  } from "..";
12
12
  import { BasicDropdownMenu, Icon } from "../../../shared/components";
13
13
  import { useDrawerProps } from "../../../shared/hooks";
14
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
14
15
  import { ADDRESS_MESSAGES } from "../../constants/messages";
15
16
  import { useSetDefaultAddress } from "../../hooks/useSetDefaultAddress";
16
17
  import { useUnsetDefaultAddress } from "../../hooks/useUnsetDefaultAddress";
@@ -40,7 +41,7 @@ export const AddressDropdownMenu = ({
40
41
 
41
42
  const handleCreateNewAddressSuccess = () => {
42
43
  pushToast({
43
- message: ADDRESS_MESSAGES.defaultSaved,
44
+ message: `${ADDRESS_MESSAGES.defaultSaved}\n${CHANGES_TIMEOUT_MESSAGE}`,
44
45
  status: "INFO",
45
46
  });
46
47
  onUpdate?.();
@@ -48,7 +49,7 @@ export const AddressDropdownMenu = ({
48
49
 
49
50
  const handleRemoveDefaultAddressSuccess = () => {
50
51
  pushToast({
51
- message: ADDRESS_MESSAGES.defaultUnset,
52
+ message: `${ADDRESS_MESSAGES.defaultUnset}\n${CHANGES_TIMEOUT_MESSAGE}`,
52
53
  status: "INFO",
53
54
  });
54
55
  onUpdate?.();
@@ -18,6 +18,7 @@ import {
18
18
  useBuyerPortal,
19
19
  } from "../../../shared/hooks";
20
20
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
21
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
21
22
  import { useCreateNewAddress } from "../../hooks";
22
23
  import { LocationInput } from "../../types/AddressData";
23
24
 
@@ -92,7 +93,7 @@ export const CreateAddressDrawer = ({
92
93
  });
93
94
 
94
95
  pushToast({
95
- message: "Address added successfully",
96
+ message: `Address added successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
96
97
  status: "INFO",
97
98
  });
98
99
  onUpdate?.();
@@ -14,6 +14,7 @@ import {
14
14
  import { OptionSelected } from "../../../shared/components/OptionSelected/OptionSelected";
15
15
  import { SearchHighlight } from "../../../shared/components/SearchHighlight/SearchHighlight";
16
16
  import { useSetScopeConfig, SCOPE_KEYS } from "../../../shared/hooks";
17
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
17
18
  import { ADDRESS_MESSAGES } from "../../constants/messages";
18
19
  import { useDebouncedSearchAddressByUnitId } from "../../hooks/useDebouncedSearchAddressByUnitId";
19
20
  import { useGetDefaultAddress } from "../../hooks/useGetDefaultAddresses";
@@ -90,7 +91,7 @@ export const CreateAddressSettingsDrawer = ({
90
91
 
91
92
  const handleCreateNewAddressSuccess = () => {
92
93
  pushToast({
93
- message: ADDRESS_MESSAGES.defaultSaved,
94
+ message: `${ADDRESS_MESSAGES.defaultSaved}\n${CHANGES_TIMEOUT_MESSAGE}`,
94
95
  status: "INFO",
95
96
  });
96
97
  onUpdate?.();
@@ -111,7 +112,7 @@ export const CreateAddressSettingsDrawer = ({
111
112
  const { setScopeConfig, isSetScopeConfigLoading } = useSetScopeConfig({
112
113
  onSuccess: () => {
113
114
  pushToast({
114
- message: "Scope configuration updated successfully",
115
+ message: `Scope configuration updated successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
115
116
  status: "INFO",
116
117
  });
117
118
  },
@@ -9,6 +9,7 @@ import {
9
9
  } from "../../../shared/components";
10
10
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
11
11
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
12
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
12
13
  import { useDeleteAddress } from "../../hooks";
13
14
 
14
15
  export type DeleteAddressDrawerProps = Omit<BasicDrawerProps, "children"> & {
@@ -44,7 +45,7 @@ export const DeleteAddressDrawer = ({
44
45
  });
45
46
 
46
47
  pushToast({
47
- message: "Address deleted successfully",
48
+ message: `Address deleted successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
48
49
  status: "INFO",
49
50
  });
50
51
  onUpdate?.();
@@ -5,6 +5,7 @@ import { useUI } from "@faststore/ui";
5
5
  import { BasicDrawer, BasicDrawerProps } from "../../../shared/components";
6
6
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
7
7
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
8
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
8
9
  import { useAddressLocationDelete } from "../../hooks";
9
10
  import { LocationField } from "../LocationForm/LocationField/LocationField";
10
11
 
@@ -48,7 +49,7 @@ export const DeleteAddressLocationDrawer = ({
48
49
  });
49
50
 
50
51
  pushToast({
51
- message: "Location removed successfully",
52
+ message: `Location removed successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
52
53
  status: "INFO",
53
54
  });
54
55
 
@@ -11,6 +11,7 @@ import {
11
11
  } from "../../../shared/components";
12
12
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
13
13
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
14
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
14
15
  import { useDeleteRecipientAddress } from "../../hooks/useDeleteRecipientAddress";
15
16
 
16
17
  export type DeleteRecipientAddressDrawerProps = Omit<
@@ -52,7 +53,7 @@ export const DeleteRecipientAddressDrawer = ({
52
53
  });
53
54
 
54
55
  pushToast({
55
- message: "Recipient deleted successfully",
56
+ message: `Recipient deleted successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
56
57
  status: "INFO",
57
58
  });
58
59
  refetchRecipients();
@@ -6,6 +6,7 @@ import { AddressForm } from "..";
6
6
  import { type BasicDrawerProps, BasicDrawer } from "../../../shared/components";
7
7
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
8
8
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
9
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
9
10
  import { useEditAddress } from "../../hooks";
10
11
 
11
12
  import type { AddressInput, AddressData } from "../../types";
@@ -50,7 +51,7 @@ export const EditAddressDrawer = ({
50
51
  });
51
52
 
52
53
  pushToast({
53
- message: "Address updated successfully",
54
+ message: `Address updated successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
54
55
  status: "INFO",
55
56
  });
56
57
  onUpdate?.();
@@ -5,7 +5,10 @@ import { CheckboxField, useUI } from "@faststore/ui";
5
5
  import { BasicDrawer, BasicDrawerProps } from "../../../shared/components";
6
6
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
7
7
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
8
- import { LOCAL_STORAGE_LOCATION_EDIT_KEY } from "../../../shared/utils/constants";
8
+ import {
9
+ CHANGES_TIMEOUT_MESSAGE,
10
+ LOCAL_STORAGE_LOCATION_EDIT_KEY,
11
+ } from "../../../shared/utils/constants";
9
12
  import { useAddressLocationEdit } from "../../hooks";
10
13
  import { LocationField } from "../LocationForm/LocationField/LocationField";
11
14
 
@@ -57,7 +60,7 @@ export const EditAddressLocationDrawer = ({
57
60
  });
58
61
 
59
62
  pushToast({
60
- message: "Location edited successfully",
63
+ message: `Location edited successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
61
64
  status: "INFO",
62
65
  });
63
66
 
@@ -7,7 +7,10 @@ import { CheckboxField, useUI } from "@faststore/ui";
7
7
  import { type BasicDrawerProps, BasicDrawer } from "../../../shared/components";
8
8
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
9
9
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
10
- import { LOCAL_STORAGE_RECIPIENT_EDIT_KEY } from "../../../shared/utils/constants";
10
+ import {
11
+ CHANGES_TIMEOUT_MESSAGE,
12
+ LOCAL_STORAGE_RECIPIENT_EDIT_KEY,
13
+ } from "../../../shared/utils/constants";
11
14
  import { useEditRecipientsToAddress } from "../../hooks/useEditRecipientsToAddress";
12
15
  import { type RecipientData, RecipientInput } from "../../types";
13
16
  import { RecipientItem } from "../RecipientsForm/RecipientItem/RecipientItem";
@@ -64,7 +67,7 @@ export const EditRecipientAddressDrawer = ({
64
67
  });
65
68
 
66
69
  pushToast({
67
- message: "Recipient edited successfully",
70
+ message: `Recipient edited successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
68
71
  status: "INFO",
69
72
  });
70
73
  refetchRecipients();
@@ -9,6 +9,7 @@ import { type BasicDrawerProps, BasicDrawer } from "../../../shared/components";
9
9
  import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
10
10
  import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
11
11
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
12
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
12
13
  import { useAddLocationsToAddress } from "../../hooks";
13
14
 
14
15
  import type { LocationInput } from "../../types/AddressData";
@@ -58,7 +59,7 @@ export const LocationDrawer = ({
58
59
  });
59
60
 
60
61
  pushToast({
61
- message: "Locations added successfully ",
62
+ message: `Locations added successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
62
63
  status: "INFO",
63
64
  icon: (
64
65
  <button
@@ -2,6 +2,7 @@ import { useUI } from "@faststore/ui";
2
2
 
3
3
  import { type BasicDrawerProps, BasicDrawer } from "../../../shared/components";
4
4
  import { useRemoveFromScope, useBuyerPortal } from "../../../shared/hooks";
5
+ import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
5
6
 
6
7
  export type RemoveAddressDrawerProps = Omit<BasicDrawerProps, "children"> & {
7
8
  readonly?: boolean;
@@ -22,7 +23,7 @@ export const RemoveAddressDrawer = ({
22
23
 
23
24
  const handeRemoveFromScopeSuccess = () => {
24
25
  pushToast({
25
- message: "Address removed successfully",
26
+ message: `Address removed successfully\n${CHANGES_TIMEOUT_MESSAGE}`,
26
27
  status: "INFO",
27
28
  });
28
29
  onUpdate?.();
@@ -8,3 +8,4 @@ export * from "./useAddressLocationDelete";
8
8
  export * from "./useSetDefaultAddress";
9
9
  export * from "./useUnsetDefaultAddress";
10
10
  export * from "./useGetDefaultAddresses";
11
+ export * from "./useListAddresses";
@@ -1,7 +1,7 @@
1
1
  import { useDebounce } from "../../shared/hooks";
2
2
  import { DEBOUNCE_TIMEOUT } from "../../shared/utils/constants";
3
3
 
4
- import { useSearchAddressByUnitId } from "./useSearchAddressByUnitId";
4
+ import { useListAddresses } from "./useListAddresses";
5
5
 
6
6
  import type { AddressData } from "../types";
7
7
  import type { UseDebouncedSearchAddressByUnitIdProps } from "../types/AddressData";
@@ -12,12 +12,11 @@ export const useDebouncedSearchAddressByUnitId = ({
12
12
  addressType,
13
13
  }: UseDebouncedSearchAddressByUnitIdProps) => {
14
14
  const debouncedSearchTerm = useDebounce(search, DEBOUNCE_TIMEOUT);
15
- const { searchedAddresses, isSearchedAddressesLoading } =
16
- useSearchAddressByUnitId({
17
- orgUnitId,
18
- search: debouncedSearchTerm,
19
- addressType,
20
- });
15
+ const { listAddressesData, listAddressesLoading } = useListAddresses({
16
+ orgUnitId,
17
+ search: debouncedSearchTerm,
18
+ addressType,
19
+ });
21
20
 
22
21
  if (search === "") {
23
22
  return {
@@ -27,7 +26,7 @@ export const useDebouncedSearchAddressByUnitId = ({
27
26
  }
28
27
 
29
28
  return {
30
- searchedAddresses: searchedAddresses?.data ?? [],
31
- isDebouncedSearchAddressesLoading: isSearchedAddressesLoading,
29
+ searchedAddresses: listAddressesData?.data ?? [],
30
+ isDebouncedSearchAddressesLoading: listAddressesLoading,
32
31
  };
33
32
  };
@@ -0,0 +1,36 @@
1
+ import { type QueryOptions, useQuery } from "../../shared/hooks";
2
+ import { getAddressesByUnitIdService } from "../services";
3
+
4
+ type UseListAddressesProps = {
5
+ orgUnitId: string;
6
+ search: string;
7
+ page?: number;
8
+ addressType?: string;
9
+ };
10
+
11
+ export const useListAddresses = (
12
+ { orgUnitId, search, page = 1, addressType }: UseListAddressesProps,
13
+ options?: QueryOptions<AwaitedType<typeof getAddressesByUnitIdService>>
14
+ ) => {
15
+ const { data, error, isLoading, refetch } = useQuery(
16
+ `api/addresses/unitId=${orgUnitId}/page=${page}/search=${
17
+ search ?? ""
18
+ }/addressType=${addressType ?? ""}`,
19
+ ({ cookie }) =>
20
+ getAddressesByUnitIdService({
21
+ orgUnitId,
22
+ search,
23
+ cookie,
24
+ addressType,
25
+ page,
26
+ }),
27
+ options
28
+ );
29
+
30
+ return {
31
+ listAddressesData: data,
32
+ listAddressesError: error,
33
+ listAddressesLoading: isLoading,
34
+ listAddressesRefresh: refetch,
35
+ };
36
+ };