123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import { ErrorMessage, Field, Form, Formik } from "formik";
- import * as Yup from "yup";
- import Link from "next/link";
- import AuthIcon from "./authselection/AuthIcon";
- const initialValues = {
- email: "",
- password: "",
- };
-
- const SigninFormSchema = Yup.object().shape({
- email: Yup.string().email("Email is invalid").required("Email is required"),
- password: Yup.string()
- .min(6, "Password must be at least 6 characters")
- .required("Password is required"),
- });
-
- function SigninForm() {
- return (
- <>
- <Formik
- initialValues={initialValues}
- validationSchema={SigninFormSchema}
- onSubmit={(fields) => {
- alert(
- "SUCCESS!! :-)\n\n" + JSON.stringify(fields, null, 4)
- );
- }}
- >
- {({ errors, status, touched }) => (
- <Form>
- <div className="row">
-
- <div className="col-12 mb-3 d-flex justify-content-around">
- <input type="radio" id="html" className="d-none" name="fav_language" value="HTML" />
- <label className="auth-icon-label" for="html">
- <AuthIcon isActive={true} title="Consumer" icon="user" />
- </label>
- <input className="d-none" type="radio" id="css" name="fav_language" value="CSS" />
- <label className="auth-icon-label" for="css">
- <AuthIcon title="Employee" icon="address-card" />
- </label>
- <input className="d-none" type="radio" id="javascript" name="fav_language" value="JavaScript" />
- <label className="auth-icon-label" for="javascript">
- <AuthIcon title="Plumber" icon="gear" />
- </label>
-
- </div>
-
- <div className="col-12 mb-3">
- <label className="form-label">Email</label>
- <Field
- name="email"
- type="text"
- className={
- "form-control" +
- (errors.email && touched.email
- ? " is-invalid"
- : "")
- }
- />
- <ErrorMessage
- name="email"
- component="div"
- className="invalid-feedback"
- />
- </div>
-
-
-
- <div className="col-12 mb-3">
- <label className="form-label">Password</label>
- <Field
- name="password"
- type="text"
- className={
- "form-control" +
- (errors.password && touched.password
- ? " is-invalid"
- : "")
- }
- />
- <ErrorMessage
- name="password"
- component="div"
- className="invalid-feedback"
- />
- </div>
- <div className="col-6">
- <div className="form-check">
- <Field
- type="checkbox"
- name="acceptTerms"
- className={
- "form-check-input "
- }
- />
- <label
- className="form-check-label"
- >
- Remember me
- </label>
- </div>
- </div>
- <div className="col-6 text-end">
- <Link href="/reset">
- <a>Forgot Password?</a>
- </Link>
- </div>
- </div>
-
- <div className="mt-3 d-grid gap-2">
- <button
- type="submit"
- className="btn btn-primary mr-2"
- >
- Sign In
- </button>
- </div>
- </Form>
- )}
- </Formik>
- </>
- );
- }
- export default SigninForm;
|