homeman-deno/routes/routine.tsx

73 lines
2.2 KiB
TypeScript
Raw Normal View History

import { Handlers, PageProps } from '$fresh/server.ts'
2024-01-21 14:02:10 -06:00
import { DailyPhase, DoneTask, Task } from '@homeman/models.ts'
import { Routine } from '@homeman/islands/Routine.tsx'
2024-01-21 14:02:10 -06:00
import { db } from '@homeman/db.ts'
// import { db, kv, Todo, UserWithTodos } from '@homeman/models.ts'
interface Data {
tasks: Task[]
2024-01-21 14:02:10 -06:00
done: DoneTask[]
}
export const handler: Handlers = {
2024-01-21 14:02:10 -06:00
async GET(_req, ctx) {
const tasks: Task[] = Array.from([])
console.log(tasks)
2024-01-21 14:02:10 -06:00
const hardcoded: Record<DailyPhase, [string, string][]> = {
'Morning': [
['🥣', 'Breakfast'],
['🪥', 'Brush teeth'],
['👕', 'Get dressed'],
['🙏', 'Ask and thank Jesus'],
['✝️', 'Bible story or devotional'],
['📚', 'School: with Mrs. Emily or Mama'],
['🎨', 'Create time: 🧶craft ✏️ draw 🧑🏼‍🎨 paint'],
['🏗️', ' Build time: 🧱legos 🚂train tracks 🏎magna tiles'],
['👯', 'Friend time: playdate or neighbor time'],
['🚗', 'Outing: 📚library 🌳park 🥑groceries ☕ coffee shop'],
],
'Midday': [
['🥓', 'Lunch'],
['🧹', 'Tidy time'],
['🤫', 'Quiet time'],
['🏃', 'BIG energy time: 🚲bike 🥁 drums 🤸 silly play'],
['👯', 'Friend time: playdate or neighbor time'],
['🚗', 'Outing: 📚library 🌳park 🥑groceries'],
],
'Evening': [
['🍽️', 'Dinner'],
['🚗', 'Outing'],
['👪', 'Family time: 🃏games 🕺dance party 🤸silly play 🏋workout'],
],
'Bedtime': [
['🪥', 'Brush teeth'],
['🛁', 'Take bath'],
['👕', 'Put on pajamas'],
['🙏', 'Ask and thank Jesus'],
['✝️', 'Bible story or devotional'],
['📕', 'Read a story'],
['❤', 'Emotions check in: 😭 😡 😂 😟 😣 😀 ☹️ 😰 😁'],
],
'Night': [
['👨‍⚖️', 'Sleep!'],
],
}
Object.entries(hardcoded).forEach(([tphase, phaseTasks]) => {
const phase = tphase as DailyPhase
for (const [emoji, id] of phaseTasks) {
tasks.push({ phase, emoji, id, doneAt: null })
}
})
2024-01-21 14:02:10 -06:00
const done = await db.doneTasks.findMany({})
console.log({ done })
return ctx.render({ tasks, done })
},
}
export default function Page(props: PageProps<Data>) {
2024-01-21 14:02:10 -06:00
return <Routine tasks={props.data.tasks} done={props.data.done} />
}