diff --git a/src/components/Login/index.js b/src/components/Login/index.js new file mode 100644 index 00000000..3899154e --- /dev/null +++ b/src/components/Login/index.js @@ -0,0 +1,80 @@ +import React, { useState } from 'react'; +import Swal from 'sweetalert2'; + +const Login = ({ setIsAuthenticated }) => { + const adminEmail = 'admin@example.com'; + const adminPassword = 'qwerty'; + + const [email, setEmail] = useState('admin@example.com'); + const [password, setPassword] = useState('qwerty'); + + const handleLogin = e => { + e.preventDefault(); + + if (email === adminEmail && password === adminPassword) { + Swal.fire({ + timer: 1500, + showConfirmButton: false, + willOpen: () => { + Swal.showLoading(); + }, + willClose: () => { + localStorage.setItem('is_authenticated', true); + setIsAuthenticated(true); + + Swal.fire({ + icon: 'success', + title: 'Successfully logged in!', + showConfirmButton: false, + timer: 1500, + }); + }, + }); + } else { + Swal.fire({ + timer: 1500, + showConfirmButton: false, + willOpen: () => { + Swal.showLoading(); + }, + willClose: () => { + Swal.fire({ + icon: 'error', + title: 'Error!', + text: 'Incorrect email or password.', + showConfirmButton: true, + }); + }, + }); + } + }; + + return ( +