* refactor customer api * refactor slots api * hooks/customers: use invalidateQueries * refactor services api * optimize hooks queryKey * refactor orders api * typo refactor hooks * fix telegramId type (number) * fix bot with new api * rename customers masters & clients query * fix useClientsQuery & useMastersQuery query * new line after 'use client' & 'use server' directives
24 lines
828 B
TypeScript
24 lines
828 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({
|
|
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({
|
|
queryFn: () => getMasters({ telegramId }),
|
|
queryKey: ['customer', 'telegramId', telegramId, 'masters'],
|
|
});
|
|
};
|