@@ -60,24 +60,61 @@ export default async function DashboardPage({ params }: { params: Promise<{ orgI
6060 } ,
6161 } ) ;
6262
63- const publishedPoliciesScore = await getPublishedPoliciesScore ( organizationId ) ;
64- const doneTasksScore = await getDoneTasks ( organizationId ) ;
65- const peopleScore = await getPeopleScore ( organizationId ) ;
63+ const scores = await getScores ( ) ;
6664
6765 return (
6866 < Overview
6967 frameworksWithControls = { frameworksWithControls }
7068 frameworksWithCompliance = { frameworksWithCompliance }
7169 allFrameworks = { allFrameworks }
7270 organizationId = { organizationId }
73- publishedPoliciesScore = { publishedPoliciesScore }
74- doneTasksScore = { doneTasksScore }
75- peopleScore = { peopleScore }
71+ publishedPoliciesScore = { scores . publishedPoliciesScore }
72+ doneTasksScore = { scores . doneTasksScore }
73+ peopleScore = { scores . peopleScore }
7674 currentMember = { member }
7775 />
7876 ) ;
7977}
8078
79+ const getScores = cache ( async ( ) => {
80+ const session = await auth . api . getSession ( {
81+ headers : await headers ( ) ,
82+ } ) ;
83+
84+ const organizationId = session ?. session . activeOrganizationId ;
85+
86+ if ( ! organizationId ) {
87+ return {
88+ publishedPoliciesScore : {
89+ totalPolicies : 0 ,
90+ publishedPolicies : 0 ,
91+ draftPolicies : [ ] ,
92+ policiesInReview : [ ] ,
93+ unpublishedPolicies : [ ] ,
94+ } ,
95+ doneTasksScore : {
96+ totalTasks : 0 ,
97+ doneTasks : 0 ,
98+ incompleteTasks : [ ] ,
99+ } ,
100+ peopleScore : {
101+ totalMembers : 0 ,
102+ completedMembers : 0 ,
103+ } ,
104+ } ;
105+ }
106+
107+ const publishedPoliciesScore = await getPublishedPoliciesScore ( organizationId ) ;
108+ const doneTasksScore = await getDoneTasks ( organizationId ) ;
109+ const peopleScore = await getPeopleScore ( organizationId ) ;
110+
111+ return {
112+ publishedPoliciesScore,
113+ doneTasksScore,
114+ peopleScore,
115+ } ;
116+ } ) ;
117+
81118const getControlTasks = cache ( async ( ) => {
82119 const session = await auth . api . getSession ( {
83120 headers : await headers ( ) ,
0 commit comments