@@ -11,17 +11,21 @@ const RegisterSchema = Schema.Struct({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const RegisterRouteComponent = Component.make("RegisterRouteView")(function*() {
|
const RegisterRouteComponent = Component.make("RegisterRouteView")(function*() {
|
||||||
const form = yield* Component.useOnMount(() => MutationForm.service({
|
const [form, emailField, passwordField] = yield* Component.useOnMount(() => Effect.gen(function*() {
|
||||||
|
const form = yield* MutationForm.service({
|
||||||
schema: RegisterSchema,
|
schema: RegisterSchema,
|
||||||
initialEncodedValue: { email: "", password: "" },
|
initialEncodedValue: { email: "", password: "" },
|
||||||
f: ([value]) => Effect.log(`Registered ${value.email}`),
|
f: ([value]) => Effect.log(`Registered ${value.email}`),
|
||||||
|
})
|
||||||
|
|
||||||
|
const emailField = Form.focusObjectOn(form, "email")
|
||||||
|
const passwordField = Form.focusObjectOn(form, "password")
|
||||||
|
|
||||||
|
return [form, emailField, passwordField] as const
|
||||||
}))
|
}))
|
||||||
const emailField = yield* Form.useInput(
|
|
||||||
Form.focusObjectOn(form, "email"),
|
const emailInput = yield* Form.useInput(emailField)
|
||||||
)
|
const passwordInput = yield* Form.useInput(passwordField)
|
||||||
const passwordField = yield* Form.useInput(
|
|
||||||
Form.focusObjectOn(form, "password"),
|
|
||||||
)
|
|
||||||
const [canCommit, isCommitting] = yield* View.useAll([
|
const [canCommit, isCommitting] = yield* View.useAll([
|
||||||
form.canCommit,
|
form.canCommit,
|
||||||
form.isCommitting,
|
form.isCommitting,
|
||||||
@@ -36,13 +40,13 @@ const RegisterRouteComponent = Component.make("RegisterRouteView")(function*() {
|
|||||||
}}>
|
}}>
|
||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
<TextField.Root
|
<TextField.Root
|
||||||
value={emailField.value}
|
value={emailInput.value}
|
||||||
onChange={event => emailField.setValue(event.currentTarget.value)}
|
onChange={event => emailInput.setValue(event.currentTarget.value)}
|
||||||
placeholder="Email"
|
placeholder="Email"
|
||||||
/>
|
/>
|
||||||
<TextField.Root
|
<TextField.Root
|
||||||
value={passwordField.value}
|
value={passwordInput.value}
|
||||||
onChange={event => passwordField.setValue(event.currentTarget.value)}
|
onChange={event => passwordInput.setValue(event.currentTarget.value)}
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
type="password"
|
type="password"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user