refactoring: server actions data fetching -> api routes
This commit is contained in:
1 parent
1111712d2c
commit
5cbf93b3b8
38 files changed
+326
-308
No files matched your search
@@ -1,19 +1,12 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { details } from '@/api';
|
||||
import detailsQuery from '@/api/queries/details';
|
||||
|
||||
interface Props {
|
||||
showId?: Show['id'];
|
||||
showType?: Show['type'];
|
||||
}
|
||||
|
||||
export const KEY = ({ showId, showType = 'movie' }: Props) => ['details', showId, showType];
|
||||
|
||||
const useDetails = ({ showId, showType = 'movie' }: Props) =>
|
||||
useQuery({
|
||||
enabled: Boolean(showId && showType),
|
||||
queryKey: KEY({ showId, showType }),
|
||||
queryFn: () => details({ showId: showId!, showType })
|
||||
});
|
||||
const useDetails = ({ showId, showType = 'movie' }: Props) => useQuery(detailsQuery({ showId, showType }));
|
||||
|
||||
export default useDetails;
|
||||
Reference in new issue
Block a user