2024-01-21 11:31:15 -06:00
|
|
|
import { Handlers, PageProps } from '$fresh/server.ts'
|
2024-01-21 14:23:45 -06:00
|
|
|
import { Task } from '@homeman/models.ts'
|
2024-01-21 11:31:15 -06:00
|
|
|
import { Routine } from '@homeman/islands/Routine.tsx'
|
2024-01-21 18:11:25 -06:00
|
|
|
import { kv } from '@homeman/db.ts'
|
2024-01-21 11:31:15 -06:00
|
|
|
// 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 })
|
2024-01-21 11:31:15 -06:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Page(props: PageProps<Data>) {
|
2024-01-21 14:23:45 -06:00
|
|
|
return <Routine tasks={props.data.tasks} />
|
2024-01-21 11:31:15 -06:00
|
|
|
}
|