import { api } from "@/config/axios";
import { FoodResponse } from "../../types/Types";
import { CreateReviewType, FoodReviewsResponse } from "../types/ReviewTypes";

export const getFood = async (id: string): Promise<FoodResponse> => {
  const { data } = await api.get<FoodResponse>(`/public/foods/${id}`);
  return data;
};

export const toggleFavorite = async (foodId: string) => {
  const { data } = await api.post(`/public/foods/favorite/${foodId}`);
  return data;
};

export const getFoodReviews = async (foodId: string): Promise<FoodReviewsResponse> => {
  const { data } = await api.get<FoodReviewsResponse>(`/public/reviews/${foodId}`);
  return data;
};

export const createReview = async (params: CreateReviewType) => {
  const { data } = await api.post("/public/reviews", params);
  return data;
};
