Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
barbara-chaves committed Jun 18, 2024
1 parent f3b5940 commit f057c2a
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions client/src/lib/localized-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,16 @@ export const getBySlugIdQueryOptions = <
};

const _isNotFoundError = (error: unknown) => {
return !!(error && typeof error === "object" && "response" in error && !!error.response && typeof error.response === "object" && "status" in error.response && error?.response?.status === 404)
}
return !!(
error &&
typeof error === "object" &&
"response" in error &&
!!error.response &&
typeof error.response === "object" &&
"status" in error.response &&
error?.response?.status === 404
);
};

export const useGetBySlug = <
TData = Awaited<ReturnType<typeof getBySlugId>>,
Expand All @@ -78,19 +86,20 @@ export const useGetBySlug = <
},
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = useMemo(
() => getBySlugIdQueryOptions(id, params, {
...options,
query: {
retry: (failureCount: number, error) => {
if (_isNotFoundError(error)) {
return false;
}
return failureCount < 3;
() =>
getBySlugIdQueryOptions(id, params, {
...options,
query: {
retry: (failureCount: number, error) => {
if (_isNotFoundError(error)) {
return false;
}
return failureCount < 3;
},
...options?.query,
queryKey: options?.query?.queryKey ?? [],
},
...options?.query,
queryKey: options?.query?.queryKey ?? [],
},
}),
}),
[id, params, options],
);

Expand Down

0 comments on commit f057c2a

Please sign in to comment.