homeman-deno/routes/routine.tsx

24 lines
614 B
TypeScript
Raw Normal View History

import { Handlers, PageProps } from '$fresh/server.ts'
2024-01-21 14:23:45 -06:00
import { Task } from '@homeman/models.ts'
import { Routine } from '@homeman/islands/Routine.tsx'
2024-01-21 18:11:25 -06:00
import { kv } from '@homeman/db.ts'
// import { db, kv, Todo, UserWithTodos } from '@homeman/models.ts'
interface Data {
tasks: Task[]
}
export const handler: Handlers = {
2024-01-21 14:02:10 -06:00
async GET(_req, ctx) {
2024-01-21 18:11:25 -06:00
const tasks = (await Array.fromAsync(kv.list({ prefix: ['task'] }))).map(
(r) => r.value
)
console.log({ tasks })
2024-01-21 14:23:45 -06:00
return ctx.render({ tasks })
},
}
export default function Page(props: PageProps<Data>) {
2024-01-21 14:23:45 -06:00
return <Routine tasks={props.data.tasks} />
}