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:
parent
3a87f7fa4c
commit
34c6ce86f0
1 changed files with 8 additions and 9 deletions
|
|
@ -47,19 +47,16 @@ export default function StorePage(): JSX.Element {
|
||||||
handleGetTags();
|
handleGetTags();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
function getAllStore() {
|
||||||
handleGetComponents();
|
handleGetComponents();
|
||||||
if (hasApiKey) {
|
if (hasApiKey) {
|
||||||
getSavedComponents();
|
getSavedComponents();
|
||||||
}
|
}
|
||||||
}, [
|
}
|
||||||
searchText,
|
|
||||||
tabActive,
|
useEffect(() => {
|
||||||
pageOrder,
|
getAllStore();
|
||||||
pageIndex,
|
}, [tabActive, pageOrder, pageIndex, pageSize, filteredCategories]);
|
||||||
pageSize,
|
|
||||||
filteredCategories,
|
|
||||||
]);
|
|
||||||
|
|
||||||
function handleGetTags() {
|
function handleGetTags() {
|
||||||
setLoadingTags(true);
|
setLoadingTags(true);
|
||||||
|
|
@ -161,6 +158,7 @@ export default function StorePage(): JSX.Element {
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
setSearchText(inputText);
|
setSearchText(inputText);
|
||||||
|
getAllStore();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
value={inputText}
|
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"
|
className="absolute bottom-0 right-4 top-0 my-auto h-6 cursor-pointer stroke-1 text-muted-foreground"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSearchText(inputText);
|
setSearchText(inputText);
|
||||||
|
getAllStore();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue