discountAmount and packingFee in create order admin
This commit is contained in:
@@ -29,6 +29,8 @@ interface OrderSummaryData {
|
||||
} | null>
|
||||
subTotal: number
|
||||
deliveryFee: number
|
||||
packingFee: number
|
||||
discountAmount: number
|
||||
total: number
|
||||
totalItems: number
|
||||
}
|
||||
@@ -129,7 +131,7 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='bg-white rounded-4xl p-5 flex-1 min-h-0 flex flex-col h-full'>
|
||||
<div className='bg-white rounded-4xl p-4 flex-1 min-h-0 flex flex-col h-full'>
|
||||
<div className='flex items-center justify-between flex-shrink-0'>
|
||||
<div className='flex items-center gap-2 text-sm font-light'>
|
||||
<ShoppingCart size={18} color='#000' />
|
||||
@@ -143,12 +145,12 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
</div>
|
||||
|
||||
{(customerName || formik.values.userPhone) && (
|
||||
<div className='mt-3 p-3 bg-[#F8F9FC] rounded-xl flex-shrink-0'>
|
||||
<div className='text-xs font-medium truncate'>
|
||||
<div className='mt-2 p-2.5 bg-[#F8F9FC] rounded-xl flex-shrink-0'>
|
||||
<div className='text-[11px] font-medium truncate'>
|
||||
{customerName || 'مشتری'}
|
||||
</div>
|
||||
{formik.values.userPhone && (
|
||||
<div className='text-[11px] text-description mt-0.5'>
|
||||
<div className='text-[10px] text-description mt-0.5'>
|
||||
{formik.values.userPhone}
|
||||
</div>
|
||||
)}
|
||||
@@ -158,7 +160,7 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
<button
|
||||
type='button'
|
||||
onClick={() => setIsDeliveryModalOpen(true)}
|
||||
className={`mt-3 w-full text-right p-3 rounded-xl border transition-colors flex-shrink-0 ${
|
||||
className={`mt-2 w-full text-right p-2.5 rounded-xl border transition-colors flex-shrink-0 ${
|
||||
isDeliverySelected && isPaymentSelected
|
||||
? 'border-border hover:border-primary/40 hover:bg-[#F8F9FC]'
|
||||
: 'border-dashed border-primary/50 bg-primary/5 hover:bg-primary/10'
|
||||
@@ -178,7 +180,7 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<div className='mt-2 space-y-2'>
|
||||
<div className='mt-1.5 space-y-1.5'>
|
||||
<div className='flex items-center gap-2 text-xs'>
|
||||
<Truck size={15} color='#8C90A3' className='flex-shrink-0' />
|
||||
<span
|
||||
@@ -221,8 +223,8 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div className='mt-4 pt-3 border-t border-border border-dashed flex-1 min-h-0 flex flex-col'>
|
||||
<div className='text-xs text-description mb-2 flex-shrink-0'>سبد سفارش</div>
|
||||
<div className='mt-3 pt-2.5 border-t border-border border-dashed flex-1 min-h-0 flex flex-col'>
|
||||
<div className='text-xs text-description mb-1.5 flex-shrink-0'>سبد سفارش</div>
|
||||
|
||||
<div className='flex-1 min-h-0 overflow-y-auto relative'>
|
||||
{orderSummary.lineItems.length === 0 ? (
|
||||
@@ -233,7 +235,7 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className='space-y-2.5 pb-2'>
|
||||
<div className='space-y-2 pb-2'>
|
||||
{orderSummary.lineItems.map((item) => {
|
||||
if (!item) return null
|
||||
return (
|
||||
@@ -319,7 +321,51 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='mt-3 space-y-2 text-xs pt-3 border-t border-border flex-shrink-0'>
|
||||
<div className='mt-2 space-y-2 text-xs pt-2.5 border-t border-border flex-shrink-0'>
|
||||
<div className='grid grid-cols-2 gap-2.5 mb-2'>
|
||||
<div>
|
||||
<div className='text-xs mb-1.5'>
|
||||
<span className='font-medium'>هزینه بستهبندی</span>
|
||||
<span className='text-description mr-1'>(اختیاری)</span>
|
||||
</div>
|
||||
<input
|
||||
name='packingFee'
|
||||
type='number'
|
||||
inputMode='numeric'
|
||||
min={0}
|
||||
placeholder='تومان'
|
||||
className='w-full h-10 rounded-xl border border-border px-3 text-sm outline-none focus:border-primary'
|
||||
value={formik.values.packingFee || ''}
|
||||
onChange={(e) =>
|
||||
formik.setFieldValue(
|
||||
'packingFee',
|
||||
Math.max(Number(e.target.value) || 0, 0)
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs mb-1.5'>
|
||||
<span className='font-medium'>تخفیف مبلغی</span>
|
||||
<span className='text-description mr-1'>(اختیاری)</span>
|
||||
</div>
|
||||
<input
|
||||
name='discountAmount'
|
||||
type='number'
|
||||
inputMode='numeric'
|
||||
min={0}
|
||||
placeholder='تومان'
|
||||
className='w-full h-10 rounded-xl border border-border px-3 text-sm outline-none focus:border-primary'
|
||||
value={formik.values.discountAmount || ''}
|
||||
onChange={(e) =>
|
||||
formik.setFieldValue(
|
||||
'discountAmount',
|
||||
Math.max(Number(e.target.value) || 0, 0)
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex justify-between'>
|
||||
<span className='text-description'>جمع آیتمها</span>
|
||||
<span>{formatPrice(orderSummary.subTotal)}</span>
|
||||
@@ -330,6 +376,20 @@ const CreateOrderSidebar: FC<CreateOrderSidebarProps> = ({
|
||||
<span>{formatPrice(orderSummary.deliveryFee)}</span>
|
||||
</div>
|
||||
)}
|
||||
{orderSummary.packingFee > 0 && (
|
||||
<div className='flex justify-between'>
|
||||
<span className='text-description'>هزینه بستهبندی</span>
|
||||
<span>{formatPrice(orderSummary.packingFee)}</span>
|
||||
</div>
|
||||
)}
|
||||
{orderSummary.discountAmount > 0 && (
|
||||
<div className='flex justify-between'>
|
||||
<span className='text-description'>تخفیف</span>
|
||||
<span className='text-green-600'>
|
||||
-{formatPrice(orderSummary.discountAmount)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div className='flex justify-between font-bold text-sm pt-2 border-t-2 border-gray-200'>
|
||||
<span>جمع کل</span>
|
||||
<span>{formatPrice(orderSummary.total)}</span>
|
||||
|
||||
Reference in New Issue
Block a user