This commit is contained in:
a.ilin
2026-10-06 10:23:46 +03:00
parent 9654c2d9ef
commit f6fd6d79a0
9 changed files with 194 additions and 57 deletions
+18 -7
View File
@@ -2,6 +2,7 @@ import type { FormInstance } from 'antd'
import { Button, Form, Input, InputNumber, Select, Space } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
import type { CreateAttractionRequest, CvProfile, UpdateAttractionRequest } from '@/api/types'
import { useIsMobile } from '@/hooks/useIsMobile'
import { cvProfileOptions } from '@/utils/format'
export interface AttractionFormValues {
@@ -74,6 +75,8 @@ export function AttractionForm({
form: FormInstance<AttractionFormValues>
initialValues?: AttractionFormInitialValues
}) {
const isMobile = useIsMobile()
return (
<Form
form={form}
@@ -111,11 +114,16 @@ export function AttractionForm({
<Form.Item name="address" label="Адрес">
<Input maxLength={255} />
</Form.Item>
<Space size="large" style={{ display: 'flex' }} align="start">
<Space
size="large"
style={{ display: 'flex' }}
align="start"
direction={isMobile ? 'vertical' : 'horizontal'}
>
<Form.Item
name="latitude"
label="Широта"
style={{ width: 220 }}
style={{ width: isMobile ? '100%' : 220 }}
rules={[
{
validator: (_, value: number | null | undefined) =>
@@ -130,7 +138,7 @@ export function AttractionForm({
<Form.Item
name="longitude"
label="Долгота"
style={{ width: 220 }}
style={{ width: isMobile ? '100%' : 220 }}
rules={[
{
validator: (_, value: number | null | undefined) =>
@@ -148,22 +156,25 @@ export function AttractionForm({
{(fields, { add, remove }) => (
<>
{fields.map((field) => (
<Space key={field.key} align="baseline" style={{ display: 'flex', marginBottom: 4 }}>
<div
key={field.key}
style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 4 }}
>
<Form.Item
name={field.name}
rules={[{ required: true, message: 'Пустой факт — удалите строку' }]}
noStyle
>
<Input placeholder="Текст факта" maxLength={500} style={{ width: 440 }} />
<Input placeholder="Текст факта" maxLength={500} style={{ flex: 1, minWidth: 0 }} />
</Form.Item>
<MinusCircleOutlined onClick={() => remove(field.name)} />
</Space>
</div>
))}
<Button
type="dashed"
icon={<PlusOutlined />}
onClick={() => add()}
style={{ width: 472 }}
style={{ width: '100%', maxWidth: 472 }}
>
Добавить факт
</Button>