diff --git a/server.ts b/server.ts index 3520894..d7e5399 100644 --- a/server.ts +++ b/server.ts @@ -472,7 +472,20 @@ async function createPlannerTask({ console.log(`✓ Planner task created in Plan ID: ${planId}`); - // Set the Notes/Description via task details (match the working test script) + // Build checklist object with unique IDs + const checklist: Record = {}; + const checklistItems = ['Create Voxer Chat', 'Create Quickbooks', 'Upload plans']; + checklistItems.forEach((item, index) => { + const itemId = `checklist_${Date.now()}_${index}`; + checklist[itemId] = { + '@odata.type': 'microsoft.graph.plannerChecklistItem', + title: item, + isChecked: false, + orderHint: ` ${index}!`, + }; + }); + + // Set the Notes/Description AND checklist via task details const taskDetails = await client.api(`/planner/tasks/${newTask.id}/details`).get(); const detailsEtag = taskDetails['@odata.etag']; console.log(`[Planner] Task created ${newTask.id}, fetched details ETag: ${detailsEtag}`); @@ -481,8 +494,22 @@ async function createPlannerTask({ .header('If-Match', detailsEtag) .patch({ description: 'Move the new folder to the correct Job Pages folder.', + checklist: checklist, }); - console.log(`[Planner] Successfully patched description`); + console.log(`[Planner] Successfully patched description and added ${checklistItems.length} checklist items`); + + // Add "plum" label (category6) to task + const taskForLabel = await client.api(`/planner/tasks/${newTask.id}`).get(); + const taskEtag = taskForLabel['@odata.etag']; + await client + .api(`/planner/tasks/${newTask.id}`) + .header('If-Match', taskEtag) + .patch({ + appliedCategories: { + category6: true, + }, + }); + console.log(`[Planner] Added plum label to task`); console.log(`✓ Planner task created: "${title}" assigned to ${assigneeName}`); return { success: true, taskId: newTask.id, title };