@vtex/faststore-plugin-buyer-portal 1.3.18 → 1.3.19
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.19] - 2025-11-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add isLoading state to orgUnit search input
|
|
15
|
+
|
|
10
16
|
## [1.3.18] - 2025-11-05
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -211,7 +217,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
211
217
|
- Add CHANGELOG file
|
|
212
218
|
- Add README file
|
|
213
219
|
|
|
214
|
-
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.
|
|
220
|
+
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.19...HEAD
|
|
215
221
|
[1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.2.2...1.2.3
|
|
216
222
|
[1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.3
|
|
217
223
|
[1.2.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.4
|
|
@@ -226,6 +232,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
226
232
|
|
|
227
233
|
# <<<<<<< HEAD
|
|
228
234
|
|
|
235
|
+
[1.3.19]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.18...v1.3.19
|
|
229
236
|
[1.3.18]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.17...v1.3.18
|
|
230
237
|
[1.3.17]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.16...v1.3.17
|
|
231
238
|
[1.3.16]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.15...v1.3.16
|
package/package.json
CHANGED
|
@@ -4,6 +4,11 @@ import { AutocompleteDropdown } from "..";
|
|
|
4
4
|
import { useDebouncedSearchOrgUnit } from "../../../users/hooks";
|
|
5
5
|
import { OptionSelected } from "../OptionSelected/OptionSelected";
|
|
6
6
|
|
|
7
|
+
type Option = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export type OrgUnitInputSearchProps = Omit<
|
|
8
13
|
ComponentProps<typeof AutocompleteDropdown>,
|
|
9
14
|
"onSelect" | "label" | "onConfirmKeyPress"
|
|
@@ -25,9 +30,15 @@ export const OrgUnitInputSearch = ({
|
|
|
25
30
|
}: OrgUnitInputSearchProps) => {
|
|
26
31
|
const [autocompleteInputValue, setAutocompleteInputValue] = useState("");
|
|
27
32
|
|
|
28
|
-
const { searchedOrgUnits } =
|
|
29
|
-
autocompleteInputValue
|
|
30
|
-
|
|
33
|
+
const { searchedOrgUnits, isSearchedOrgUnitsLoading } =
|
|
34
|
+
useDebouncedSearchOrgUnit(autocompleteInputValue);
|
|
35
|
+
|
|
36
|
+
const loadingObject: Option = { id: "loading", name: "loading..." };
|
|
37
|
+
|
|
38
|
+
const handleSelect = (option: Option) => {
|
|
39
|
+
if (option.id === loadingObject.id) return;
|
|
40
|
+
onSelect?.(option);
|
|
41
|
+
};
|
|
31
42
|
|
|
32
43
|
return orgUnit.name ? (
|
|
33
44
|
<OptionSelected
|
|
@@ -47,15 +58,8 @@ export const OrgUnitInputSearch = ({
|
|
|
47
58
|
{...otherProps}
|
|
48
59
|
label="Search organizational units"
|
|
49
60
|
value={autocompleteInputValue}
|
|
50
|
-
options={searchedOrgUnits}
|
|
51
|
-
onConfirmKeyPress={
|
|
52
|
-
onSelect?.(
|
|
53
|
-
option as {
|
|
54
|
-
name: string;
|
|
55
|
-
id: string;
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
}
|
|
61
|
+
options={isSearchedOrgUnitsLoading ? [loadingObject] : searchedOrgUnits}
|
|
62
|
+
onConfirmKeyPress={handleSelect}
|
|
59
63
|
onChange={(event) => {
|
|
60
64
|
setAutocompleteInputValue(event.currentTarget.value);
|
|
61
65
|
}}
|
|
@@ -65,7 +69,7 @@ export const OrgUnitInputSearch = ({
|
|
|
65
69
|
closeOnClick
|
|
66
70
|
index={index}
|
|
67
71
|
isSelected={orgUnit?.id === option?.id}
|
|
68
|
-
onClick={() =>
|
|
72
|
+
onClick={() => handleSelect(option)}
|
|
69
73
|
>
|
|
70
74
|
{option?.name}
|
|
71
75
|
</AutocompleteDropdown.Item>
|
|
@@ -7,18 +7,14 @@ export const useDebouncedSearchOrgUnit = (searchTerm = "") => {
|
|
|
7
7
|
const { searchedOrgUnits, isSearchedOrgUnitsLoading } =
|
|
8
8
|
useSearchOrgUnits(debouncedSearchTerm);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
name: string;
|
|
14
|
-
id: string;
|
|
15
|
-
}[],
|
|
16
|
-
isLoading: false,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
10
|
+
const isDebouncing = searchTerm !== debouncedSearchTerm;
|
|
11
|
+
const isLoading =
|
|
12
|
+
searchTerm !== "" && (isDebouncing || isSearchedOrgUnitsLoading);
|
|
19
13
|
|
|
20
14
|
return {
|
|
21
|
-
searchedOrgUnits:
|
|
22
|
-
|
|
15
|
+
searchedOrgUnits: searchTerm
|
|
16
|
+
? searchedOrgUnits?.organizationalUnits ?? []
|
|
17
|
+
: [],
|
|
18
|
+
isSearchedOrgUnitsLoading: isLoading,
|
|
23
19
|
};
|
|
24
20
|
};
|