26 lines
930 B
TypeScript
26 lines
930 B
TypeScript
import { getCustomerClients, getCustomerMasters } from '@/actions/api/customers';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useSession } from 'next-auth/react';
|
|
|
|
export const useClientsQuery = (props?: Parameters<typeof getCustomerClients>[0]) => {
|
|
const { data: session } = useSession();
|
|
const telegramId = props?.telegramId || session?.user?.telegramId;
|
|
|
|
return useQuery({
|
|
enabled: false,
|
|
queryFn: () => getCustomerClients({ telegramId }),
|
|
queryKey: ['customer', 'telegramId', telegramId, 'clients', 'get'],
|
|
});
|
|
};
|
|
|
|
export const useMastersQuery = (props?: Parameters<typeof getCustomerMasters>[0]) => {
|
|
const { data: session } = useSession();
|
|
const telegramId = props?.telegramId || session?.user?.telegramId;
|
|
|
|
return useQuery({
|
|
enabled: false,
|
|
queryFn: () => getCustomerMasters({ telegramId }),
|
|
queryKey: ['customer', 'telegramId', telegramId, 'masters', 'get'],
|
|
});
|
|
};
|