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,20 +1,9 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { credits } from '@/api';
|
||||
import creditsQuery, { CreditsQueryProps } from '@/api/queries/credits';
|
||||
|
||||
interface Props {
|
||||
showId?: Show['id'];
|
||||
showType?: Show['type'];
|
||||
}
|
||||
|
||||
export const KEY = ({ showId, showType }: Props) => ['credits', showId, showType];
|
||||
|
||||
const useCredits = ({ showId, showType }: Props) => {
|
||||
return useQuery({
|
||||
queryKey: KEY({ showId, showType }),
|
||||
queryFn: () => credits({ showId, showType }),
|
||||
enabled: Boolean(showId)
|
||||
});
|
||||
const useCredits = ({ showId, showType }: CreditsQueryProps) => {
|
||||
return useQuery(creditsQuery({ showId, showType }));
|
||||
};
|
||||
|
||||
export default useCredits;
|
||||
Reference in new issue
Block a user