import useSWR from 'swr';
import { getDiscounts } from '@api/discounts';
import type { Discount } from '@model/discounts';

export const useDiscounts = (userId: string | null) => {
  return useSWR<Discount[]>(
    userId ? `discounts/${userId}` : null,
    () => getDiscounts(userId!).then(([data]) => data)
  );
}; 