feat: introduce usePlanAndUsage with RQ

This commit is contained in:
Rıdvan Akca
2024-04-08 14:45:42 +02:00
parent d74af4931e
commit 0609f30e25
2 changed files with 40 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
import useCurrentUser from './useCurrentUser';
export default function usePlanAndUsage() {
const { data } = useCurrentUser();
const currentUserId = data?.data?.id;
const query = useQuery({
queryKey: ['planAndUsage', currentUserId],
queryFn: async ({ signal }) => {
const { data } = await api.get(
`/v1/users/${currentUserId}/plan-and-usage`,
{
signal,
},
);
return data;
},
});
return query;
}