Showing
1 changed file
with
39 additions
and
1 deletions
| ... | @@ -24,6 +24,16 @@ import { | ... | @@ -24,6 +24,16 @@ import { |
| 24 | InputGroup, | 24 | InputGroup, |
| 25 | InputLeftElement, | 25 | InputLeftElement, |
| 26 | InputRightElement, | 26 | InputRightElement, |
| 27 | + Alert, | ||
| 28 | + AlertIcon, | ||
| 29 | + AlertTitle, | ||
| 30 | + AlertDescription, | ||
| 31 | + AlertDialog, | ||
| 32 | + AlertDialogBody, | ||
| 33 | + AlertDialogFooter, | ||
| 34 | + AlertDialogHeader, | ||
| 35 | + AlertDialogContent, | ||
| 36 | + AlertDialogOverlay, | ||
| 27 | } from '@chakra-ui/react' | 37 | } from '@chakra-ui/react' |
| 28 | import { PhoneIcon } from '@chakra-ui/icons' | 38 | import { PhoneIcon } from '@chakra-ui/icons' |
| 29 | import http from '../utils/http' | 39 | import http from '../utils/http' |
| ... | @@ -31,6 +41,10 @@ import http from '../utils/http' | ... | @@ -31,6 +41,10 @@ import http from '../utils/http' |
| 31 | const SignIn = () => { | 41 | const SignIn = () => { |
| 32 | const [username, setUsername] = useState('') | 42 | const [username, setUsername] = useState('') |
| 33 | const [password, setPassword] = useState('') | 43 | const [password, setPassword] = useState('') |
| 44 | + const [isSuccess, setSuccess] = useState(false) | ||
| 45 | + | ||
| 46 | + const cancelRef = React.useRef() | ||
| 47 | + const onClose = () => setSuccess(false) | ||
| 34 | 48 | ||
| 35 | const handleUsernameOnChange = (event) => { | 49 | const handleUsernameOnChange = (event) => { |
| 36 | setUsername(event.target.value) | 50 | setUsername(event.target.value) |
| ... | @@ -40,6 +54,14 @@ const SignIn = () => { | ... | @@ -40,6 +54,14 @@ const SignIn = () => { |
| 40 | setPassword(event.target.value) | 54 | setPassword(event.target.value) |
| 41 | } | 55 | } |
| 42 | 56 | ||
| 57 | + const signIn = () => { | ||
| 58 | + http.post('/login').then(response => { | ||
| 59 | + const { success, code, data, message } = response.data | ||
| 60 | + if (success) { | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + }) | ||
| 64 | + } | ||
| 43 | 65 | ||
| 44 | useEffect(() => { | 66 | useEffect(() => { |
| 45 | }, []) | 67 | }, []) |
| ... | @@ -47,7 +69,7 @@ const SignIn = () => { | ... | @@ -47,7 +69,7 @@ const SignIn = () => { |
| 47 | return ( | 69 | return ( |
| 48 | <Container> | 70 | <Container> |
| 49 | <Heading>Sign-In</Heading> | 71 | <Heading>Sign-In</Heading> |
| 50 | - <br /> | 72 | + <br/> |
| 51 | 73 | ||
| 52 | <Stack | 74 | <Stack |
| 53 | // divider={<StackDivider borderColor="gray.200"/>} | 75 | // divider={<StackDivider borderColor="gray.200"/>} |
| ... | @@ -75,10 +97,26 @@ const SignIn = () => { | ... | @@ -75,10 +97,26 @@ const SignIn = () => { |
| 75 | 97 | ||
| 76 | <Button | 98 | <Button |
| 77 | colorScheme="teal" | 99 | colorScheme="teal" |
| 100 | + onClick={() => signIn()} | ||
| 78 | > | 101 | > |
| 79 | Sign In | 102 | Sign In |
| 80 | </Button> | 103 | </Button> |
| 81 | </Stack> | 104 | </Stack> |
| 105 | + | ||
| 106 | + <AlertDialog | ||
| 107 | + isOpen={isSuccess} | ||
| 108 | + leastDestructiveRef={cancelRef} | ||
| 109 | + onClose={onClose} | ||
| 110 | + > | ||
| 111 | + <AlertDialogOverlay> | ||
| 112 | + <AlertDialogContent> | ||
| 113 | + <Alert status="success"> | ||
| 114 | + <AlertIcon /> | ||
| 115 | + Successfully signed in ! | ||
| 116 | + </Alert> | ||
| 117 | + </AlertDialogContent> | ||
| 118 | + </AlertDialogOverlay> | ||
| 119 | + </AlertDialog> | ||
| 82 | </Container> | 120 | </Container> |
| 83 | ) | 121 | ) |
| 84 | } | 122 | } | ... | ... |
-
Please register or login to post a comment