import { ScheduleFilled } from "@ant-design/icons";
import { Card } from "antd";
import BackIcon from "components/Icons/BackIcon";
import DeliveryIcon from "components/Icons/DeliveryIcon";
import DineInIcon from "components/Icons/DineInIcon";
import NextIcon from "components/Icons/NextIcon";
import PickupIcon from "components/Icons/PickupIcon";
import SendGiftIcon from "components/Icons/SendGiftIcon";
import ToOfficeIcon from "components/Icons/ToOfficeIcon";
import ToRoomIcon from "components/Icons/ToRoomIcon";
import ProTitle from "components/ProTitle";
import { updateOrderType } from "features/order/orderSlice";
import { OrderType } from "pages/checkout/hooks/types.ts";
import { useTranslation } from "react-i18next";
import { Link, useParams } from "react-router-dom";
import { useGetRestaurantDetailsQuery } from "redux/api/others";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import styles from "./restaurant.module.css";
export default function RestaurantServices() {
const { t } = useTranslation();
const { isRTL } = useAppSelector((state) => state.locale);
const { subdomain } = useParams();
const dispatch = useAppDispatch();
const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain, {
skip: !subdomain,
});
const {
dineIn,
pickup,
gift,
toRoom,
toOffice,
// is_booking_enabled,
delivery,
is_schedule_order_enabled,
pickup_type,
} = restaurant || {};
const services = [
...((dineIn && [
{
id: OrderType.DineIn,
title: t("common.dineIn"),
description: t("home.services.dineIn"),
icon: (
),
color: "bg-blue-50 text-blue-600",
href: `/${subdomain}/menu?orderType=${OrderType.DineIn}`,
},
]) ||
[]),
...((pickup && [
{
id: OrderType.Pickup,
title: pickup_type === "car" ? t("common.car") : t("common.pickup"),
description: t("home.services.pickup"),
icon: (
),
color: "bg-green-50 text-green-600",
href: `/${subdomain}/menu?orderType=${OrderType.Pickup}`,
},
]) ||
[]),
...((gift && [
{
id: OrderType.Gift,
title: t("common.sendGift"),
description: t("home.services.gift"),
icon: (
),
color: "bg-pink-50 text-pink-600",
href: `/${subdomain}/menu?orderType=${OrderType.Gift}`,
},
]) ||
[]),
...((toRoom && [
{
id: OrderType.ToRoom,
title: t("common.roomService"),
description: t("home.services.room"),
icon: (
),
color: "bg-purple-50 text-purple-600",
href: `/${subdomain}/menu?orderType=${OrderType.ToRoom}`,
},
]) ||
[]),
...((toOffice && [
{
id: OrderType.ToOffice,
title: t("common.officeDelivery"),
description: t("home.services.office"),
icon: (
),
color: "bg-orange-50 text-orange-600",
href: `/${subdomain}/menu?orderType=${OrderType.ToOffice}`,
},
]) ||
[]),
// ...((is_booking_enabled && [
// {
// id: OrderType.Booking,
// title: t("common.tableBooking"),
// description: t("home.services.booking"),
// icon: (
//
// ),
// color: "bg-indigo-50 text-indigo-600",
// href: `/${subdomain}/menu?orderType=${OrderType.Booking}`,
// },
// ]) ||
// []),
...((delivery && [
{
id: OrderType.Delivery,
title: t("common.delivery"),
description: t("home.services.delivery"),
icon: (
),
color: "bg-indigo-50 text-indigo-600",
href: `/${subdomain}/address`,
},
]) ||
[]),
...((is_schedule_order_enabled === 1 && [
{
id: OrderType.ScheduledOrder,
title: t("common.scheduledOrder"),
description: t("home.services.scheduledOrder"),
icon: (
),
color: "bg-indigo-50 text-indigo-600",
href: `/${subdomain}/menu?orderType=${OrderType.ScheduledOrder}`,
},
]) ||
[]),
// ...((true && [
// {
// id: OrderType.Pay,
// title: t("common.pay"),
// description: t("home.services.pay"),
// icon: (
//
// ),
// color: "bg-orange-50 text-orange-600",
// href: `/${subdomain}/pay`,
// },
// ]) ||
// []),
];
// Determine grid class based on number of services
const getGridClass = () => {
const serviceCount = services.length;
if (serviceCount <= 2) return `${styles.servicesGrid} ${styles.twoColumns}`;
if (serviceCount >= 4)
return `${styles.servicesGrid} ${styles.manyServices}`;
return styles.servicesGrid;
};
return (
{services?.map((s) => {
return (
{
dispatch(updateOrderType(s?.id));
}}
style={{
width: "100%",
}}
>
);
})}
);
}