fix(StorePage/index.tsx): set validApiKey to true in useEffect to fix missing data bug

fix(StorePage/index.tsx): handle unauthorized response and set validApiKey to false to handle invalid API key error
This commit is contained in:
cristhianzl 2023-11-17 01:23:02 -03:00
commit e021df94f0

View file

@ -61,6 +61,7 @@ export default function StorePage(): JSX.Element {
useEffect(() => { useEffect(() => {
handleGetComponents(); handleGetComponents();
setValidApiKey(true);
}, [ }, [
tabActive, tabActive,
pageOrder, pageOrder,
@ -97,6 +98,11 @@ export default function StorePage(): JSX.Element {
filterByUser: selectFilter === "createdbyme" && validApiKey ? true : null, filterByUser: selectFilter === "createdbyme" && validApiKey ? true : null,
}) })
.then((res) => { .then((res) => {
if (res?.authorized === false && validApiKey === false) {
setValidApiKey(false);
return;
}
setLoading(false); setLoading(false);
setSearchData(res?.results ?? []); setSearchData(res?.results ?? []);
setTotalRowsCount( setTotalRowsCount(