@vtex/faststore-plugin-buyer-portal 1.3.21 → 1.3.22

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.22] - 2025-11-21
11
+
12
+ ### Added
13
+
14
+ - Add validation to prevent Org Unit deletion if it has users
15
+
10
16
  ## [1.3.21] - 2025-11-05
11
17
 
12
18
  ### Removed
@@ -138,8 +144,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
138
144
  ## [1.2.4] - 2025-10-16
139
145
 
140
146
  ### Added
141
- - Responsiviness adjustment to to Buying policies page
142
147
 
148
+ - Responsiviness adjustment to to Buying policies page
143
149
 
144
150
  ### Added
145
151
 
@@ -229,7 +235,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
229
235
  - Add CHANGELOG file
230
236
  - Add README file
231
237
 
232
- [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.21...HEAD
238
+ [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.22...HEAD
233
239
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.2.2...1.2.3
234
240
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.3
235
241
  [1.2.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.4
@@ -244,6 +250,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
244
250
 
245
251
  # <<<<<<< HEAD
246
252
 
253
+ [1.3.22]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.21...v1.3.22
247
254
  [1.3.21]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.20...v1.3.21
248
255
  [1.3.20]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.19...v1.3.20
249
256
  [1.3.19]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.18...v1.3.19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.3.21",
3
+ "version": "1.3.22",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,6 +11,7 @@ import {
11
11
  InputText,
12
12
  type BasicDrawerProps,
13
13
  } from "../../../shared/components";
14
+ import { useGetUserByOrgUnitId } from "../../../users/hooks/useGetUserByOrgUnitId";
14
15
  import { useChildrenOrgUnits } from "../../hooks";
15
16
  import { useDeleteOrgUnit } from "../../hooks/useDeleteOrgUnit";
16
17
 
@@ -28,12 +29,14 @@ export const DeleteOrgUnitDrawer = ({
28
29
  }: DeleteOrgUnitDrawerProps) => {
29
30
  const router = useRouter();
30
31
  const { childrenOrgUnits } = useChildrenOrgUnits(id, name);
32
+ const { users } = useGetUserByOrgUnitId(id);
31
33
  const { pushToast } = useUI();
32
34
 
33
35
  const [confirmName, setConfirmName] = useState("");
34
36
  const [isTouched, setIsTouched] = useState(false);
35
37
 
36
- const hasChildren = Boolean(childrenOrgUnits?.nodes?.length);
38
+ const hasChildren =
39
+ Boolean(childrenOrgUnits?.nodes?.length) || Boolean(users?.length);
37
40
 
38
41
  const handleDeleteOrgUnitSuccess = () => {
39
42
  pushToast({
@@ -111,13 +114,14 @@ export const DeleteOrgUnitDrawer = ({
111
114
  <span data-fs-bp-delete-org-unit-drawer-message-name>
112
115
  {` ${name} `}
113
116
  </span>
114
- , you must first remove all child organizational units.
117
+ , you must first remove all child organizational units{" "}
118
+ {users?.length ? "and users" : ""}.
115
119
  <br />
116
120
  Please delete them individually, starting from the lowest level.
117
121
  <br />
118
122
  <br />
119
- Once all child units bellow are removed, you’ll be able to delete{" "}
120
- {name}.
123
+ Once all child units {users?.length ? "and users" : ""} bellow are
124
+ removed, you’ll be able to delete {name}.
121
125
  </p>
122
126
 
123
127
  <span data-fs-bp-delete-org-unit-drawer-subtitle>
@@ -13,4 +13,4 @@ export const LOCAL_STORAGE_LOCATION_EDIT_KEY = "bp_hide_edit_location_confirm";
13
13
  export const LOCAL_STORAGE_RECIPIENT_EDIT_KEY =
14
14
  "bp_hide_edit_recipient_confirm";
15
15
 
16
- export const CURRENT_VERSION = "1.3.21";
16
+ export const CURRENT_VERSION = "1.3.22";
@@ -0,0 +1,20 @@
1
+ import { type QueryOptions, useQuery } from "../../shared/hooks";
2
+ import { getUsersByOrgUnitIdService } from "../services";
3
+
4
+ export const useGetUserByOrgUnitId = (
5
+ orgUnitId: string,
6
+ options?: QueryOptions<AwaitedType<typeof getUsersByOrgUnitIdService>>
7
+ ) => {
8
+ const { data, error, isLoading, refetch } = useQuery(
9
+ `org-unit/user/${orgUnitId}`,
10
+ ({ cookie }) => getUsersByOrgUnitIdService({ orgUnitId, cookie }),
11
+ options
12
+ );
13
+
14
+ return {
15
+ users: data?.users,
16
+ hasUserError: error,
17
+ isUserLoading: isLoading,
18
+ refetchUser: refetch,
19
+ };
20
+ };