You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { route } from 'preact-router'
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
import { Problem as ProblemModel } from '../../shared/model'
|
|
import { Header } from '../components/Header'
|
|
|
|
import { Problem } from '../components/Problem'
|
|
import { Select } from '../components/Select'
|
|
import { useResource, useCurrentUser } from '../hooks'
|
|
|
|
export const HomePage = () => {
|
|
const [user] = useCurrentUser()
|
|
const [problems] = useResource<ProblemModel[]>('/api/problems', [])
|
|
|
|
console.log(problems)
|
|
|
|
return (
|
|
<main class="page-home">
|
|
<Header {...{ user }} />
|
|
<div class="board">
|
|
<div class="fill-row board-controls">
|
|
<div class="sort-order">
|
|
<Select
|
|
value="oldest"
|
|
options={{
|
|
'latest': 'Prima più recenti',
|
|
'oldest': 'Prima più antichi',
|
|
'top-solved': 'Prima più risolti',
|
|
'least-solved': 'Prima meno risolti',
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
{problems.map(p => (
|
|
<Problem {...p} />
|
|
))}
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|