- Changed the terminology from "masters" to "invited" and "invitedBy" across the codebase for clarity and consistency. - Updated the `addContact` function to reflect the new naming convention. - Refactored API actions and server methods to support the new invited structure. - Adjusted components and hooks to utilize the updated invited data, enhancing user experience and simplifying logic.
24 lines
838 B
TypeScript
24 lines
838 B
TypeScript
import { getInvited, getInvitedBy } from '@/actions/api/customers';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useSession } from 'next-auth/react';
|
|
|
|
export const useInvitedQuery = (props?: Parameters<typeof getInvited>[0]) => {
|
|
const { data: session } = useSession();
|
|
const telegramId = props?.telegramId || session?.user?.telegramId;
|
|
|
|
return useQuery({
|
|
queryFn: () => getInvited({ telegramId }),
|
|
queryKey: ['customer', 'telegramId', telegramId, 'invited'],
|
|
});
|
|
};
|
|
|
|
export const useInvitedByQuery = (props?: Parameters<typeof getInvitedBy>[0]) => {
|
|
const { data: session } = useSession();
|
|
const telegramId = props?.telegramId || session?.user?.telegramId;
|
|
|
|
return useQuery({
|
|
queryFn: () => getInvitedBy({ telegramId }),
|
|
queryKey: ['customer', 'telegramId', telegramId, 'invitedBy'],
|
|
});
|
|
};
|