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