Add detailed logging to updateTask and syncToServer
This commit is contained in:
parent
6ef31132b6
commit
30d8d7022b
@ -456,7 +456,7 @@
|
|||||||
"updatedAt": "2026-02-20T01:52:57.259Z"
|
"updatedAt": "2026-02-20T01:52:57.259Z"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lastUpdated": 1771555515806,
|
"lastUpdated": 1771556223745,
|
||||||
"sprints": [
|
"sprints": [
|
||||||
{
|
{
|
||||||
"name": "Sprint 1",
|
"name": "Sprint 1",
|
||||||
|
|||||||
@ -377,12 +377,20 @@ const defaultTasks: Task[] = [
|
|||||||
|
|
||||||
// Helper to sync to server
|
// Helper to sync to server
|
||||||
async function syncToServer(projects: Project[], tasks: Task[], sprints: Sprint[]) {
|
async function syncToServer(projects: Project[], tasks: Task[], sprints: Sprint[]) {
|
||||||
|
console.log('syncToServer: saving', tasks.length, 'tasks')
|
||||||
|
const t2 = tasks.find(t => t.id === '2')
|
||||||
|
if (t2) console.log('syncToServer: task 2 sprintId:', t2.sprintId)
|
||||||
try {
|
try {
|
||||||
await fetch('/api/tasks', {
|
const res = await fetch('/api/tasks', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ projects, tasks, sprints }),
|
body: JSON.stringify({ projects, tasks, sprints }),
|
||||||
})
|
})
|
||||||
|
if (res.ok) {
|
||||||
|
console.log('syncToServer: saved successfully')
|
||||||
|
} else {
|
||||||
|
console.error('syncToServer: failed with status', res.status)
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to sync to server:', error)
|
console.error('Failed to sync to server:', error)
|
||||||
}
|
}
|
||||||
@ -489,10 +497,13 @@ export const useTaskStore = create<TaskStore>()(
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateTask: (id, updates) => {
|
updateTask: (id, updates) => {
|
||||||
|
console.log('updateTask called:', id, updates)
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const newTasks = state.tasks.map((t) =>
|
const newTasks = state.tasks.map((t) =>
|
||||||
t.id === id ? { ...t, ...updates, updatedAt: new Date().toISOString() } : t
|
t.id === id ? { ...t, ...updates, updatedAt: new Date().toISOString() } : t
|
||||||
)
|
)
|
||||||
|
const updatedTask = newTasks.find(t => t.id === id)
|
||||||
|
console.log('updateTask: updated task:', updatedTask)
|
||||||
syncToServer(state.projects, newTasks, state.sprints)
|
syncToServer(state.projects, newTasks, state.sprints)
|
||||||
return { tasks: newTasks }
|
return { tasks: newTasks }
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user