|
| 1 | +import { makeStyles, Typography, Button } from '@material-ui/core'; |
| 2 | +import React from 'react'; |
| 3 | +import { signInWithGoogle } from 'src/services/authService'; |
| 4 | +import { useHistory } from 'react-router-dom'; |
| 5 | +import clsx from 'clsx'; |
| 6 | + |
| 7 | +const useStyles = makeStyles(theme => ({ |
| 8 | + root: { |
| 9 | + background: |
| 10 | + 'linear-gradient(269.76deg, #180255 0.18%, #000000 53.35%, #000000 107.44%)', |
| 11 | + height: '100vh', |
| 12 | + textAlign: 'center' |
| 13 | + }, |
| 14 | + container: { |
| 15 | + color: '#fff', |
| 16 | + margin: 'auto', |
| 17 | + textAlign: 'center', |
| 18 | + verticalAlign: 'center', |
| 19 | + position: 'absolute', |
| 20 | + top: '50%', |
| 21 | + left: '50%', |
| 22 | + msTransform: 'translate(-50%, -50%)', |
| 23 | + transform: 'translate(-50%, -50%)', |
| 24 | + maxWidth: 450 |
| 25 | + }, |
| 26 | + typography: { |
| 27 | + margin: '40px 0px 10px' |
| 28 | + }, |
| 29 | + btn: { |
| 30 | + backgroundColor: '#cccccc', |
| 31 | + color: '#000', |
| 32 | + '&:hover': { |
| 33 | + backgroundColor: '#ceeeee' |
| 34 | + } |
| 35 | + }, |
| 36 | + parentbtn: { |
| 37 | + backgroundColor: '#A60000', |
| 38 | + color: '#ffffff', |
| 39 | + padding: '8px 16px', |
| 40 | + fontWeight: 700, |
| 41 | + textTransform: 'capitalize', |
| 42 | + [theme.breakpoints.down('sm')]: { |
| 43 | + width: '100%' |
| 44 | + }, |
| 45 | + '&:hover': { |
| 46 | + backgroundColor: 'rgba(166, 0, 0, 0.8)' |
| 47 | + } |
| 48 | + } |
| 49 | +})); |
| 50 | + |
| 51 | +export default function Login() { |
| 52 | + const classes = useStyles(); |
| 53 | + const history = useHistory(); |
| 54 | + |
| 55 | + const handleSignInWithGoogle = () => { |
| 56 | + signInWithGoogle() |
| 57 | + .then(() => { |
| 58 | + history.push('/'); |
| 59 | + }) |
| 60 | + .catch(e => { |
| 61 | + console.log('error', e); |
| 62 | + }); |
| 63 | + }; |
| 64 | + |
| 65 | + return ( |
| 66 | + <div className={classes.root}> |
| 67 | + <div className={classes.container}> |
| 68 | + <Typography variant="h2" className={classes.typography}> |
| 69 | + Sign In / Sign Up |
| 70 | + </Typography> |
| 71 | + <Typography style={{ marginBottom: '40px' }}> |
| 72 | + Login to Manage your events with CauseFolio |
| 73 | + </Typography> |
| 74 | + <ButtonComponent |
| 75 | + title="Sign In with Google" |
| 76 | + className={classes.btn} |
| 77 | + onClick={handleSignInWithGoogle} |
| 78 | + fullWidth |
| 79 | + icon={ |
| 80 | + <img |
| 81 | + src={'https://image.flaticon.com/icons/png/32/2702/2702602.png'} |
| 82 | + style={{ marginRight: '16px' }} |
| 83 | + alt="G-Icon" |
| 84 | + /> |
| 85 | + } |
| 86 | + /> |
| 87 | + <Typography |
| 88 | + variant="caption" |
| 89 | + style={{ display: 'block', marginTop: '40px', fontSize: '10px' }} |
| 90 | + > |
| 91 | + By continuing, you agree to Code For Cause Terms of Use & Privacy |
| 92 | + policy. |
| 93 | + </Typography> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + ); |
| 97 | +} |
| 98 | + |
| 99 | +function ButtonComponent({ className, title, icon = '', ...rest }) { |
| 100 | + const classes = useStyles(); |
| 101 | + return ( |
| 102 | + <Button className={clsx(classes.btn, className)} {...rest}> |
| 103 | + {icon} |
| 104 | + {title} |
| 105 | + </Button> |
| 106 | + ); |
| 107 | +} |
0 commit comments