I want to know how to take the coupon input and check if it is already in the coupons database before successful google log in. (If the coupon is in the coupons database then log in successfully).
const responseGoogle = async (response) => {
console.log(response)
try {
const req = await axios.post(`${process.env.REACT_APP_BASE_URL}/api/v1/login/google/googlelogin`,
{ tokenId: response.tokenId }, { withCredentials: true }
)
if (req.status === 200) {
localStorage.setItem('loginstatus', 'true')
localStorage.setItem('userprofile', JSON.stringify(response.profileObj))
history.push('/welcome')
}
else {
alert('err')
}
}
catch (e) {
(e.response.status === 400 && e.response.data.reason === 'not_domain') ?
alert('Your email domain is not valid') :
alert('An error occurred')
}
}
return(
<>
<GoogleLogin
clientId={process.env.REACT_APP_GOOGLE_ID}
render={renderProps => (
<Button onClick={renderProps.onClick} disableElevation disabled={renderProps.disabled} variant="outlined" color="default">
<img src={logo} alt="Google Logo" className="login_logo_comp" /> Sign in with Google
</Button>
)}
buttonText="Login"
onSuccess={responseGoogle}
onFailure={failed}
cookiePolicy={'single_host_origin'}
/>
</>
)
Would adding prompt to take the coupon input work? how to do this? and it should be before user enter google information or after? what other ways to do that?