1234567891011121314151617181920212223242526 |
- import { countriesQueryKeys } from '../countries-query-keys';
- import { countriesApi, type PostGetUsersFromCountryDataReturn } from '../countries-api';
- import type { BaseAxiosError } from '../../../../types';
- import { useMutation } from '@tanstack/react-query';
- export const useGetUsersFromCountryMutation = () => {
- return useMutation<
- PostGetUsersFromCountryDataReturn,
- BaseAxiosError,
- { id: number; page: number; sort?: string; age?: number },
- PostGetUsersFromCountryDataReturn
- >({
- mutationKey: countriesQueryKeys.getUsersFromCountry(),
- mutationFn: async (variables) => {
- const response = await countriesApi.getUsersFromCountry(
- variables.id,
- variables.page,
- variables.sort,
- variables.age
- );
- return response.data;
- }
- });
- };
|