refactor(StorePage): extract getAllStore function to improve code readability and reusability

feat(StorePage): call getAllStore function when search text is entered or search button is clicked to update store components
This commit is contained in:
anovazzi1 2023-11-13 15:44:07 -03:00
commit 34c6ce86f0

View file

@ -47,19 +47,16 @@ export default function StorePage(): JSX.Element {
handleGetTags();
}, []);
useEffect(() => {
function getAllStore() {
handleGetComponents();
if (hasApiKey) {
getSavedComponents();
}
}, [
searchText,
tabActive,
pageOrder,
pageIndex,
pageSize,
filteredCategories,
]);
}
useEffect(() => {
getAllStore();
}, [tabActive, pageOrder, pageIndex, pageSize, filteredCategories]);
function handleGetTags() {
setLoadingTags(true);
@ -161,6 +158,7 @@ export default function StorePage(): JSX.Element {
onKeyDown={(e) => {
if (e.key === "Enter") {
setSearchText(inputText);
getAllStore();
}
}}
value={inputText}
@ -169,6 +167,7 @@ export default function StorePage(): JSX.Element {
className="absolute bottom-0 right-4 top-0 my-auto h-6 cursor-pointer stroke-1 text-muted-foreground"
onClick={() => {
setSearchText(inputText);
getAllStore();
}}
>
<IconComponent