/
Kovalenko
/
TODO
Обзор
Документация
Войти
/
Kovalenko
/
TODO
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
frontend/src/hooks/useTaskForm.ts
44 строки
987 B
Kovalenko1
Done
29 дек 2025, 11:50
29 дек 2025, 11:50
f453b3b
Код
Авторство
О чём код?
import { useState } from 'react'; import type { TaskForm } from '../types'; import type { RepeatMode } from '../types/ui'; import { buildOccurrences } from '../utils/date'; const initialForm: TaskForm = { title: '', description: '', dueDate: '', assignee: '', priority: 3, status: 'New', }; export function useTaskForm() { const [form, setForm] = useState<TaskForm>(initialForm); const [repeatMode, setRepeatMode] = useState<RepeatMode>('none'); const [repeatCount, setRepeatCount] = useState(3); function resetForm() { setForm(initialForm); setRepeatMode('none'); setRepeatCount(3); } function updateForm(changes: Partial<TaskForm>) { setForm((prev) => ({ ...prev, ...changes })); } function getOccurrences() { return buildOccurrences(form.dueDate, repeatMode, repeatCount); } return { form, repeatMode, repeatCount, setRepeatMode, setRepeatCount, updateForm, resetForm, getOccurrences, }; }