2025-04-02 22:42:02 +07:00
|
|
|
import { FC, ReactElement, useState } from 'react';
|
2025-03-27 22:28:40 +07:00
|
|
|
import { useNavigate } from 'react-router';
|
2025-03-27 07:19:46 +07:00
|
|
|
import { Button } from '@imphnen-frontend-service/ui/atoms';
|
|
|
|
|
import { InputForm } from '@imphnen-frontend-service/ui/molecules';
|
2025-04-02 22:42:02 +07:00
|
|
|
import { postLogin } from '@imphnen-frontend-service/service';
|
2025-03-17 09:39:04 +07:00
|
|
|
|
|
|
|
|
export const Components: FC = (): ReactElement => {
|
2025-03-27 22:28:40 +07:00
|
|
|
const navigate = useNavigate();
|
2025-04-02 22:42:02 +07:00
|
|
|
const [email, setEmail] = useState('');
|
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
|
|
|
|
|
|
const handleLogin = async (e: React.FormEvent) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
try {
|
|
|
|
|
const payload = { email, password };
|
|
|
|
|
console.log(payload); // for debugging
|
|
|
|
|
const response = await postLogin(payload);
|
|
|
|
|
|
|
|
|
|
console.log('Login successful:', response); // for debugging
|
|
|
|
|
navigate('/dashboard');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('Login error:', error); // for debugging
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-03-27 22:28:40 +07:00
|
|
|
|
2025-03-27 07:19:46 +07:00
|
|
|
return (
|
|
|
|
|
<div className="flex justify-center items-center min-h-screen">
|
|
|
|
|
<div className="bg-white border border-primary-200 shadow-lg p-[60px] text-center flex flex-col justify-items-stretch gap-8 rounded-2xl">
|
|
|
|
|
<img src="/logos/logo.svg" alt="" className="h-[70px] w-auto" />
|
|
|
|
|
<h1 className="text-primary-500 text-p1 font-semibold">
|
|
|
|
|
Welcome to IMPHNEN Backoffice
|
|
|
|
|
</h1>
|
2025-04-02 22:42:02 +07:00
|
|
|
<form onSubmit={handleLogin} className="flex flex-col gap-8">
|
|
|
|
|
<InputForm
|
|
|
|
|
label="Email"
|
|
|
|
|
placeholder="Masukkan Email"
|
|
|
|
|
type="email"
|
|
|
|
|
size="lg"
|
|
|
|
|
className="w-full"
|
|
|
|
|
value={email}
|
|
|
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<InputForm
|
|
|
|
|
label="Password"
|
|
|
|
|
placeholder="Masukkan password"
|
|
|
|
|
type="password"
|
|
|
|
|
size="lg"
|
|
|
|
|
className="w-full"
|
|
|
|
|
value={password}
|
|
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<Button type="submit">Login</Button>
|
|
|
|
|
</form>
|
2025-03-27 07:19:46 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-03-17 09:39:04 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Components;
|