|
1 | 1 | import React, {useState} from 'react'
|
2 | 2 | import { useGoogleLogin } from '@react-oauth/google';
|
3 | 3 | import { useNavigate } from 'react-router-dom';
|
4 |
| -import { Button } from 'flowbite-react'; |
| 4 | +import { Button, Popover } from 'flowbite-react'; |
5 | 5 | import AuthService from '../services/auth.service';
|
6 | 6 | import { Spinner } from 'flowbite-react';
|
7 | 7 |
|
@@ -29,20 +29,40 @@ function GoogleLoginButton(props) {
|
29 | 29 | }
|
30 | 30 | });
|
31 | 31 |
|
| 32 | + const googleButton = ( |
| 33 | + <Button disabled={props.error} color="light" onClick={() => (handleLoginGoogle(), setLoading(true))}> |
| 34 | + <svg version="1.1" className="roboto-medium h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" xmlnsXlink="http://www.w3.org/1999/xlink"> |
| 35 | + <path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"></path> |
| 36 | + <path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"></path> |
| 37 | + <path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"></path> |
| 38 | + <path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"></path> |
| 39 | + <path fill="none" d="M0 0h48v48H0z"></path> |
| 40 | + </svg> |
| 41 | + Sign in with Google |
| 42 | + {props.error && |
| 43 | + |
| 44 | + <span>⚠️</span> |
| 45 | + } |
| 46 | + </Button> |
| 47 | + ); |
| 48 | + |
32 | 49 | return (
|
33 | 50 | <>
|
34 | 51 | {loading ? (
|
35 | 52 | <Button color="light">
|
36 | 53 | <Spinner/>
|
37 | 54 | </Button>
|
38 | 55 | ): (
|
39 |
| - <Button color="light" onClick={() => (handleLoginGoogle(), setLoading(true))}><svg version="1.1" className="roboto-medium h-5 w-5 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" xmlnsXlink="http://www.w3.org/1999/xlink"> |
40 |
| - <path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"></path> |
41 |
| - <path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"></path> |
42 |
| - <path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"></path> |
43 |
| - <path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"></path> |
44 |
| - <path fill="none" d="M0 0h48v48H0z"></path> |
45 |
| - </svg>Sign in with Google</Button> |
| 56 | + props.error ? ( |
| 57 | + <Popover placement='top' content={<div className="p-2 text-sm text-gray-500">Invalid Google Client ID.</div>} trigger="hover"> |
| 58 | + <div> |
| 59 | + {googleButton} |
| 60 | + </div> |
| 61 | + </Popover> |
| 62 | + ):( |
| 63 | + googleButton |
| 64 | + ) |
| 65 | + |
46 | 66 | )}
|
47 | 67 |
|
48 | 68 | </>
|
|
0 commit comments