Set up API spec and basic components
This commit is contained in:
parent
2adecd13f7
commit
61bd31eb7e
20 changed files with 353 additions and 26 deletions
24
frontend/src/components/Stats/Stats.module.scss
Normal file
24
frontend/src/components/Stats/Stats.module.scss
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
.wrapper {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
|
||||
& > div {
|
||||
text-align: center;
|
||||
padding: 0 6px;
|
||||
min-width: 160px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.number {
|
||||
display: block;
|
||||
font-weight: 900;
|
||||
color: var(--secondary);
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
}
|
||||
33
frontend/src/components/Stats/Stats.tsx
Normal file
33
frontend/src/components/Stats/Stats.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { API_BASE, StatsResponse } from '/src/config/api'
|
||||
import { useTranslation } from '/src/i18n/server'
|
||||
|
||||
import styles from './Stats.module.scss'
|
||||
|
||||
const getStats = async () => {
|
||||
const res = await fetch(new URL('/stats', API_BASE))
|
||||
.catch(console.warn)
|
||||
if (!res?.ok) return
|
||||
return StatsResponse.parse(await res.json())
|
||||
}
|
||||
|
||||
const Stats = async () => {
|
||||
const stats = await getStats()
|
||||
const { t } = await useTranslation('home')
|
||||
|
||||
return <div className={styles.wrapper}>
|
||||
<div>
|
||||
<span className={styles.number}>
|
||||
{new Intl.NumberFormat().format(stats?.event_count || 17000)}{!stats?.event_count && '+'}
|
||||
</span>
|
||||
<span className={styles.label}>{t('about.events')}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className={styles.number}>
|
||||
{new Intl.NumberFormat().format(stats?.person_count || 65000)}{!stats?.person_count && '+'}
|
||||
</span>
|
||||
<span className={styles.label}>{t('about.availabilities')}</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
export default Stats
|
||||
Loading…
Add table
Add a link
Reference in a new issue