diff --git a/server.ts b/server.ts index 3c0a5aa..3520894 100644 --- a/server.ts +++ b/server.ts @@ -23,20 +23,30 @@ const CONFIG = { TEST: { pbCollection: 'Job_Info_TestEnv', excelTable: 'Test_Table', + plannerGroupId: 'e45f2188-dc65-42d6-b7b0-d0a873e07472', + plannerPlanId: '87nMEU5OqUqro1xLjY58-2UAD4uj', + plannerBucketId: '9VuH0OQEa0GQsCHtPgUCFmUACHVF', description: '๐Ÿงช TEST ENVIRONMENT' }, PROD: { pbCollection: process.env.PB_COLLECTION || 'Job_Info_Prod', excelTable: process.env.EXCEL_TABLE_NAME || 'Job_List', + plannerGroupId: process.env.PLANNER_GROUP_ID || 'e45f2188-dc65-42d6-b7b0-d0a873e07472', + plannerPlanId: process.env.PLANNER_PLAN_ID || '87nMEU5OqUqro1xLjY58-2UAD4uj', + plannerBucketId: process.env.PLANNER_BUCKET_ID || '9VuH0OQEa0GQsCHtPgUCFmUACHVF', description: '๐Ÿš€ PRODUCTION ENVIRONMENT' } }; const activeConfig = MODE === 'PROD' ? CONFIG.PROD : CONFIG.TEST; console.log('\n' + '*'.repeat(60)); -console.log(' RUNNING IN: ' + activeConfig.description); -console.log(' PocketBase: ' + activeConfig.pbCollection); -console.log(' Excel Table: ' + activeConfig.excelTable); + console.log(' RUNNING IN: ' + activeConfig.description); + console.log(' PocketBase: ' + activeConfig.pbCollection); + console.log(' Excel Table: ' + activeConfig.excelTable); + console.log(' Planner Plan: ' + activeConfig.plannerPlanId); + console.log(' Planner Bucket: ' + activeConfig.plannerBucketId); + console.log(' Planner Plan: ' + activeConfig.plannerPlanId); + console.log(' Planner Bucket: ' + activeConfig.plannerBucketId); console.log('*'.repeat(60) + '\n'); const app = new Hono(); @@ -436,27 +446,31 @@ async function createPlannerTask({ // Task title: "Disposition New Job Folder for [Job_Number] [Job_Full_Name]" const title = `Disposition New Job Folder for ${jobNumber} ${jobFullName}`; - // Create the Planner task - const groupId = process.env.PLANNER_GROUP_ID; - const planId = process.env.PLANNER_PLAN_ID; - const bucketId = process.env.PLANNER_BUCKET_ID; + // Create the Planner task + const groupId = activeConfig.plannerGroupId; + const planId = activeConfig.plannerPlanId; + const bucketId = activeConfig.plannerBucketId; - if (!groupId || !planId || !bucketId) { - throw new Error('Missing Planner configuration: PLANNER_GROUP_ID, PLANNER_PLAN_ID, or PLANNER_BUCKET_ID'); - } + if (!groupId || !planId || !bucketId) { + throw new Error('Missing Planner configuration in activeConfig'); + } const newTask = await client.api('/planner/tasks').post({ - planId, - bucketId, - title, - assignments: { - [assigneeId]: { - '@odata.type': 'microsoft.graph.plannerAssignment', - orderHint: ' !', + planId, + bucketId, + title, + assignments: { + [assigneeId]: { + '@odata.type': 'microsoft.graph.plannerAssignment', + orderHint: ' !', + }, }, - }, - ...(dueDateObj ? { dueDateTime: dueDateObj } : {}), - }); + ...(dueDateObj ? { dueDateTime: dueDateObj } : {}), + }); + + console.log(`โœ“ Planner task created in Plan ID: ${planId}`); + + console.log(`โœ“ Planner task created in Plan ID: ${planId}`); // Set the Notes/Description via task details (match the working test script) const taskDetails = await client.api(`/planner/tasks/${newTask.id}/details`).get();