Skip to content

Commit

Permalink
feat(enter-activation): envia requisição de criação de usuário
Browse files Browse the repository at this point in the history
  • Loading branch information
danicaus committed Aug 25, 2024
1 parent 657636d commit 381f038
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/app/activations/enter/createUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function createUser(formData: Record<string, string>){
console.log('formData', formData)

await fetch('/api/user', {
method: 'POST',
body: JSON.stringify(formData)
})
.then((res) => console.log(res.body))

// redirect('/activations')
}
11 changes: 3 additions & 8 deletions src/app/activations/enter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import React from "react";
import Button from "@/components/Button";
import Input from "@/components/Input";
import {useRouter} from "next/navigation";
import {createUser} from "@/app/activations/enter/createUser";

export default function Enter() {
const [ step, setStep ] = React.useState<number>(0)
const router = useRouter()
const questions = [
{
id: 'email',
Expand Down Expand Up @@ -51,11 +50,7 @@ export default function Enter() {

const handleNext = () => {
setStep((prevStep) => prevStep + 1)
}

const handleSubmit = () => {
console.log(formData)
router.push('/activations')
setValidField(false)
}

return (
Expand Down Expand Up @@ -84,7 +79,7 @@ export default function Enter() {
{step < (questions.length - 1) ? (
<Button text="Próximo" onClick={handleNext} type="button" disabled={!validField}/>
) : (
<Button text="Começar" onClick={handleSubmit} type="button"/>
<Button text="Começar" onClick={() => createUser(formData)} type="button" disabled={!validField} />
)}
</form>
)
Expand Down

0 comments on commit 381f038

Please sign in to comment.