import { Card, Divider, Space } from "antd";
import ArabicPrice from "components/ArabicPrice";
import { selectCartTotal } from "features/order/orderSlice";
import { useTranslation } from "react-i18next";
import { useAppSelector } from "redux/hooks";
import ProText from "../ProText";
import ProTitle from "../ProTitle";
import styles from "./OrderSummary.module.css";

export default function OrderSummary() {
  const { t } = useTranslation();
  const subtotal = useAppSelector(selectCartTotal);
  const tax = subtotal * 0.1; // 10% tax
  const total = subtotal + tax;

  return (
    <>
      <Card className={`${styles.orderSummary}`}>
        <ProTitle style={{ fontSize: 18 }}>{t("cart.orderSummary")}</ProTitle>
        <Divider style={{ margin: "15px 0 15px 0" }} />
        <Space direction="vertical" style={{ width: "100%" }}>
          <div className={styles.summaryRow}>
            <ProText type="secondary">{t("cart.basketTotal")}</ProText>
            <ArabicPrice price={subtotal} />
          </div>
          <div className={styles.summaryRow}>
            <ProText type="secondary">{t("cart.discount")}</ProText>
            <ArabicPrice price={0} />
          </div>
          <div className={styles.summaryRow}>
            <ProText type="secondary">{t("cart.riderTip")}</ProText>
            <ArabicPrice price={tax} />
          </div>
          <Divider className={styles.summaryDivider} />
          <div className={`${styles.summaryRow} ${styles.totalRow}`}>
            <ProText strong type="secondary">{t("cart.totalAmount")}</ProText>
            <ArabicPrice price={total} strong />
          </div>
        </Space>
      </Card>
    </>
  );
}
