🐛 fix(API/index.ts): add return type to getStoreComponents function to improve code readability and maintainability

🐛 fix(StorePage/index.tsx): fix comment syntax error to prevent code from being commented out
🐛 fix(StorePage/index.tsx): handle undefined response in getStoreComponents promise chain to prevent errors
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-07 14:39:49 -03:00
commit c9d22071cd
2 changed files with 4 additions and 5 deletions

View file

@ -594,7 +594,7 @@ export async function getStoreComponents(
page: number = 1, page: number = 1,
limit: number = 10, limit: number = 10,
is_component?: boolean | null is_component?: boolean | null
) { ): Promise<StoreComponentResponse | undefined> {
try { try {
let url = `${BASE_URL_API}store/components/`; let url = `${BASE_URL_API}store/components/`;
const queryParams: any = []; const queryParams: any = [];

View file

@ -74,7 +74,7 @@ export default function StorePage(): JSX.Element {
let results = data?.results ?? []; let results = data?.results ?? [];
results.forEach((flow) => { results.forEach((flow) => {
savedIds.add(flow.id); savedIds.add(flow.id);
}); /* }); /*
setSavedFlows(savedIds); */ setSavedFlows(savedIds); */
setErrorApiKey(false); setErrorApiKey(false);
setLoading(false); setLoading(false);
@ -86,10 +86,9 @@ export default function StorePage(): JSX.Element {
getStoreComponents(index - 1, size, filterComponent.current) getStoreComponents(index - 1, size, filterComponent.current)
.then((res) => { .then((res) => {
console.log(res);
setLoading(false); setLoading(false);
setSearchData(res.results); setSearchData(res?.results ?? []);
setTotalRowsCount(Number(res.count)); setTotalRowsCount(Number(res?.count ?? 0));
setErrorApiKey(true); setErrorApiKey(true);
}) })
.catch((err) => { .catch((err) => {