71 lines
1.6 KiB
TypeScript
71 lines
1.6 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet";
|
|
import ProRatioGroups from "../ProRatioGroups/ProRatioGroups";
|
|
|
|
interface CouponBottomSheetProps {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
initialValue: string;
|
|
onSave: (value: string) => void;
|
|
}
|
|
|
|
export function CouponBottomSheet({
|
|
isOpen,
|
|
onClose,
|
|
initialValue,
|
|
onSave,
|
|
}: CouponBottomSheetProps) {
|
|
const { t } = useTranslation();
|
|
const [value, setValue] = useState(initialValue);
|
|
|
|
useEffect(() => {
|
|
setValue(initialValue);
|
|
}, [initialValue]);
|
|
|
|
const handleSave = () => {
|
|
onSave(value);
|
|
onClose();
|
|
};
|
|
|
|
const handleCancel = () => {
|
|
setValue(initialValue);
|
|
onClose();
|
|
};
|
|
|
|
return (
|
|
<ProBottomSheet
|
|
isOpen={isOpen}
|
|
onClose={handleCancel}
|
|
title={t("cart.coupon")}
|
|
showCloseButton={false}
|
|
initialSnap={1}
|
|
height={350}
|
|
snapPoints={["30vh"]}
|
|
>
|
|
<div>
|
|
<ProRatioGroups
|
|
options={[
|
|
{
|
|
label: "50% off, Min order : SDG 10,000",
|
|
value: "50",
|
|
price: "0"
|
|
},
|
|
{
|
|
label: "Buy one get one free, Min order : SDG 5,000",
|
|
value: "buy",
|
|
price: "0"
|
|
},
|
|
{
|
|
label: "30% off on select items, Min order : SDG 15,000",
|
|
value: "30",
|
|
price: "0"
|
|
},
|
|
]}
|
|
onRatioClick={handleSave}
|
|
/>
|
|
</div>
|
|
</ProBottomSheet>
|
|
);
|
|
}
|