diff --git a/public/gimmick.png b/public/gimmick.png new file mode 100644 index 0000000000000000000000000000000000000000..5ee50348d2ea358c18bbfde600467ee65ba1202f Binary files /dev/null and b/public/gimmick.png differ diff --git a/public/index.html b/public/index.html index aa069f27cbd9d53394428171c3989fd03db73c76..97861042304aafcb535290cfabc07a3004b8f9a9 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8" /> - <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> + <link rel="icon" href="%PUBLIC_URL%/gimmick.png" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" /> <meta @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - <title>React App</title> + <title>Say It App</title> </head> <body> <noscript>You need to enable JavaScript to run this app.</noscript> diff --git a/src/App.tsx b/src/App.tsx index 5715c4a712d1c6e06cb89b693490f57adb45b232..6248b5234fa0a7179cce726d603e8912f58af772 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -16,17 +16,18 @@ import Feedback from './pages/Feedback'; function App() { const location = useLocation(); - const isLoginPage = location.pathname === '/login'; + const isLoginPage = location.pathname === '/'; const isRegisterPage = location.pathname === '/register'; return ( <div className="App"> - {<Navbar/>} + {!isLoginPage && !isRegisterPage && <Navbar />} + <Routes> - <Route path="/" element={<Home />} /> + <Route path="/" element={<Login />} /> <Route path="/consultation" element={<Consultation />} /> <Route path="/Report" element={<Report />} /> <Route path="/Register" element={<Register />} /> - <Route path="/Login" element={<Login />} /> + {/* <Route path="/Login" element={<Login />} /> */} <Route path="/chat/:psychologistId" element={<Chat />} /> <Route path ="/profile" element={<Profile />} /> <Route path ="/feedback" element={<Feedback />} /> diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index b864173ffc072c0e10b4e678ed9a12ccb083e9a1..68bd3f4ba9e5b007cf11c66bb4f21da376c10446 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -24,7 +24,7 @@ const Navbar = () => { console.log('Logging out...'); console.log('User:', localStorage.getItem('user')); console.log('Token:', localStorage.getItem('jwt')); - navigate('/login'); + navigate('/'); }; useEffect(() => { @@ -78,7 +78,7 @@ const Navbar = () => { ) : ( <li> <button className='signinButton'> - <Link to="/login">Sign In</Link> + <Link to="/">Sign In</Link> </button> </li> )} diff --git a/src/pages/Consultation.tsx b/src/pages/Consultation.tsx index 2b9c155346938ab726a90a12813901ed1f194a00..8d0c76da38e48959340e5bdc4797aecb26abd01a 100644 --- a/src/pages/Consultation.tsx +++ b/src/pages/Consultation.tsx @@ -34,7 +34,7 @@ const Consultation = () => { console.log('Unauthorized - Redirecting to login page'); localStorage.removeItem('user'); localStorage.removeItem('jwt'); - window.location.replace('/login'); + window.location.replace('/'); } return Promise.reject(error); } @@ -43,7 +43,7 @@ const Consultation = () => { const user = localStorage.getItem('user'); if (!user) { - navigate('/login'); + navigate('/'); alert('Anda harus login terlebih dahulu untuk mengakses halaman ini'); } else { @@ -155,9 +155,23 @@ const Consultation = () => { <img src="yunis.jpg" alt={psychologist.psikolog_name} /> </div> <div className="psikolofDesc"> - <h2>{psychologist.psikolog_name}</h2> - <p>{psychologist.psikolog_phone}</p> - <p>{psychologist.psikolog_klinik}</p> + <div className="psikologName"> + <p>Name: </p> + <p>{psychologist.psikolog_name}</p> + </div> + <div className="psikologEmail"> + <p>Email: </p> + <p>{psychologist.psikolog_email}</p> + </div> + <div className="psikologPhone"> + <p>Phone: </p> + <p>{psychologist.psikolog_phone}</p> + </div> + <div className="psikologKlinik"> + <p>Klinik: </p> + <p>{psychologist.psikolog_klinik}</p> + </div> + </div> </div> diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index a41b78e48d640e80a4c166211468360c70f85860..f41b654e9d14e509314bcb3db74c04cdeeda8ff1 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -35,7 +35,6 @@ const Login = () => { localStorage.setItem('user', JSON.stringify(response.data.user)); console.log('Response:', response.data); if (response.data === "failed") { - // history('/'); setEmail(''); setPassword(''); @@ -43,10 +42,9 @@ const Login = () => { } else { - // history('/'); setEmail(''); setPassword(''); - history('/'); + history('/consultation'); } } catch (error) { diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 453d5afdf7446e7666e9e49edfff61133cfeab8c..066aa5ed3a481620527bf6b888b21cb79d81af4f 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -37,7 +37,7 @@ const Profile = () => { }); } else { - navigate('/login'); + navigate('/'); alert('Anda harus login terlebih dahulu untuk mengakses halaman ini'); } }, [navigate]); @@ -82,6 +82,25 @@ const Profile = () => { } }; + const handleDelete = async () => { + try { + const userString = localStorage.getItem('user'); + if (userString) { + const user: Psychologist = JSON.parse(userString); + const { psikolog_id } = user; + + const response = await axios.delete(`http://localhost:3010/psikolog/deleteProfile/${psikolog_id}`); + + console.log('Delete response:', response.data); + + // Setelah menghapus akun, arahkan pengguna ke halaman login atau halaman lainnya + navigate('/'); + } + } catch (error) { + console.error('Error deleting profile:', error); + } + }; + const handleChange = (field: string, value: string) => { @@ -213,6 +232,28 @@ const Profile = () => { > {isEditing ? 'Save' : 'Edit'} </Button> + <Button + colorScheme="red" + bgColor={'#FF4D4F'} + color={'white'} + size={'lg'} + border={0} + borderRadius={10} + height={'30px'} + width={'150px'} + fontWeight={'bold'} + onClick={handleDelete} + mb="3" + mt="35" + _hover={{ bg: '#FF3436' }} + _active={{ + bg: '#FF3436', + transform: 'scale(0.95)', + }} + cursor={'pointer'} + > + Delete Account + </Button> </Box> </Flex> diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index c25d81a62ebf554e8ba9620f034400ec001aebe1..d5859a003900da8a159ba75c33e9d0565c89cbdb 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -39,6 +39,24 @@ const Register = () => { const history = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); + setError(''); + setIsLoading(true); + if (!name || !email || !phoneNumber || !password || !clinic) { + setIsLoading(false); + setError('Please fill all fields.'); + + return; + } + + const confirmPassInput = (e.target as HTMLFormElement).querySelector('#userConfirmPassword') as HTMLInputElement; + + if (password !== confirmPassInput.value) { + setIsLoading(false); + setError("Your password and confirm password don't match."); + + return; + } + console.log('submitting...'); console.log(name, email, phoneNumber, password, clinic); @@ -50,17 +68,23 @@ const Register = () => { psikolog_password: password, psikolog_klinik: clinic, }); - navigate('/login'); + setIsLoading(false); + navigate('/'); console.log('Response:', response); if (response.status === 200) { // Registrasi berhasil, arahkan pengguna ke halaman login - navigate('/login'); + navigate('/'); } else { console.log('Registration failed:', response); } } - catch (error) { - console.log(error); + catch (error: any) { + setIsLoading(false); + + console.error('Error:', error.response.data); + + // Tangkap pesan kesalahan dari server + setError(error.response.data.error || 'Invalid Email'); } }; @@ -68,7 +92,7 @@ const Register = () => { return ( <div className="box"> <h2>REGISTER</h2> - {/* {error && <p className={styles.error}>{error}</p>} */} + {error && <p className="error">{error}</p>} <form className="registerForm" onSubmit={handleSubmit} method="POST"> <div className="inputBox"> <TextField sx={{ width: '26ch', marginBottom:'15px' }} id="email" label="Email" placeholder="Type your email" variant="standard" value={email} onChange={(e) => setEmail(e.target.value)}/> @@ -133,7 +157,7 @@ const Register = () => { {isLoading ? "Loading..." : "Sign Up"} </button> <p className="registerText"> - Have an account? <Link className="loginLink" to="/login">Login</Link> + Have an account? <Link className="loginLink" to="/">Login</Link> </p> </form> </div> diff --git a/src/styles/Consultation.css b/src/styles/Consultation.css index b79e5b2f3812cb6c859932c4f9c943bdeb526b4d..92871c3ad81632d570c127a492814a65d44fe68f 100644 --- a/src/styles/Consultation.css +++ b/src/styles/Consultation.css @@ -35,6 +35,7 @@ h1 { display: flex; flex-direction: row; gap: 30px; + align-items: center; } .psikologDesc{ display: flex; @@ -90,3 +91,28 @@ font-weight: bold; button.chat-button:hover { background-color: #0056b3; } + +.psikologName{ + font-weight: bold; + font-size: 20px; + display: flex; + flex-direction: row; +} +.psikologEmail{ + font-weight: bold; + font-size: 20px; + display: flex; + flex-direction: row; +} +.psikologPhone{ + font-weight: bold; + font-size: 20px; + display: flex; + flex-direction: row; +} +.psikologKlinik{ + font-weight: bold; + font-size: 20px; + display: flex; + flex-direction: row; +} \ No newline at end of file