import { Flex, Box, FormControl, FormLabel, Input, InputGroup, InputRightElement, Stack, Button, Heading, Text, useColorModeValue, useToast, } from '@chakra-ui/react' import Link from 'next/link' import { useState } from 'react' import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons' import { login, loginWithGoogle, selectAuth } from '../store/authReducer' import { useDispatch, useSelector } from 'react-redux' import { LoginRequestPayload } from '../services/types' import { GoogleLogin } from '@react-oauth/google' export default function LoginPage() { const [showPassword, setShowPassword] = useState(false) const [credentials, setCredentials] = useState({ email: '', password: '', }) const dispatch = useDispatch() const toast = useToast() const authState = useSelector(selectAuth) const handleSubmit = async (e) => { e.preventDefault() if (!credentials.email || !credentials.password) { toast({ title: 'Error', description: 'Please fill in all fields', status: 'warning', }) } else { dispatch(login(credentials)) } } const onChange = (e) => { setCredentials({ ...credentials, [e.target.name]: e.target.value, }) } return ( Login to access your dashboard Email address Password { dispatch(loginWithGoogle({ idToken })) }} onError={() => { toast({ title: 'Error', description: 'Something went wrong', status: 'error', }) }} useOneTap={!authState.user} width='300' size='large' shape='pill' locale='en' theme='outline' text='continue_with' /> Don't have an account?{' '} Register ) }