feat: introduce usePlanAndUsage with RQ

This commit is contained in:
Rıdvan Akca
2024-03-28 15:25:40 +03:00
parent d74af4931e
commit 0609f30e25
2 changed files with 40 additions and 1 deletions

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;
}