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(); 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