Ignore:
Timestamp:
08/30/24 15:44:27 (4 weeks ago)
Author:
223021 <daniel.ilievski.2@…>
Branches:
main
Parents:
0f0add0
Message:

Implemented Google login, additional file uploads, response messages and email notifications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jobvista-frontend/src/views/auth/SignInForm.js

    r0f0add0 r4d97b63  
    1 import {Button, TextField} from "@mui/material";
    21import {Link} from "react-router-dom";
    32import "./auth.css"
     
    98import {AuthActions} from "../../redux/actions/authActions";
    109import {notifyIncorrectEmailOrPassword} from "../../utils/toastUtils";
     10
     11import {GoogleOAuthProvider, GoogleLogin} from "@react-oauth/google";
    1112
    1213export const SignInForm = () => {
     
    4041    }
    4142
     43    const handleGoogleSuccess = (response) => {
     44        const tokenId = response.credential;
     45
     46        dispatch(AuthActions.signInGoogle(tokenId, (success, error) => {
     47            if (success) {
     48                console.log("User signed in successfully");
     49                if(success) {
     50                    navigate("/")
     51                }
     52            } else {
     53                console.error("Google sign-in failed", error);
     54            }
     55        }));
     56    };
     57
     58    const handleGoogleFailure = (error) => {
     59        console.error(error);
     60    };
     61
    4262    return (
    4363
    44         <div className="d-flex align-items-center">
     64        <div className="">
    4565            <div className="container">
    46                 <div className="row">
    47                     <div className="col-md-8 mx-auto form-container">
     66                <div className="row d-flex flex-column justify-content-center align-items-center">
     67                    <div className="col-md-8 form-container">
    4868                        <h3 className="login-heading mb-4">Sign in</h3>
    4969                        <form onSubmit={handleSubmit(signIn)}>
     
    83103
    84104                        <div className="row">
     105                            <GoogleOAuthProvider clientId={process.env.REACT_APP_GOOGLE_CLIENT_ID}>
     106                                <GoogleLogin
     107                                    onSuccess={handleGoogleSuccess}
     108                                    onError={handleGoogleFailure}
     109                                    type={"standard"}
     110                                    text={"signin_with"}
     111                                    locale={"en"}
     112                                    redirectUri="http://localhost:3000/login/oauth2/code/google"
     113                                />
     114                            </GoogleOAuthProvider>
     115                        </div>
     116                        <br/>
     117                    </div>
     118
     119                    <div className="col-md-8 mt-5 form-container">
     120                        <div>
     121                            <h5 className="mb-3">Don't have an account?</h5>
     122                        </div>
     123
     124                        <div className="row">
    85125                            <div className="col-md-6">
    86126                                <Link to="/signup/recruiter" className="btn auth-secondary-btn text-uppercase fw-bold mb-2 w-100">SIGN UP AS RECRUITER</Link>
     
    91131                        </div>
    92132                    </div>
     133
    93134                </div>
    94135            </div>
Note: See TracChangeset for help on using the changeset viewer.