@@ -11,7 +11,7 @@ import { MonthlyRevenueChart } from '@/components/dashboard/MonthlyRevenueChart'
1111import { MostBorrowedBookChart } from '@/components/dashboard/MostBorrowedBookChart'
1212import { MontlyBorrowChart } from '@/components/dashboard/MontlyBorrowChart'
1313import { TopMembershipChart } from '@/components/dashboard/TopMembershipChart'
14- import { getAnalysis } from '@/lib/api/analysis'
14+ import { getAnalysis , getBorrowingHeatmapAnalysis } from '@/lib/api/analysis'
1515import { SITE_NAME } from '@/lib/consts'
1616import type { Metadata } from 'next'
1717import { LibrarySelector } from '@/components/dashboard/LibrarySelector'
@@ -22,6 +22,8 @@ import { format, subMonths, parse, startOfDay, endOfDay } from 'date-fns'
2222import { getListLibraries } from '@/lib/api/library'
2323import { DateRange } from 'react-day-picker'
2424import { cookies } from 'next/headers'
25+ import { Suspense } from 'react'
26+ import { BorrowHeatmapChart } from '@/components/dashboard/BorrowHeatmapChart'
2527
2628export const metadata : Metadata = {
2729 title : `Dashboard · ${ SITE_NAME } ` ,
@@ -65,7 +67,7 @@ export default async function DashboardPage({
6567 redirect ( '?' + sp . toString ( ) , RedirectType . replace )
6668 }
6769
68- const [ res , libsRes ] = await Promise . all ( [
70+ const [ res , libsRes , heatmapRes ] = await Promise . all ( [
6971 getAnalysis ( {
7072 skip,
7173 limit,
@@ -74,6 +76,11 @@ export default async function DashboardPage({
7476 library_id : libID ! ,
7577 } ) ,
7678 getListLibraries ( { limit : 5 } ) ,
79+ getBorrowingHeatmapAnalysis ( {
80+ library_id : libID ! ,
81+ start : startOfDay ( parse ( from , 'dd-MM-yyyy' , new Date ( ) ) ) . toJSON ( ) ,
82+ end : endOfDay ( parse ( to , 'dd-MM-yyyy' , new Date ( ) ) ) . toJSON ( ) ,
83+ } ) ,
7784 ] )
7885
7986 if ( 'error' in res ) {
@@ -144,6 +151,11 @@ export default async function DashboardPage({
144151 < TopMembershipChart data = { res . data . membership } />
145152 < MontlyBorrowChart data = { res . data . borrowing } />
146153 < MonthlyRevenueChart data = { res . data . revenue } />
154+ { 'error' in heatmapRes ? (
155+ < div > { heatmapRes . error } </ div >
156+ ) : (
157+ < BorrowHeatmapChart data = { heatmapRes . data } />
158+ ) }
147159 </ div >
148160 </ div >
149161 )
0 commit comments