🐛 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,
limit: number = 10,
is_component?: boolean | null
) {
): Promise<StoreComponentResponse | undefined> {
try {
let url = `${BASE_URL_API}store/components/`;
const queryParams: any = [];

View file

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