implment send amount gift api
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user