'use client'; import { getProfile, updateProfile } from '@/actions/profile'; import { type ProfileProps } from '@/components/profile/types'; import { useMutation, useQuery } from '@tanstack/react-query'; export const useProfileQuery = ({ telegramId }: ProfileProps) => { return useQuery({ queryFn: () => getProfile({ telegramId }), queryKey: telegramId ? ['profile', 'telegramId', telegramId, 'get'] : ['profile', 'get'], }); }; export const useProfileMutation = ({ telegramId }: ProfileProps) => { const { refetch } = useProfileQuery({ telegramId }); return useMutation({ mutationFn: updateProfile, mutationKey: ['profile', 'telegramId', telegramId, 'update'], onSuccess: () => refetch(), }); };