🚩 (flags) create form submitter endpoint
This commit is contained in:
8
features/auth/models/submitRegisterForm.ts
Normal file
8
features/auth/models/submitRegisterForm.ts
Normal file
@ -0,0 +1,8 @@
|
||||
"use server";
|
||||
|
||||
import { RegisterInputs } from "../ui/components/ProvisionInput";
|
||||
|
||||
export const submitRegisterForm = async (data: RegisterInputs) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
return data;
|
||||
};
|
||||
@ -3,12 +3,13 @@
|
||||
import React, { useState } from "react";
|
||||
import { Button, Form, Input } from "@heroui/react";
|
||||
import { SubmitHandler, useForm } from "react-hook-form";
|
||||
import { submitRegisterForm } from "../../models/submitRegisterForm";
|
||||
|
||||
type Props = {
|
||||
fullname: string;
|
||||
};
|
||||
|
||||
type Inputs = {
|
||||
export type RegisterInputs = {
|
||||
fullname: string;
|
||||
email: string;
|
||||
password: string;
|
||||
@ -16,13 +17,14 @@ type Inputs = {
|
||||
};
|
||||
|
||||
const ProvisionInput = ({ fullname }: Props) => {
|
||||
const { register, handleSubmit, setValue } = useForm<Inputs>();
|
||||
const { register, handleSubmit, setValue } = useForm<RegisterInputs>();
|
||||
setValue("fullname", fullname);
|
||||
|
||||
const [submitStatus, setSubmitStatus] = useState(false);
|
||||
const onSubmit: SubmitHandler<Inputs> = (data) => {
|
||||
setSubmitStatus(true);
|
||||
console.log(data);
|
||||
const onSubmit: SubmitHandler<RegisterInputs> = async (data) => {
|
||||
console.log("Mensubmit");
|
||||
const returnData = await submitRegisterForm(data);
|
||||
console.log(returnData);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user