import { api } from "@/config/axios";
import {
  CategoriesResponse,
  FoodsResponse,
  NotificationsCountResponse,
  SlidersResponse,
} from "../types/Types";

export const getFoods = async (slug: string): Promise<FoodsResponse> => {
  const response = await api.get<FoodsResponse>(
    `/public/foods/restaurant/${slug}`
  );
  return response.data;
};

export const getCategories = async (
  slug: string
): Promise<CategoriesResponse> => {
  const response = await api.get<CategoriesResponse>(
    `/public/categories/restaurant/${slug}`
  );
  return response.data;
};

export const getNotificationsCount = async (): Promise<
  NotificationsCountResponse
> => {
  const response = await api.get<NotificationsCountResponse>(
    `/public/notifications/unseen-count`
  );
  return response.data;
};

export const getSliders = async (slug: string): Promise<SlidersResponse> => {
  try {
    const response = await api.get<SlidersResponse>(
      `/public/sliders/restaurant/${slug}`,
    );
    return response.data;
  } catch {
    return { success: true, data: [] };
  }
};
