import { Handlers, PageProps } from '$fresh/server.ts'
import { Task } from '@homeman/models.ts'
import { Routine } from '@homeman/islands/Routine.tsx'
// import { db, kv, Todo, UserWithTodos } from '@homeman/models.ts'

interface Data {
	tasks: Task[]
}

export const handler: Handlers = {
	GET(_req, ctx) {
		const tasks: Task[] = Array.from([])
		console.log(tasks)

		Array.prototype.forEach.apply([
			['🥣', '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'],
		], [([emoji, text]) => {
			tasks.push({
				emoji,
				text,
				doneAt: null,
				phase: 'Morning',
			})
		}])

		return ctx.render({ tasks })
	},
}

export default function Page(props: PageProps<Data>) {
	console.log(props)
	return <Routine tasks={props.data.tasks} />
}

/*
🌄 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

🌤️ AFTERNOON
🥓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

*/
