Fix
All checks were successful
Lint / lint (push) Successful in 41s

This commit is contained in:
Julien Valverdé
2025-08-28 04:42:23 +02:00
parent f6e69a05fd
commit 450d11cc3e
2 changed files with 38 additions and 24 deletions

View File

@@ -6,22 +6,22 @@ import { Component, Form } from "effect-fc"
import { useContext, useFork } from "effect-fc/hooks"
const LoginFormSchema = Schema.Struct({
const RegisterFormSchema = Schema.Struct({
email: Schema.String,
password: Schema.String.pipe(Schema.minLength(3)),
})
class LoginForm extends Effect.Service<LoginForm>()("LoginForm", {
class RegisterForm extends Effect.Service<RegisterForm>()("RegisterForm", {
scoped: Form.make({
schema: LoginFormSchema,
initialValue: { email: "", password: "xxx" },
schema: RegisterFormSchema,
initialValue: { email: "", password: "" },
})
}) {}
class LoginFormComponent extends Component.makeUntraced(function* LoginFormComponent() {
const form = yield* LoginForm
const emailInput = yield* form.useInput(["email"])
const passwordInput = yield* form.useInput(["password"])
class RegisterPage extends Component.makeUntraced(function* RegisterPage() {
const form = yield* RegisterForm
const emailInput = yield* form.useInput({ path: ["email"], defaultValue: "" })
const passwordInput = yield* form.useInput({ path: ["password"], defaultValue: "" })
yield* useFork(() => Stream.runForEach(form.latestValueSubscribable.changes, Console.log), [])
@@ -63,15 +63,15 @@ class LoginFormComponent extends Component.makeUntraced(function* LoginFormCompo
}) {}
const FormRoute = Component.makeUntraced(function* FormRoute() {
const context = yield* useContext(LoginForm.Default)
const LoginFormComponentFC = yield* Effect.provide(LoginFormComponent, context)
const RegisterRoute = Component.makeUntraced(function* RegisterRoute() {
const context = yield* useContext(RegisterForm.Default)
const RegisterRouteFC = yield* Effect.provide(RegisterPage, context)
return <LoginFormComponentFC />
return <RegisterRouteFC />
}).pipe(
Component.withRuntime(runtime.context)
)
export const Route = createFileRoute("/form")({
component: FormRoute
component: RegisterRoute
})