@@ -1,8 +1,8 @@
|
||||
import { Button, Container, Flex } from "@radix-ui/themes"
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
import { Effect, ParseResult, Schema } from "effect"
|
||||
import { Component, Form } from "effect-fc"
|
||||
import { useContext, useSubscribables } from "effect-fc/Hooks"
|
||||
import { Component, Form, Hooks } from "effect-fc"
|
||||
import { useSubscribables } from "effect-fc/Hooks"
|
||||
import { TextFieldFormInput } from "@/lib/form/TextFieldFormInput"
|
||||
import { runtime } from "@/runtime"
|
||||
|
||||
@@ -29,7 +29,7 @@ class RegisterForm extends Effect.Service<RegisterForm>()("RegisterForm", {
|
||||
Schema.typeSchema(RegisterFormSchema),
|
||||
{
|
||||
decode: v => Effect.andThen(Effect.sleep("500 millis"), ParseResult.succeed(v)),
|
||||
encode: v => Effect.andThen(Effect.sleep("500 millis"), ParseResult.succeed(v)),
|
||||
encode: ParseResult.succeed,
|
||||
},
|
||||
),
|
||||
initialEncodedValue: { email: "", password: "" },
|
||||
@@ -48,7 +48,7 @@ class RegisterPage extends Component.makeUntraced("RegisterPage")(function*() {
|
||||
const TextFieldFormInputFC = yield* TextFieldFormInput
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Container width="300">
|
||||
<form onSubmit={e => {
|
||||
e.preventDefault()
|
||||
void submit()
|
||||
@@ -72,15 +72,15 @@ class RegisterPage extends Component.makeUntraced("RegisterPage")(function*() {
|
||||
}) {}
|
||||
|
||||
|
||||
const RegisterRoute = Component.makeUntraced(function* RegisterRoute() {
|
||||
const context = yield* useContext(RegisterForm.Default, { finalizerExecutionMode: "fork" })
|
||||
const RegisterRouteFC = yield* Effect.provide(RegisterPage, context)
|
||||
|
||||
return <RegisterRouteFC />
|
||||
}).pipe(
|
||||
Component.withRuntime(runtime.context)
|
||||
)
|
||||
|
||||
export const Route = createFileRoute("/form")({
|
||||
component: RegisterRoute
|
||||
component: Component.makeUntraced("RegisterRoute")(function*() {
|
||||
const RegisterRouteFC = yield* Effect.provide(
|
||||
RegisterPage,
|
||||
yield* Hooks.useContext(RegisterForm.Default, { finalizerExecutionMode: "fork" }),
|
||||
)
|
||||
|
||||
return <RegisterRouteFC />
|
||||
}).pipe(
|
||||
Component.withRuntime(runtime.context)
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user