payment with card to card

This commit is contained in:
hamid zarghami
2026-06-15 12:18:25 +03:30
parent 1dd639c0b1
commit 22e443cf7b
7 changed files with 221 additions and 200 deletions
+14 -10
View File
@@ -1,7 +1,7 @@
import { type FC, useState } from 'react'
import {
useGetOrderById,
useVerifyCashPayment,
useVerifyPayment,
useChangeOrderStatus,
useRefundPayment
} from './hooks/useOrderData'
@@ -14,6 +14,7 @@ import ModalConfrim from '@/components/ModalConfrim'
import CustomerInfo from './components/CustomerInfo'
import OrderItemsDetails from './components/OrderItemsDetails'
import PaymentInfo from './components/PaymentInfo'
import PaymentVerificationBox from './components/PaymentVerificationBox'
import OrderActions from './components/OrderActions'
import { toast } from 'react-toastify'
import { extractErrorMessage } from '@/config/func'
@@ -22,7 +23,7 @@ import { printOrderReceipt } from './print/orderReceiptPrint'
const OrderDetails: FC = () => {
const { id } = useParams()
const { data: orderData, isLoading } = useGetOrderById(id!)
const { mutate: verifyCashPayment, isPending: isVerifyingPayment } = useVerifyCashPayment()
const { mutate: verifyPayment, isPending: isVerifyingPayment } = useVerifyPayment()
const { mutate: changeOrderStatus, isPending: isChangingStatus } = useChangeOrderStatus()
const { mutate: refundPayment, isPending: isRefunding } = useRefundPayment()
@@ -89,6 +90,7 @@ const OrderDetails: FC = () => {
// منطق نمایش دکمه‌ها
const isCashPayment = order.paymentMethod?.method === PaymentMethodEnum.Cash
const isCreditCardPayment = order.paymentMethod?.method === PaymentMethodEnum.CreditCard
const isPendingPayment = order.status === OrderStatus.PENDING_PAYMENT
const isOrderPaid = order.status === OrderStatus.PAID
const isPreparing = order.status === OrderStatus.PREPARING
@@ -102,9 +104,7 @@ const OrderDetails: FC = () => {
const isDineInOrCarDelivery = order.deliveryMethod?.method === DeliveryMethodEnum.DineIn || order.deliveryMethod?.method === DeliveryMethodEnum.DeliveryCar
const isCustomerPickup = order.deliveryMethod?.method === DeliveryMethodEnum.CustomerPickup
// نمایش دکمه تایید پرداخت نقدی
// وقتی روش پرداخت نقدی است و وضعیت پرداخت Pending باشد
const showVerifyCashPaymentButton = isCashPayment && isPaymentPending
const showVerifyPaymentBox = (isCashPayment || isCreditCardPayment) && isPaymentPending && !isCanceled
// نمایش دکمه ارسال به آشپزخانه
// برای pendingPayment با پرداخت نقدی یا برای paid
@@ -114,10 +114,10 @@ const OrderDetails: FC = () => {
// همیشه نمایش داده می‌شود مگر اینکه سفارش قبلاً کنسل شده باشد
const showCancelButton = !isCanceled
const handleVerifyCashPayment = () => {
const handleVerifyPayment = () => {
const paymentId = order.paymentId || order.payments?.[0]?.id
if (paymentId) {
verifyCashPayment(paymentId, {
verifyPayment(paymentId, {
onSuccess: () => {
// Success handled by query invalidation
},
@@ -232,9 +232,15 @@ const OrderDetails: FC = () => {
getPaymentStatusTextColor={getPaymentStatusTextColor}
getPaymentStatusText={getPaymentStatusText}
/>
{showVerifyPaymentBox && (
<PaymentVerificationBox
order={order}
isVerifyingPayment={isVerifyingPayment}
onVerifyPayment={handleVerifyPayment}
/>
)}
<OrderActions
onPrint={handlePrintOrder}
showVerifyCashPaymentButton={showVerifyCashPaymentButton}
showSendToKitchenButton={showSendToKitchenButton}
showCancelButton={showCancelButton}
isPreparing={isPreparing}
@@ -242,9 +248,7 @@ const OrderDetails: FC = () => {
isDineInOrCarDelivery={isDineInOrCarDelivery}
isCustomerPickup={isCustomerPickup}
isCanceled={isCanceled}
isVerifyingPayment={isVerifyingPayment}
isChangingStatus={isChangingStatus}
onVerifyCashPayment={handleVerifyCashPayment}
onSendToKitchen={handleSendToKitchen}
onDeliverToCourier={handleDeliverToCourier}
onDeliverToWaiter={handleDeliverToWaiter}