implment send amount gift api

This commit is contained in:
2026-01-15 07:22:48 +03:00
parent 68a12a4796
commit ab5867b0cb
4 changed files with 106 additions and 4 deletions

View File

@@ -10,14 +10,17 @@ import { EqualltyChoiceBottomSheet } from "pages/pay/components/splitBill/Equall
import { SplitBillChoiceBottomSheet } from "pages/pay/components/splitBill/SplitBillChoiceBottomSheet";
import { CustomAmountChoiceBottomSheet } from "pages/pay/components/splitBill/CustomAmountChoiceBottomSheet";
import { PayForYourItemsChoiceBottomSheet } from "pages/pay/components/splitBill/PayForYourItemsChoiceBottomSheet";
import useGidtAmount from "../hooks/useGidtAmount";
import { GiftType } from "components/CustomBottomSheet/GiftTypeBottomSheet";
type SplitWay = "customAmount" | "equality" | "payForItems" | null;
export default function CheckoutButton({ form }: { form: FormInstance }) {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const { orderType } = useAppSelector(selectCart);
const { orderType, giftDetails } = useAppSelector(selectCart);
const { handleCreateOrder } = useOrder();
const { handleCreateGiftAmount } = useGidtAmount();
const [selectedSplitWay, setSelectedSplitWay] = useState<SplitWay>(null);
const [
isSplitBillChoiceBottomSheetOpen,
@@ -47,11 +50,18 @@ export default function CheckoutButton({ form }: { form: FormInstance }) {
const handlePlaceOrderClick = useCallback(async () => {
try {
await form.validateFields();
handleCreateOrder();
if (
orderType === OrderType.Gift &&
giftDetails?.giftType === GiftType.Vouchers
) {
handleCreateGiftAmount();
} else {
handleCreateOrder();
}
} catch (error) {
console.log(error);
}
}, [handleCreateOrder, form]);
}, [handleCreateOrder, handleCreateGiftAmount, form, orderType, giftDetails]);
const shouldShowSplitBill = useMemo(
() => orderType === OrderType.DineIn,