mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-30 07:46:04 +00:00
Former-commit-id: 9df4dbc3772273d29024452577f63b8cfa111347 [formerly 29dc4d2e9a85edffbf207e8ee3af21306722c634] [formerly ff49ec6aaef41900de3ac62d321c6af55e17acb5 [formerly 865d23809a689fb95a94210df62ee972fdbf821f]] Former-commit-id: d45f51f4f143edbddbe17c3d8cf1cb03ffc9d220 [formerly 0db73af8405bc86e7bfc8b42ba046b56145a606b] Former-commit-id: 4d40862c144b50a0c513d536d9c4814aceb30613
68 lines
2.7 KiB
TypeScript
68 lines
2.7 KiB
TypeScript
/* eslint-disable @typescript-eslint/indent */
|
|
/* eslint-disable multiline-ternary */
|
|
/* eslint-disable react/jsx-no-undef */
|
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
import { Icon } from '@iconify/react/dist/iconify.js'
|
|
import React from 'react'
|
|
import HoursAndMinutesFromSeconds from './HoursAndMinutesFromSeconds'
|
|
import useFetch from '@hooks/useFetch'
|
|
import APIComponentWithFallback from '@components/APIComponentWithFallback'
|
|
|
|
function CodeTimeStatistics(): React.ReactElement {
|
|
const [stats] = useFetch<Record<string, number>>('code-time/statistics')
|
|
|
|
return (
|
|
<div className="flex w-full flex-col gap-6">
|
|
<h1 className="mb-2 flex items-center gap-2 text-2xl font-semibold">
|
|
<Icon icon="tabler:chart-bar" className="text-3xl" />
|
|
<span className="ml-2">Statistics</span>
|
|
</h1>
|
|
<div className="grid grid-cols-[repeat(auto-fit,minmax(14rem,1fr))] items-center justify-between gap-4">
|
|
<APIComponentWithFallback data={stats}>
|
|
{typeof stats !== 'string' &&
|
|
Object.entries(stats).map(([key, value], index) => (
|
|
<div
|
|
key={key}
|
|
className="flex w-full flex-col items-start gap-2 rounded-lg bg-bg-50 p-6 shadow-[4px_4px_10px_0px_rgba(0,0,0,0.05)] dark:bg-bg-900"
|
|
>
|
|
<div className="flex rounded-lg bg-bg-200/70 p-4 shadow-[4px_4px_10px_0px_rgba(0,0,0,0.05)] dark:bg-bg-800">
|
|
<Icon
|
|
icon={
|
|
{
|
|
'Most time spent': 'tabler:coffee',
|
|
'Total time spent': 'tabler:clock',
|
|
'Average time spent': 'tabler:wave-saw-tool',
|
|
'Longest streak': 'tabler:flame',
|
|
'Current streak': 'tabler:flame'
|
|
}[key]!
|
|
}
|
|
className={`text-3xl ${
|
|
index === 3
|
|
? 'text-orange-300'
|
|
: 'text-bg-500 dark:text-bg-100'
|
|
}`}
|
|
/>
|
|
</div>
|
|
<div className="text-lg text-bg-500">{key}</div>
|
|
<div className="text-4xl font-semibold">
|
|
{index < 3 ? (
|
|
<HoursAndMinutesFromSeconds seconds={value} />
|
|
) : (
|
|
<>
|
|
{value}
|
|
<span className="pl-1 text-3xl font-normal text-bg-500">
|
|
days
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</APIComponentWithFallback>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default CodeTimeStatistics
|