This commit is contained in:
2025-12-03 01:24:52 -03:00
parent 3a49b13cb9
commit 38c49ff370
21 changed files with 133 additions and 73 deletions

View File

@@ -1,5 +1,6 @@
import type { Route } from '../+types'
import { useRequest } from 'ahooks'
import { PatternFormat } from 'react-number-format'
import { zodResolver } from '@hookform/resolvers/zod'
import { useState } from 'react'
@@ -31,6 +32,19 @@ export function meta({}: Route.MetaArgs) {
return [{ title: 'Criar conta · EDUSEG®' }]
}
export async function action({ request, context }: Route.ActionArgs) {
const issuerUrl = new URL('/register', context.cloudflare.env.ISSUER_URL)
const body = await request.json()
const r = await fetch(issuerUrl.toString(), {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
console.log(await r.json())
}
export default function Signup({}: Route.ComponentProps) {
const [show, setShow] = useState(false)
const [user, setUser] = useState<User | null>(null)
@@ -38,13 +52,21 @@ export default function Signup({}: Route.ComponentProps) {
resolver: zodResolver(formSchema)
})
const { control, handleSubmit, formState } = form
const { runAsync } = useRequest(
async (user) => {
return await fetch(`/register`, {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
body: JSON.stringify(user)
})
},
{ manual: true }
)
const onSubmit = async (data: Schema) => {
console.log(data)
await runAsync({ ...user, ...data })
}
console.log(user)
return (
<RegisterContext value={{ user, setUser }}>
{user ? (