More formatting for annual report

This commit is contained in:
Lim Chee Aun 2024-12-06 14:01:06 +08:00
parent 4e1572f89c
commit 2304b05c08
3 changed files with 47 additions and 10 deletions

4
src/locales/en.po generated
View file

@ -2268,7 +2268,7 @@ msgid "Failed to load history"
msgstr "" msgstr ""
#: src/components/status.jsx:3006 #: src/components/status.jsx:3006
#: src/pages/annual-report.jsx:44 #: src/pages/annual-report.jsx:46
msgid "Loading…" msgid "Loading…"
msgstr "" msgstr ""
@ -2410,7 +2410,7 @@ msgid "Login required."
msgstr "Login required." msgstr "Login required."
#: src/compose.jsx:90 #: src/compose.jsx:90
#: src/pages/annual-report.jsx:136 #: src/pages/annual-report.jsx:165
#: src/pages/http-route.jsx:91 #: src/pages/http-route.jsx:91
#: src/pages/login.jsx:270 #: src/pages/login.jsx:270
msgid "Go home" msgid "Go home"

View file

@ -31,8 +31,13 @@
table { table {
width: 100%; width: 100%;
td, th { td,
th {
vertical-align: top; vertical-align: top;
&.number {
text-align: end;
}
} }
th { th {
@ -44,6 +49,10 @@
tr > * { tr > * {
border-top: 1px dashed var(--outline-color); border-top: 1px dashed var(--outline-color);
~ * {
padding-inline-start: 1ch;
}
} }
} }
@ -68,10 +77,9 @@
.status { .status {
pointer-events: none; pointer-events: none;
font-size: calc(var(--text-size) * .8); font-size: calc(var(--text-size) * 0.8);
} }
} }
} }
} }
} }

View file

@ -35,6 +35,8 @@ export default function AnnualReport() {
const { accounts, annualReports, statuses } = results || {}; const { accounts, annualReports, statuses } = results || {};
const report = annualReports?.find((report) => report.year == year)?.data; const report = annualReports?.find((report) => report.year == year)?.data;
const datePlaceholder = new Date();
return ( return (
<div id="annual-report-page" class="deck-container" tabIndex="-1"> <div id="annual-report-page" class="deck-container" tabIndex="-1">
<div class="report"> <div class="report">
@ -54,8 +56,16 @@ export default function AnnualReport() {
<table> <table>
<thead> <thead>
<tr> <tr>
{Object.keys(value[0]).map((key) => ( {Object.entries(value[0]).map(([key, value]) => (
<th>{key}</th> <th
class={
key !== 'month' && typeof value === 'number'
? 'number'
: ''
}
>
{key}
</th>
))} ))}
</tr> </tr>
</thead> </thead>
@ -63,7 +73,13 @@ export default function AnnualReport() {
{value.map((item) => ( {value.map((item) => (
<tr> <tr>
{Object.entries(item).map(([k, value]) => ( {Object.entries(item).map(([k, value]) => (
<td> <td
class={
k !== 'month' && typeof value === 'number'
? 'number'
: ''
}
>
{value && {value &&
/(accountId)/i.test(k) && /(accountId)/i.test(k) &&
/^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test( /^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test(
@ -75,6 +91,13 @@ export default function AnnualReport() {
)} )}
showAvatar showAvatar
/> />
) : k === 'month' ? (
datePlaceholder.setMonth(value - 1) &&
datePlaceholder.toLocaleString(undefined, {
month: 'long',
})
) : typeof value === 'number' ? (
value.toLocaleString()
) : ( ) : (
value value
)} )}
@ -112,7 +135,13 @@ export default function AnnualReport() {
{Object.entries(value).map(([k, value]) => ( {Object.entries(value).map(([k, value]) => (
<tr> <tr>
<th>{k}</th> <th>{k}</th>
<td>{value}</td> <td
class={
typeof value === 'number' ? 'number' : ''
}
>
{value}
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>