Update monthly order page: added 2 new data inputs

This commit is contained in:
romanskijdev 2026-11-13 17:23:53 +03:00
parent 0b25a1d932
commit 6b5f3f9496
2 changed files with 41 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { useEffect } from 'react'
import { Box, Button, Group, NumberInput, Paper, Stack, Title, Text } from '@mantine/core'
import { Box, Button, Group, NumberInput, Paper, Stack, Title, Text, Select, Textarea } from '@mantine/core'
import { DateTimePicker } from '@mantine/dates'
import { useForm } from '@mantine/form'
import { useMonthlyOrderSettings, useSaveMonthlyOrderSettings } from '@/features/monthlyOrders/hooks/useMonthlyOrderSettings'
@ -9,6 +9,8 @@ import { IconDeviceFloppy } from '@tabler/icons-react'
interface SettingsFormValues {
deadline_date: Date | null
assembly_time_days: number
market_stage: string | null
market_stage_comment: string
}
export default function MonthlyOrdersSettingsPage() {
@ -19,6 +21,8 @@ export default function MonthlyOrdersSettingsPage() {
initialValues: {
deadline_date: null,
assembly_time_days: 3,
market_stage: null,
market_stage_comment: '',
},
validate: {
deadline_date: (value) => (!value ? 'Укажите граничную дату и время' : null),
@ -31,6 +35,8 @@ export default function MonthlyOrdersSettingsPage() {
form.setValues({
deadline_date: currentSettings.deadline_date ? new Date(currentSettings.deadline_date) : null,
assembly_time_days: currentSettings.assembly_time_days || 3,
market_stage: currentSettings.market_stage || null,
market_stage_comment: currentSettings.market_stage_comment || '',
})
}
}, [currentSettings])
@ -39,6 +45,8 @@ export default function MonthlyOrdersSettingsPage() {
saveSettings({
deadline_date: values.deadline_date ? dayjs(values.deadline_date).format() : null,
assembly_time_days: values.assembly_time_days,
market_stage: values.market_stage,
market_stage_comment: values.market_stage_comment,
})
}
@ -56,14 +64,42 @@ export default function MonthlyOrdersSettingsPage() {
</Text>
<DateTimePicker
label="Граничная дата и время (Дедлайн)"
description="После этого времени менеджеры не смогут редактировать заказы, и они отправятся на согласование."
label="Крайняя дата и время"
description="После этого времени менеджеры не смогут редактировать заказы на месяц и они отправятся на согласование."
placeholder="Выберите дату и время"
valueFormat="DD.MM.YYYY HH:mm"
withSeconds={false}
{...form.getInputProps('deadline_date')}
/>
<NumberInput
label="Срок сборки заказа (в днях)"
description="Время, необходимое на комплектацию товаров"
placeholder="Например: 3"
min={0}
{...form.getInputProps('assembly_time_days')}
/>
<Select
label="Стадия рынка"
placeholder="Выберите текущую стадию"
data={[
{ value: 'растущий', label: 'Растущий' },
{ value: 'падающий', label: 'Падающий' },
{ value: 'стоячий', label: 'Стоячий' },
]}
clearable
{...form.getInputProps('market_stage')}
/>
<Textarea
label="Комментарий к стадии рынка"
placeholder="Опишите подробности текущей ситуации на рынке"
minRows={3}
autosize
{...form.getInputProps('market_stage_comment')}
/>
<Group justify="flex-end" mt="md">
<Button
type="submit"

View File

@ -354,6 +354,8 @@ export interface MonthlyOrderSetting {
year?: number
deadline_date: string | null
assembly_time_days: number
market_stage?: string | null
market_stage_comment?: string | null
created_at?: string
updated_at?: string
}