change design in norder
This commit is contained in:
@@ -13,7 +13,7 @@ type Props = {
|
||||
|
||||
const RadioGroup: FC<Props> = (props: Props) => {
|
||||
return (
|
||||
<div className='flex gap-5 items-center text-xs'>
|
||||
<div className='flex flex-wrap gap-5 items-center text-xs'>
|
||||
{
|
||||
props.items.map((item, index) => (
|
||||
<div key={index} className='flex gap-2 items-center'>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { type FC, useState } from 'react'
|
||||
import type { FormikProps } from 'formik'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Input from '@/components/Input'
|
||||
import RadioGroup from '@/components/RadioGroup'
|
||||
import Textarea from '@/components/Textarea'
|
||||
import DefaulModal from '@/components/DefaulModal'
|
||||
import LocationInput from '@/pages/settings/components/LocationInput'
|
||||
@@ -68,37 +69,20 @@ const CreateOrderDeliverySection: FC<CreateOrderDeliverySectionProps> = ({
|
||||
|
||||
<div className='mt-6'>
|
||||
<div className='text-sm mb-3'>روش تحویل</div>
|
||||
<div className='grid grid-cols-1 sm:grid-cols-2 gap-3'>
|
||||
{deliveryMethods.map((method) => {
|
||||
const isSelected = formik.values.deliveryMethodId === method.id
|
||||
return (
|
||||
<button
|
||||
key={method.id}
|
||||
type='button'
|
||||
onClick={() => formik.setFieldValue('deliveryMethodId', method.id)}
|
||||
className={`text-right p-4 rounded-xl border transition-colors ${
|
||||
isSelected
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border hover:border-primary/40'
|
||||
}`}
|
||||
>
|
||||
<div className='text-sm font-medium'>
|
||||
{getDeliveryLabel(method.method)}
|
||||
</div>
|
||||
{method.description && (
|
||||
<div className='text-xs text-description mt-1 line-clamp-2'>
|
||||
{method.description}
|
||||
</div>
|
||||
)}
|
||||
{method.deliveryFee > 0 && (
|
||||
<div className='text-xs mt-2 text-primary'>
|
||||
{formatPrice(method.deliveryFee)}
|
||||
</div>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<RadioGroup
|
||||
items={deliveryMethods.map((method) => ({
|
||||
label:
|
||||
method.deliveryFee > 0
|
||||
? `${getDeliveryLabel(method.method)} (${formatPrice(method.deliveryFee)})`
|
||||
: getDeliveryLabel(method.method),
|
||||
value: method.id,
|
||||
}))}
|
||||
selected={formik.values.deliveryMethodId}
|
||||
onChange={(value) => {
|
||||
formik.setFieldValue('deliveryMethodId', value)
|
||||
formik.setFieldTouched('deliveryMethodId', true, false)
|
||||
}}
|
||||
/>
|
||||
{formik.touched.deliveryMethodId && formik.errors.deliveryMethodId && (
|
||||
<div className='text-xs text-red-500 mt-2'>
|
||||
{formik.errors.deliveryMethodId}
|
||||
@@ -108,16 +92,21 @@ const CreateOrderDeliverySection: FC<CreateOrderDeliverySectionProps> = ({
|
||||
|
||||
<div className='mt-8'>
|
||||
<div className='text-sm mb-3'>روش پرداخت</div>
|
||||
<div className='p-4 rounded-xl border border-primary bg-primary/5'>
|
||||
<div className='text-sm font-medium'>پرداخت نقدی</div>
|
||||
{cashPaymentMethod?.description && (
|
||||
<div className='text-xs text-description mt-1'>
|
||||
{cashPaymentMethod.description}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{!cashPaymentMethod && (
|
||||
<div className='text-xs text-red-500 mt-2'>
|
||||
{cashPaymentMethod ? (
|
||||
<RadioGroup
|
||||
items={[
|
||||
{
|
||||
label: cashPaymentMethod.description
|
||||
? `پرداخت نقدی (${cashPaymentMethod.description})`
|
||||
: 'پرداخت نقدی',
|
||||
value: cashPaymentMethod.id,
|
||||
},
|
||||
]}
|
||||
selected={formik.values.paymentMethodId}
|
||||
onChange={(value) => formik.setFieldValue('paymentMethodId', value)}
|
||||
/>
|
||||
) : (
|
||||
<div className='text-xs text-red-500'>
|
||||
روش پرداخت نقدی فعال یافت نشد
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user