Files
goal-planner/frontend/components/SignUpPage.tsx
T
2026-11-02 15:52:53 +08:00

87 lines
4.6 KiB
TypeScript

import React, { useState } from 'react';
interface SignUpPageProps {
onSignUp: (name: string, email: string, password: string) => void;
onNavigateToLogin: () => void;
}
const AppIcon = () => (
<svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-green-600 dark:text-green-400 mx-auto mb-4" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
);
const SignUpPage: React.FC<SignUpPageProps> = ({ onSignUp, onNavigateToLogin }) => {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (name.trim() && email.trim() && password.trim()) {
onSignUp(name.trim(), email.trim(), password);
}
};
return (
<div className="bg-white dark:bg-slate-800 p-8 rounded-xl shadow-lg border border-slate-200 dark:border-slate-700 w-full max-w-md">
<AppIcon />
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100 mb-2 text-center">Create Your Account</h2>
<p className="text-slate-600 dark:text-slate-400 mb-6 text-center">Start planning your goals today.</p>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label htmlFor="name" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Full Name</label>
<input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
className="w-full p-3 bg-white dark:bg-slate-700 text-slate-900 dark:text-slate-100 border border-slate-300 dark:border-slate-600 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow placeholder:text-slate-400 dark:placeholder:text-slate-500"
placeholder="Ada Lovelace"
required
/>
</div>
<div>
<label htmlFor="signup-email" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Email Address</label>
<input
type="email"
id="signup-email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full p-3 bg-white dark:bg-slate-700 text-slate-900 dark:text-slate-100 border border-slate-300 dark:border-slate-600 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow placeholder:text-slate-400 dark:placeholder:text-slate-500"
placeholder="you@example.com"
required
/>
</div>
<div>
<label htmlFor="signup-password" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Password</label>
<input
type="password"
id="signup-password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full p-3 bg-white dark:bg-slate-700 text-slate-900 dark:text-slate-100 border border-slate-300 dark:border-slate-600 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow placeholder:text-slate-400 dark:placeholder:text-slate-500"
placeholder="••••••••"
required
/>
</div>
<button
type="submit"
className="w-full bg-green-600 text-white font-semibold px-6 py-3 rounded-lg hover:bg-green-700 transition-colors disabled:bg-slate-400 dark:disabled:bg-slate-600 disabled:cursor-not-allowed"
disabled={!name || !email || !password}
>
Create Account
</button>
</form>
<p className="text-sm text-center text-slate-500 dark:text-slate-400 mt-6">
Already have an account?{' '}
<button onClick={onNavigateToLogin} className="font-semibold text-green-600 dark:text-green-400 hover:underline">
Log In
</button>
</p>
</div>
);
};
export default SignUpPage;