functioning apk with reworked calendar
This commit is contained in:
@@ -15,7 +15,7 @@ import { AssigneeSelector } from '@/components/AssigneeSelector';
|
||||
import { useForm, FormProvider, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { z } from 'zod';
|
||||
import { useDatabase, useCategories } from '@/hooks/useDatabase';
|
||||
import { useDatabase } from '@/hooks/useDatabase';
|
||||
import { database, collections } from '@/database';
|
||||
import { TaskFormData } from '@/types';
|
||||
import { useSettings } from '@/theme';
|
||||
@@ -25,7 +25,7 @@ import { useFriends } from '@/hooks/useFriends';
|
||||
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().min(1, 'Category is required'),
|
||||
categoryId: z.string().optional(),
|
||||
priority: z.enum(['none', 'low', 'medium', 'high', 'critical']),
|
||||
dueDate: z.date().nullable().optional(),
|
||||
dueTime: z.string().optional(),
|
||||
@@ -42,13 +42,12 @@ const taskSchema = z.object({
|
||||
|
||||
export default function AddTaskScreen() {
|
||||
const { isReady } = useDatabase();
|
||||
const categories = useCategories();
|
||||
const { defaultCategoryId } = useSettings();
|
||||
const router = useRouter();
|
||||
const { theme } = useSettings();
|
||||
const { date: dateParam } = useLocalSearchParams<{ date?: string }>();
|
||||
const { friends } = useFriends();
|
||||
const initialCategory = defaultCategoryId || categories[0]?.id || '';
|
||||
const initialCategory = defaultCategoryId || '';
|
||||
const initialDate = useMemo(() => {
|
||||
if (!dateParam) return null;
|
||||
const parsed = new Date(Array.isArray(dateParam) ? dateParam[0] : dateParam);
|
||||
@@ -108,6 +107,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 || '';
|
||||
|
||||
let createdTask: any = null;
|
||||
|
||||
@@ -115,7 +115,7 @@ export default function AddTaskScreen() {
|
||||
const task = await collections.tasks.create((t) => {
|
||||
t.title = data.title.trim();
|
||||
t.description = data.description || '';
|
||||
t.categoryId = data.categoryId;
|
||||
t.categoryId = resolvedCategoryId;
|
||||
t.priority = data.priority;
|
||||
t.completed = false;
|
||||
t.dueDate = dueDateTimestamp;
|
||||
|
||||
Reference in New Issue
Block a user