Implement login/signup pages

This commit implements the login and signup pages for the application.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 01:37:07 +00:00
parent d7e5c0bf48
commit 3b9a6cc8b0
4 changed files with 394 additions and 0 deletions

View File

@@ -9,6 +9,9 @@ import Transactions from "./pages/Transactions";
import Analytics from "./pages/Analytics"; import Analytics from "./pages/Analytics";
import Settings from "./pages/Settings"; import Settings from "./pages/Settings";
import NotFound from "./pages/NotFound"; import NotFound from "./pages/NotFound";
import Login from "./pages/Login";
import Register from "./pages/Register";
import ForgotPassword from "./pages/ForgotPassword";
const queryClient = new QueryClient(); const queryClient = new QueryClient();
@@ -23,6 +26,9 @@ const App = () => (
<Route path="/transactions" element={<Transactions />} /> <Route path="/transactions" element={<Transactions />} />
<Route path="/analytics" element={<Analytics />} /> <Route path="/analytics" element={<Analytics />} />
<Route path="/settings" element={<Settings />} /> <Route path="/settings" element={<Settings />} />
<Route path="/login" element={<Login />} />
<Route path="/register" element={<Register />} />
<Route path="/forgot-password" element={<ForgotPassword />} />
<Route path="*" element={<NotFound />} /> <Route path="*" element={<NotFound />} />
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>

View File

@@ -0,0 +1,109 @@
import React, { useState } from "react";
import { Link } from "react-router-dom";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { ArrowLeft, Mail, Check } from "lucide-react";
import { useToast } from "@/components/ui/use-toast";
const ForgotPassword = () => {
const [email, setEmail] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [isSubmitted, setIsSubmitted] = useState(false);
const { toast } = useToast();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!email) {
toast({
title: "입력 오류",
description: "이메일을 입력해주세요.",
variant: "destructive",
});
return;
}
setIsLoading(true);
// 실제 비밀번호 찾기 로직은 추후 구현
// 임시로 2초 후 성공으로 처리
setTimeout(() => {
setIsLoading(false);
setIsSubmitted(true);
toast({
title: "이메일 전송 완료",
description: "비밀번호 재설정 링크가 이메일로 전송되었습니다.",
});
}, 2000);
};
return (
<div className="min-h-screen flex flex-col items-center justify-center p-6 bg-neuro-background">
<div className="w-full max-w-md">
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-neuro-accent mb-2"> </h1>
<p className="text-gray-500"> </p>
</div>
<div className="neuro-flat p-8 mb-6">
{!isSubmitted ? (
<form onSubmit={handleSubmit}>
<div className="space-y-6">
<div className="space-y-2">
<Label htmlFor="email" className="text-base"></Label>
<div className="relative">
<Mail className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="email"
type="email"
placeholder="your@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<Button
type="submit"
className="w-full bg-neuro-accent hover:bg-neuro-accent-light text-white py-6 h-auto"
disabled={isLoading}
>
{isLoading ? "처리 중..." : "재설정 링크 전송"}
</Button>
</div>
</form>
) : (
<div className="text-center space-y-6">
<div className="mx-auto w-16 h-16 neuro-flat rounded-full flex items-center justify-center text-neuro-accent">
<Check className="h-8 w-8" />
</div>
<div>
<h3 className="text-xl font-semibold mb-2"> </h3>
<p className="text-gray-500">
{email} . .
</p>
</div>
<Button
className="w-full bg-neuro-accent hover:bg-neuro-accent-light text-white py-6 h-auto"
onClick={() => setIsSubmitted(false)}
>
</Button>
</div>
)}
</div>
<div className="text-center">
<Link to="/login" className="inline-flex items-center text-neuro-accent hover:underline">
<ArrowLeft className="mr-2 h-4 w-4" />
</Link>
</div>
</div>
</div>
);
};
export default ForgotPassword;

122
src/pages/Login.tsx Normal file
View File

@@ -0,0 +1,122 @@
import React, { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { ArrowRight, Mail, KeyRound, Eye, EyeOff } from "lucide-react";
import { useToast } from "@/components/ui/use-toast";
const Login = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const { toast } = useToast();
const navigate = useNavigate();
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
if (!email || !password) {
toast({
title: "입력 오류",
description: "이메일과 비밀번호를 모두 입력해주세요.",
variant: "destructive",
});
return;
}
setIsLoading(true);
// 실제 로그인 로직은 추후 구현
// 임시로 2초 후 로그인 성공으로 처리
setTimeout(() => {
setIsLoading(false);
toast({
title: "로그인 성공",
description: "환영합니다!",
});
navigate("/");
}, 2000);
};
return (
<div className="min-h-screen flex flex-col items-center justify-center p-6 bg-neuro-background">
<div className="w-full max-w-md">
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-neuro-accent mb-2"></h1>
<p className="text-gray-500"> </p>
</div>
<div className="neuro-flat p-8 mb-6">
<form onSubmit={handleLogin}>
<div className="space-y-6">
<div className="space-y-2">
<Label htmlFor="email" className="text-base"></Label>
<div className="relative">
<Mail className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="email"
type="email"
placeholder="your@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="password" className="text-base"></Label>
<div className="relative">
<KeyRound className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="password"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="pl-10 neuro-pressed"
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500"
>
{showPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
</button>
</div>
</div>
<div className="text-right">
<Link to="/forgot-password" className="text-sm text-neuro-accent hover:underline">
?
</Link>
</div>
<Button
type="submit"
className="w-full bg-neuro-accent hover:bg-neuro-accent-light text-white py-6 h-auto"
disabled={isLoading}
>
{isLoading ? "로그인 중..." : "로그인"} {!isLoading && <ArrowRight className="ml-2 h-5 w-5" />}
</Button>
</div>
</form>
</div>
<div className="text-center">
<p className="text-gray-500">
?{" "}
<Link to="/register" className="text-neuro-accent font-medium hover:underline">
</Link>
</p>
</div>
</div>
</div>
);
};
export default Login;

157
src/pages/Register.tsx Normal file
View File

@@ -0,0 +1,157 @@
import React, { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { ArrowRight, Mail, KeyRound, User, Eye, EyeOff } from "lucide-react";
import { useToast } from "@/components/ui/use-toast";
const Register = () => {
const [username, setUsername] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const { toast } = useToast();
const navigate = useNavigate();
const handleRegister = async (e: React.FormEvent) => {
e.preventDefault();
if (!username || !email || !password || !confirmPassword) {
toast({
title: "입력 오류",
description: "모든 필드를 입력해주세요.",
variant: "destructive",
});
return;
}
if (password !== confirmPassword) {
toast({
title: "비밀번호 불일치",
description: "비밀번호와 비밀번호 확인이 일치하지 않습니다.",
variant: "destructive",
});
return;
}
setIsLoading(true);
// 실제 회원가입 로직은 추후 구현
// 임시로 2초 후 회원가입 성공으로 처리
setTimeout(() => {
setIsLoading(false);
toast({
title: "회원가입 성공",
description: "로그인 페이지로 이동합니다.",
});
navigate("/login");
}, 2000);
};
return (
<div className="min-h-screen flex flex-col items-center justify-center p-6 bg-neuro-background">
<div className="w-full max-w-md">
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-neuro-accent mb-2"></h1>
<p className="text-gray-500"> </p>
</div>
<div className="neuro-flat p-8 mb-6">
<form onSubmit={handleRegister}>
<div className="space-y-6">
<div className="space-y-2">
<Label htmlFor="username" className="text-base"></Label>
<div className="relative">
<User className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="username"
type="text"
placeholder="홍길동"
value={username}
onChange={(e) => setUsername(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="email" className="text-base"></Label>
<div className="relative">
<Mail className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="email"
type="email"
placeholder="your@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="password" className="text-base"></Label>
<div className="relative">
<KeyRound className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="password"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="pl-10 neuro-pressed"
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500"
>
{showPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
</button>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="confirmPassword" className="text-base"> </Label>
<div className="relative">
<KeyRound className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input
id="confirmPassword"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<Button
type="submit"
className="w-full bg-neuro-accent hover:bg-neuro-accent-light text-white py-6 h-auto"
disabled={isLoading}
>
{isLoading ? "가입 중..." : "회원가입"} {!isLoading && <ArrowRight className="ml-2 h-5 w-5" />}
</Button>
</div>
</form>
</div>
<div className="text-center">
<p className="text-gray-500">
?{" "}
<Link to="/login" className="text-neuro-accent font-medium hover:underline">
</Link>
</p>
</div>
</div>
</div>
);
};
export default Register;