@@ -16,7 +16,7 @@ type Invoice = {
1616type Data = {
1717 authed : boolean ;
1818 error ?: string ;
19- counts ?: { invoices : number ; customers : number ; templates : number } ;
19+ counts ?: { invoices : number ; customers : number } ;
2020 money ?: {
2121 billed : number ;
2222 paid : number ;
@@ -25,6 +25,7 @@ type Data = {
2525 } ;
2626 status ?: { draft : number ; sent : number ; paid : number ; overdue : number } ;
2727 recent ?: Invoice [ ] ;
28+ version ?: string ;
2829} ;
2930
3031export const handler : Handlers < Data > = {
@@ -39,10 +40,9 @@ export const handler: Handlers<Data> = {
3940 } ) ;
4041 }
4142 try {
42- const [ invoices , customers , templates ] = await Promise . all ( [
43+ const [ invoices , customers ] = await Promise . all ( [
4344 backendGet ( "/api/v1/invoices" , auth ) as Promise < Invoice [ ] > ,
4445 backendGet ( "/api/v1/customers" , auth ) as Promise < unknown [ ] > ,
45- backendGet ( "/api/v1/templates" , auth ) as Promise < unknown [ ] > ,
4646 ] ) ;
4747
4848 const currency = ( invoices [ 0 ] ?. currency as string ) || "USD" ;
@@ -69,16 +69,28 @@ export const handler: Handlers<Data> = {
6969 )
7070 . slice ( 0 , 5 ) ;
7171
72+ // Read version from VERSION file at project root
73+ let version = 'unknown' ;
74+ const possiblePaths = [ '/app/VERSION' , Deno . cwd ( ) + '/../VERSION' , Deno . cwd ( ) + '/VERSION' ] ;
75+ for ( const path of possiblePaths ) {
76+ try {
77+ version = await Deno . readTextFile ( path ) . then ( v => v . trim ( ) ) ;
78+ break ;
79+ } catch {
80+ // Ignore and try next path
81+ }
82+ }
83+
7284 return ctx . render ( {
7385 authed : true ,
7486 counts : {
7587 invoices : invoices . length ,
7688 customers : customers . length ,
77- templates : templates . length ,
7889 } ,
7990 money : { billed, paid, outstanding, currency } ,
8091 status,
8192 recent,
93+ version,
8294 } ) ;
8395 } catch ( e ) {
8496 return ctx . render ( { authed : true , error : String ( e ) } ) ;
@@ -131,19 +143,17 @@ export default function Dashboard(props: PageProps<Data>) {
131143 </ div >
132144 < div class = "card bg-base-100 border border-base-300 rounded-box" >
133145 < div class = "card-body" >
134- < div class = "text-sm opacity-70" > Templates </ div >
146+ < div class = "text-sm opacity-70" > Open Invoices </ div >
135147 < div class = "text-3xl font-extrabold" >
136- { props . data . counts . templates }
148+ { ( props . data . status ?. sent || 0 ) +
149+ ( props . data . status ?. overdue || 0 ) }
137150 </ div >
138151 </ div >
139152 </ div >
140153 < div class = "card bg-base-100 border border-base-300 rounded-box" >
141154 < div class = "card-body" >
142- < div class = "text-sm opacity-70" > Open Invoices</ div >
143- < div class = "text-3xl font-extrabold" >
144- { ( props . data . status ?. sent || 0 ) +
145- ( props . data . status ?. overdue || 0 ) }
146- </ div >
155+ < div class = "text-sm opacity-70" > Version</ div >
156+ < div class = "text-3xl font-extrabold" > { props . data . version } </ div >
147157 </ div >
148158 </ div >
149159 </ div >
0 commit comments