homeman-deno/routes/index.tsx

43 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-01-05 21:10:38 -06:00
import { Handlers, PageProps } from '$fresh/server.ts'
2024-01-05 13:22:56 -06:00
import { useSignal } from '@preact/signals'
import Counter from '../islands/Counter.tsx'
2024-01-05 21:10:38 -06:00
import { db, Todo, User } from '$models'
2024-01-05 13:22:56 -06:00
interface Data {
2024-01-05 21:10:38 -06:00
users: User[]
unassignedTodos: Todo[]
2024-01-05 13:22:56 -06:00
}
export const handler: Handlers = {
async GET(_req, ctx) {
2024-01-05 21:10:38 -06:00
const users = await db.users.findMany({ include: { assignedTodos: true } })
const unassignedTodos = await db.todos.findMany({
where: { assigneeUserId: null },
})
return ctx.render({ users, unassignedTodos })
2024-01-05 13:22:56 -06:00
},
}
2024-01-05 21:10:38 -06:00
export default function Home(props: PageProps<Data>) {
2024-01-05 13:22:56 -06:00
const count = useSignal(3)
return (
2024-01-05 21:10:38 -06:00
<div class='px-4 py-8 mx-auto bg-emerald-950'>
2024-01-05 13:22:56 -06:00
<div class='max-w-screen-md mx-auto flex flex-col items-center justify-center'>
<img
class='my-6'
src='/logo.svg'
width='128'
height='128'
alt='the Fresh logo: a sliced lemon dripping with juice'
/>
<h1 class='text-4xl font-bold'>Welcome to Fresh</h1>
<p class='my-4'>
Try updating this message in the
<code class='mx-2'>./routes/index.tsx</code> file, and refresh.
</p>
<Counter count={count} />
</div>
</div>
)
}