diff --git a/src/components/tasks/SomedaySection.tsx b/src/components/tasks/SomedaySection.tsx index 58a0dd8..1603906 100644 --- a/src/components/tasks/SomedaySection.tsx +++ b/src/components/tasks/SomedaySection.tsx @@ -1,6 +1,5 @@ import { useState } from 'react'; import { - useCreateTask, useDeleteTaskAll, useRenameSomeday, useScheduleSomeday, @@ -15,40 +14,9 @@ interface Props { export function SomedaySection({ listId }: Props) { const { data: tasks = [], isLoading } = useSomedayTasks(listId); - const createTask = useCreateTask(); - const [newTitle, setNewTitle] = useState(''); - - async function addQuick(e: React.FormEvent) { - e.preventDefault(); - const title = newTitle.trim(); - if (!title) return; - await createTask.mutateAsync({ - title, - list_id: listId, - is_recurring: false, - is_someday: true, - }); - setNewTitle(''); - } return (
-
- setNewTitle(e.target.value)} - placeholder="Add a task (no date) and press Enter…" - className="flex-1 rounded-md border border-slate-700 bg-slate-950 px-3 py-2 text-sm text-slate-100 focus:border-brand-500 focus:outline-none" - /> - -
- {isLoading ? (

Loading…

) : tasks.length === 0 ? ( diff --git a/src/components/tasks/TaskForm.tsx b/src/components/tasks/TaskForm.tsx index bc038d3..9e95ffe 100644 --- a/src/components/tasks/TaskForm.tsx +++ b/src/components/tasks/TaskForm.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { DateTime } from 'luxon'; import { useLists } from '@/hooks/useLists'; import { useCreateTask } from '@/hooks/useTasks'; @@ -7,11 +7,15 @@ import { RecurrenceBuilder, defaultRecurrence } from '@/components/recurrence/Re import { buildRRule, type RecurrenceInput } from '@/lib/recurrence'; interface Props { + /** YYYY-MM-DD to pre-fill the date field. If undefined, defaults to today. + * Pass an empty string to leave the date blank (creates a someday task). */ initialDate?: string; + /** Pre-select a list. Used when opening from the Lists page. */ + initialListId?: string | null; onClose: () => void; } -export function TaskForm({ initialDate, onClose }: Props) { +export function TaskForm({ initialDate, initialListId, onClose }: Props) { const zone = useTimezone(); const { data: lists } = useLists(); const createTask = useCreateTask(); @@ -19,16 +23,27 @@ export function TaskForm({ initialDate, onClose }: Props) { const [title, setTitle] = useState(''); const [notes, setNotes] = useState(''); + // initialDate === '' means "intentionally blank" → someday. + // initialDate === undefined means "use today". const [date, setDate] = useState(initialDate ?? today); const [time, setTime] = useState(''); - const [listId, setListId] = useState(''); + const [listId, setListId] = useState(initialListId ?? ''); const [isRecurring, setIsRecurring] = useState(false); - const [recurrence, setRecurrence] = useState(() => defaultRecurrence(initialDate ?? today)); + const [recurrence, setRecurrence] = useState(() => + defaultRecurrence(initialDate || today), + ); + + // Recurring tasks need an anchor date — auto-off when the date is cleared. + useEffect(() => { + if (!date && isRecurring) setIsRecurring(false); + }, [date, isRecurring]); + + const someday = !date; async function onSubmit(e: React.FormEvent) { e.preventDefault(); let rrule: string | null = null; - if (isRecurring) { + if (isRecurring && date) { const anchor = DateTime.fromISO(date, { zone }); rrule = buildRRule(recurrence, anchor); } @@ -36,10 +51,11 @@ export function TaskForm({ initialDate, onClose }: Props) { title: title.trim(), notes: notes.trim() || null, list_id: listId || null, - date, + date: date || undefined, time: time || null, - is_recurring: isRecurring, + is_recurring: isRecurring && !!date, rrule, + is_someday: someday, }); onClose(); } @@ -63,10 +79,21 @@ export function TaskForm({ initialDate, onClose }: Props) { />
+ {someday && ( +

+ No date — this task lands in its list under Someday{' '} + and won’t appear on Today or the Calendar. +

+ )}