Updated the task view and backend to handle more like a routine
This commit is contained in:
@@ -222,14 +222,16 @@ export async function getUpcomingTasks() {
|
||||
* Create a new task.
|
||||
* @param {number} userId
|
||||
* @param {string} title
|
||||
* @param {number} dueDate Unix timestamp in seconds
|
||||
* @returns {Promise<{id: number, user_id: number, title: string, due_date: number, completed: boolean}>}
|
||||
* @param {number} dueDate Unix timestamp in seconds (used for non-recurrent tasks)
|
||||
* @param {number} period 0=Morning, 1=Afternoon, 2=Evening
|
||||
* @param {number} recurrence 0=None, 1-7=Day of week (1=Mon)
|
||||
* @returns {Promise<{id: number, user_id: number, title: string, due_date: number, period: number, recurrence: number, completed: boolean}>}
|
||||
*/
|
||||
export async function addTask(userId, title, dueDate) {
|
||||
export async function addTask(userId, title, dueDate, period = 0, recurrence = 0) {
|
||||
const res = await trackedFetch(`${API_BASE}/api/tasks`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: userId, title, due_date: dueDate })
|
||||
body: JSON.stringify({ user_id: userId, title, due_date: dueDate, period, recurrence })
|
||||
});
|
||||
if (!res.ok) {
|
||||
const errorText = await res.text();
|
||||
@@ -241,7 +243,7 @@ export async function addTask(userId, title, dueDate) {
|
||||
/**
|
||||
* Update a task (partial update — only include fields you want to change).
|
||||
* @param {number} id
|
||||
* @param {Object} fields - { title?: string, due_date?: number, completed?: boolean }
|
||||
* @param {Object} fields - { title?: string, due_date?: number, period?: number, recurrence?: number, completed?: boolean }
|
||||
* @returns {Promise<{status: string}>}
|
||||
*/
|
||||
export async function updateTask(id, fields) {
|
||||
|
||||
Reference in New Issue
Block a user