import { runtime } from "@/runtime"
import { Todos } from "@/todo/Todos"
import { TodosState } from "@/todo/TodosState.service"
import { createFileRoute } from "@tanstack/react-router"
import { Effect } from "effect"
import { Component, Hook } from "effect-fc"


export const Route = createFileRoute("/")({
    component: Component.make(function* Index() {
        return yield* Effect.provide(
            Component.use(Todos, Todos => <Todos />),
            yield* Hook.useMemoLayer(TodosState.Default("todos")),
        )
    }, {
        finalizerExecutionMode: "fork"
    }).pipe(
        Component.withRuntime(runtime.context),
    )
})
