"use client"; import { useState } from "react"; import type { TaskInput } from "@/types/task"; export default function AddTaskForm({ onSubmit, onClose, }: { onSubmit: (task: TaskInput) => Promise | void; onClose: () => void; }) { const [formData, setFormData] = useState({ title: "", description: "", dueDate: "", topic: "", }); const handleChange = ( e: React.ChangeEvent ) => { setFormData({ ...formData, [e.target.name]: e.target.value }); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!formData.topic) { alert("Please select a topic before saving."); return; } await onSubmit(formData); onClose(); }; return (

Add New Task