feat(app): subtask categories, live refresh on save, nested subtask fixes

This commit is contained in:
2026-08-10 11:41:25 +02:00
parent f3bcd78e49
commit 2ca23e276f
22 changed files with 518 additions and 307 deletions
+11 -8
View File
@@ -17,7 +17,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { useDatabase } from '@/hooks/useDatabase';
import { database, collections } from '@/database';
import { TaskFormData } from '@/types';
import { TaskFormData, tagsToString } from '@/types';
import { useSettings } from '@/theme';
import { scheduleTaskReminder } from '@/services/notifications';
import { useFriends } from '@/hooks/useFriends';
@@ -26,6 +26,7 @@ const taskSchema = z.object({
title: z.string().trim().min(1, 'Task name is required').max(100),
description: z.string().max(1000).optional(),
categoryId: z.string().optional(),
tags: z.array(z.string()).optional(),
priority: z.enum(['none', 'low', 'medium', 'high', 'critical']),
dueDate: z.date().nullable().optional(),
dueTime: z.string().optional(),
@@ -60,6 +61,7 @@ export default function AddTaskScreen() {
title: '',
description: '',
categoryId: initialCategory,
tags: initialCategory ? [initialCategory] : [],
priority: 'none',
dueDate: initialDate,
dueTime: '',
@@ -83,7 +85,7 @@ export default function AddTaskScreen() {
formState: { errors },
} = methods;
const categoryId = watch('categoryId');
const tags = watch('tags') ?? [];
const priority = watch('priority');
const repeat = watch('repeat');
const repeatInterval = watch('repeatInterval') ?? 1;
@@ -94,10 +96,10 @@ export default function AddTaskScreen() {
const assigneeId = watch('assigneeId');
React.useEffect(() => {
if (!categoryId && initialCategory) {
setValue('categoryId', initialCategory);
if (tags.length === 0 && initialCategory) {
setValue('tags', [initialCategory]);
}
}, [initialCategory, categoryId, setValue]);
}, [initialCategory, tags, setValue]);
const onSubmit = async (data: TaskFormData) => {
if (!isReady) return;
@@ -107,7 +109,7 @@ export default function AddTaskScreen() {
const seriesId = data.repeat !== 'none'
? `series_${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`
: '';
const resolvedCategoryId = data.categoryId || '';
const resolvedCategoryId = (data.tags && data.tags[0]) || '';
let createdTask: any = null;
@@ -116,6 +118,7 @@ export default function AddTaskScreen() {
t.title = data.title.trim();
t.description = data.description || '';
t.categoryId = resolvedCategoryId;
t.tags = tagsToString(data.tags || []);
t.priority = data.priority;
t.completed = false;
t.dueDate = dueDateTimestamp;
@@ -184,8 +187,8 @@ export default function AddTaskScreen() {
keyboardShouldPersistTaps="handled"
>
<CategorySelector
value={categoryId}
onChange={(value) => setValue('categoryId', value)}
value={tags}
onChange={(value) => setValue('tags', value)}
error={errors.categoryId?.message}
/>
<Controller