stylist / frontend / src / api / useFetchSalonServices.ts
useFetchSalonServices.ts
Raw
import { QueryOptions, useQuery } from 'react-query';

import { api } from '.';
//types
import { SalonPageServices } from '@/types/services';

const fetchSalonServices = async (id: number | undefined) => {
  if (!id) {
    return undefined;
  }
  return await api.get<never, SalonPageServices[]>(
    `/services/recommended/salon/${id}`
  );
};

export const useFetchSalonServices = (
  id: number | undefined,
  options?: QueryOptions<SalonPageServices[] | undefined>
) => {
  return useQuery(
    ['services/recommended/salon', id],
    () => fetchSalonServices(id),
    options
  );
};