contact information + ...

This commit is contained in:
hamid zarghami
2025-10-27 13:00:03 +03:30
parent 10b395577a
commit abc74eb970
7 changed files with 41 additions and 33 deletions
+20 -21
View File
@@ -11,6 +11,8 @@ import { useGetCart, useSaveShipmentCart, useShippingCost } from '../hooks/useCa
import { useGetProfile } from '@/app/profile/hooks/useProfileData'
import Link from 'next/link'
import { useState, useEffect } from 'react'
import { toast } from '@/components/Toast'
import { extractErrorMessage } from '@/helpers/errorUtils'
const CartShipping: NextPage = () => {
@@ -67,30 +69,27 @@ const CartShipping: NextPage = () => {
setIsSavingShipment(true)
try {
// تبدیل selectedShipments به فرمت مورد نیاز API
const shipmentsInfo = Object.entries(selectedShipments).map(([shopId, shipperId]) => ({
shopId,
shipmentId: shipperId
}))
// تبدیل selectedShipments به فرمت مورد نیاز API
const shipmentsInfo = Object.entries(selectedShipments).map(([shopId, shipperId]) => ({
shopId,
shipmentId: shipperId
}))
// ذخیره انتخاب‌ها در API
await new Promise<void>((resolve, reject) => {
saveShipmentCart({ shipmentsInfo }, {
onSuccess: () => resolve(),
onError: (error) => reject(error)
})
// ذخیره انتخاب‌ها در API
await new Promise<void>((resolve, reject) => {
saveShipmentCart({ shipmentsInfo }, {
onSuccess: () => {
resolve()
window.location.href = '/cart/payment'
},
onError: (error) => {
setIsSavingShipment(false)
toast(extractErrorMessage(error))
reject(error)
}
})
})
// انتقال به صفحه پرداخت
window.location.href = '/cart/payment'
} catch (error) {
console.error('Error saving shipment cart:', error)
// در صورت خطا همچنان به صفحه پرداخت برویم
window.location.href = '/cart/payment'
} finally {
setIsSavingShipment(false)
}
}
if (cartLoading || shippingLoading || profileLoading) {