-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fdb894
commit e3b5dd9
Showing
4 changed files
with
338 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
'use server' | ||
|
||
import { queryAllNotionDatabaseAction } from "./notion" | ||
|
||
export const getCalendarSummary = async ({apiToken, calendarDbId}:any) => { | ||
let filters:any= [ | ||
{ | ||
name: 'Completed', | ||
type: 'checkbox', | ||
condition: 'equals', | ||
value: false | ||
}, | ||
{ | ||
name: 'Not Completed', | ||
type: 'checkbox', | ||
condition: 'equals', | ||
value: false | ||
} | ||
] | ||
let sorts:any = [ | ||
{ | ||
name: 'Created time', | ||
type: 'created_time', | ||
direction: 'descending' | ||
} | ||
] | ||
const calendar = await queryAllNotionDatabaseAction({apiToken, database_id: calendarDbId, filters, sorts}) | ||
const tasks = calendar.results.filter((task:any) => task['Tags'].includes('Task')) | ||
const habits = calendar.results.filter((task:any) => task['Tags'].includes('Habit')) | ||
const payments = calendar.results.filter((task:any) => task['Tags'].includes('Financial')) | ||
return {tasks, habits, payments} | ||
} | ||
|
||
export const getTasksSummary = async ({apiToken, eisenhowerMatrixDbId}:any) => { | ||
let filters:any= [ | ||
{ | ||
name: 'Done', | ||
type: 'checkbox', | ||
condition: 'equals', | ||
value: false | ||
} | ||
] | ||
let sorts:any = [ | ||
{ | ||
name: 'Created time', | ||
type: 'created_time', | ||
direction: 'descending' | ||
} | ||
] | ||
const tasks = await queryAllNotionDatabaseAction({apiToken, database_id: eisenhowerMatrixDbId, filters, sorts}) | ||
const uiTasks = tasks.results.filter((task:any) => task['Urgent']===true && task['Important']===true) | ||
const uniTasks = tasks.results.filter((task:any) => task['Urgent']===true && task['Important']===false) | ||
const nuiTasks= tasks.results.filter((task:any) => task['Urgent']===false && task['Important']===true) | ||
return { | ||
uiTasks, uniTasks, nuiTasks | ||
} | ||
} | ||
|
||
export const getWeeklyPlannerSummary = async ({apiToken, weeklyPlannerDbId}:any) => { | ||
let filters:any= [ | ||
{ | ||
name: 'Completed', | ||
type: 'checkbox', | ||
condition: 'equals', | ||
value: false | ||
} | ||
] | ||
let sorts:any = [ | ||
{ | ||
name: 'Created time', | ||
type: 'created_time', | ||
direction: 'descending' | ||
} | ||
] | ||
const weeklyPlannerTasks = await queryAllNotionDatabaseAction({apiToken, database_id: weeklyPlannerDbId, filters, sorts}) | ||
console.log('Weekly Planner Tasks', weeklyPlannerTasks) | ||
if (weeklyPlannerTasks.results.length === 0){ | ||
return { | ||
weeklyPlannerTasks: [], | ||
totalHoursLeft: 0 | ||
} | ||
} | ||
const totalHoursLeft = weeklyPlannerTasks.results.reduce((acc:any, task:any) => acc + task['Remaining Time (in Hrs)'], 0) | ||
return { | ||
weeklyPlannerTasks, | ||
totalHoursLeft | ||
} | ||
} |
249 changes: 247 additions & 2 deletions
249
apps/dashboard-app/app/(dashboard)/planner/_components/Overview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters