Login.js
6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React, { useState } from 'react';
import { Formik } from "formik";
import Image from "next/image";
import Link from "next/link";
import { Fragment } from "react";
import { Button, Form } from "react-bootstrap";
import * as Yup from "yup";
import { renderImage } from "../../services/imageHandling";
const Login = (props) => {
    console.log(props.type)
    const loginValidationSchema = Yup.object().shape({
        email: Yup.string()
            .required("Email Id is Required")
            .email("Please Enter An Valid Email Id"),
        password: Yup.string()
            .required("Password is Required")
    });
    return (
        <Fragment>
            <div className="contaier-fluid login-banner-image">
                <div className="row">
                    <div className="col-11 col-lg-4 login-div">
                        <div className="">
                            <h2>{props.type=="vendor" ? "Vendor Login" : "Login to Experience"}</h2>
                            <div className="form-container">
                                <Formik
                                    initialValues={{
                                        email: "",
                                        password: ""
                                    }}
                                    validationSchema={loginValidationSchema}
                                    // enableReinitialize={true}
                                    onSubmit={values => {
                                        console.log("login values",values)
                                    }}
                                >
                                    {({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
                                        <Form
                                            onSubmit={e => {
                                                e.preventDefault();
                                                handleSubmit();
                                            }}
                                        >
                                            <div className="input-group">
                                                <label>Email Id</label>
                                                <input
                                                    type="text"
                                                    name="email"
                                                    onChange={handleChange}
                                                    onBlur={handleBlur}
                                                    value={values.email}
                                                    placeholder="yourname@example.com"
                                                />
                                                {errors.email && touched.email && (<span className="form-error">{errors.email}</span>)}
                                            </div>
                                            <div className="input-group">
                                                <label>Password</label>
                                                <input
                                                    type="text"
                                                    name="password"
                                                    onChange={handleChange}
                                                    onBlur={handleBlur}
                                                    value={values.password}
                                                    placeholder="#@$!%@#"
                                                />
                                                {errors.password && touched.password && (<span className="form-error">{errors.password}</span>)}
                                            </div>
                                            <div className="input-group">
                                                <Button type="submit" className="btn btn-primary btn-submit">
                                                    Login
                                                </Button>
                                            </div>
                                        </Form>
                                    )}
                                </Formik>
                                <div className="input-group justify-content-center">
                                    <p className="text-center mb-0">or <Link href={`../signup/${props.type}`}><span style={{textDecoration:"underline",cursor:"pointer"}}>Create a new account</span></Link></p>
                                </div>
                                {props && props.type == "user" && (
                                    <>
                                        <div className="input-group mb-0">
                                            <div className="btn-continue">
                                                <span className="col-1 image-container">
                                                    <Image src={renderImage("/images/login/icon-google.png")} layout="fill" className="image" />
                                                </span>
                                                <span className="col-10 text-center">Continue with Google</span>
                                            </div>
                                        </div>
                                        <div className="input-group mb-0">
                                            <div className="btn-continue">
                                                <span className="col-1 image-container">
                                                    <Image src={renderImage("/images/login/icon-fb1.png")} layout="fill" className="image" />
                                                </span>
                                                <span className="col-10 text-center">Continue with Facebook</span>
                                            </div>
                                        </div>
                                        <div className="input-group mb-0">
                                            <div className="btn-continue mb-0">
                                                <span className="col-1 image-container">
                                                    <Image src={renderImage("/images/login/icon-apple.png")} layout="fill" className="image" />
                                                </span>
                                                <span className="col-10 text-center">Continue with Apple</span>
                                            </div>
                                        </div>
                                    </>
                                )}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </Fragment>
    )
}
export default Login;