import { getRequest } from "@/api/customFetch";
import { getRestaurantFoodDetail, getRestaurantFoodList, getRestaurantFoodSet } from "@/api/interfaceDocument";

export const foodList = ref<any[]>([]);
export const packingFee = ref(0);
export const shippingFee = ref(0);
export const useRestaurantFoodList = () => {

  getRequest(getRestaurantFoodList()).then((resp) => {
    if (resp.code === 200) {
      foodList.value = (resp.result as { items: any[] }).items;
      packingFee.value = (resp.result as { packingFee: number }).packingFee;
      shippingFee.value = (resp.result as { shippingFee: number }).shippingFee;
    }
  });
};

export const foodSetList = ref<any[]>([]);
export const useRestaurantFoodSet = () => {
  getRequest(getRestaurantFoodSet()).then((resp) => {
    if (resp.code === 200) {
      foodSetList.value = (resp.result as { items: any[] }).items;
    }
  });
};


export const useRestaurantFoodDetail = () => {
  const foodDetail = ref<any>({});

  getRequest(getRestaurantFoodDetail()).then((resp) => {
    if (resp.code === 200) {
      foodDetail.value = resp.result;
    }
  });
  return {foodDetail}
};