base commit
This commit is contained in:
@@ -3,8 +3,12 @@ import Alert from '@mui/material/Alert'
|
||||
import Box from '@mui/material/Box'
|
||||
import Button from '@mui/material/Button'
|
||||
import FormControl from '@mui/material/FormControl'
|
||||
import FormControlLabel from '@mui/material/FormControlLabel'
|
||||
import InputLabel from '@mui/material/InputLabel'
|
||||
import Link from '@mui/material/Link'
|
||||
import MenuItem from '@mui/material/MenuItem'
|
||||
import Radio from '@mui/material/Radio'
|
||||
import RadioGroup from '@mui/material/RadioGroup'
|
||||
import Select from '@mui/material/Select'
|
||||
import Stack from '@mui/material/Stack'
|
||||
import TextField from '@mui/material/TextField'
|
||||
@@ -23,6 +27,7 @@ export function CheckoutPage() {
|
||||
const qc = useQueryClient()
|
||||
const navigate = useNavigate()
|
||||
const [deliveryType, setDeliveryType] = useState<'delivery' | 'pickup'>('delivery')
|
||||
const [pickupPayment, setPickupPayment] = useState<'online' | 'on_pickup'>('online')
|
||||
const [addressId, setAddressId] = useState('')
|
||||
const [comment, setComment] = useState('')
|
||||
|
||||
@@ -45,6 +50,7 @@ export function CheckoutPage() {
|
||||
mutationFn: () =>
|
||||
createOrder({
|
||||
deliveryType,
|
||||
paymentMethod: deliveryType === 'delivery' ? 'online' : pickupPayment,
|
||||
addressId: deliveryType === 'delivery' ? selectedAddressId : null,
|
||||
comment: comment.trim() || null,
|
||||
}),
|
||||
@@ -134,7 +140,10 @@ export function CheckoutPage() {
|
||||
value={deliveryType}
|
||||
onChange={(e) => {
|
||||
const v = String(e.target.value)
|
||||
if (v === 'delivery' || v === 'pickup') setDeliveryType(v)
|
||||
if (v === 'delivery' || v === 'pickup') {
|
||||
setDeliveryType(v)
|
||||
if (v === 'delivery') setPickupPayment('online')
|
||||
}
|
||||
}}
|
||||
>
|
||||
<MenuItem value="delivery">Доставка</MenuItem>
|
||||
@@ -183,7 +192,35 @@ export function CheckoutPage() {
|
||||
)}
|
||||
|
||||
{deliveryType === 'pickup' && (
|
||||
<Alert severity="info">Самовывоз: адрес доставки не нужен. Мы свяжемся с вами для согласования.</Alert>
|
||||
<>
|
||||
<Alert severity="info" sx={{ mb: 0 }}>
|
||||
Самовывоз: адрес доставки не нужен. Адрес точки выдачи указан на странице{' '}
|
||||
<Link component={RouterLink} to="/about" underline="hover" sx={{ fontWeight: 700 }}>
|
||||
О нас
|
||||
</Link>
|
||||
.
|
||||
</Alert>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" gutterBottom sx={{ mt: 0.5 }}>
|
||||
Оплата
|
||||
</Typography>
|
||||
<RadioGroup
|
||||
value={pickupPayment}
|
||||
onChange={(e) => {
|
||||
const v = String(e.target.value)
|
||||
if (v === 'online' || v === 'on_pickup') setPickupPayment(v)
|
||||
}}
|
||||
>
|
||||
<FormControlLabel value="online" control={<Radio size="small" />} label="Онлайн-оплата" />
|
||||
<FormControlLabel value="on_pickup" control={<Radio size="small" />} label="Оплатить при получении" />
|
||||
</RadioGroup>
|
||||
{pickupPayment === 'on_pickup' && (
|
||||
<Alert severity="info" sx={{ mt: 1 }}>
|
||||
Оплатите заказ наличными или картой при выдаче на самовывозе.
|
||||
</Alert>
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
|
||||
<TextField
|
||||
|
||||
Reference in New Issue
Block a user