Files
License-Tracker-Pro/components/ResetPassword.tsx
T
Philip e045354892 feat: Initialize License Tracker Pro v1.2 project
Adds initial project structure, dependencies, and basic configuration for the License Tracker Pro v1.2 application. This includes setting up Vite for the build process, defining core types, and incorporating essential UI components like icons and a timeline. The project is now ready for development.
2026-01-26 18:55:43 -08:00

74 lines
3.1 KiB
TypeScript

import React, { useState } from 'react';
import { resetPassword } from '../graphService';
interface ResetPasswordProps {
token: string;
onSuccess: () => void;
}
const ResetPassword: React.FC<ResetPasswordProps> = ({ token, onSuccess }) => {
const [password, setPassword] = useState('');
const [confirm, setConfirm] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (password !== confirm) {
setError("Passwords do not match.");
return;
}
if (password.length < 6) {
setError("Password must be at least 6 characters.");
return;
}
setLoading(true);
setError('');
try {
await resetPassword(token, password);
alert("Password reset successfully. You can now login.");
onSuccess();
} catch (e: any) {
setError(e.message);
} finally {
setLoading(false);
}
};
return (
<div className="min-h-screen bg-slate-900 flex items-center justify-center p-4">
<div className="bg-slate-800 p-8 rounded-lg shadow-2xl w-full max-w-md border border-slate-700">
<h2 className="text-3xl font-bold text-cyan-400 mb-6 text-center">Set New Password</h2>
<form onSubmit={handleSubmit} className="space-y-6">
{error && <div className="bg-red-900/50 border border-red-500 text-red-200 text-sm p-3 rounded">{error}</div>}
<div>
<label className="block text-sm font-medium text-gray-400 mb-1">New Password</label>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full bg-slate-900 border border-slate-600 rounded-md p-2.5 text-gray-200 focus:outline-none focus:border-cyan-500"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-400 mb-1">Confirm Password</label>
<input
type="password"
value={confirm}
onChange={(e) => setConfirm(e.target.value)}
className="w-full bg-slate-900 border border-slate-600 rounded-md p-2.5 text-gray-200 focus:outline-none focus:border-cyan-500"
/>
</div>
<button type="submit" disabled={loading} className="w-full bg-cyan-600 hover:bg-cyan-500 text-white font-bold py-3 rounded-md transition-colors disabled:opacity-50">
{loading ? 'Updating...' : 'Update Password'}
</button>
</form>
</div>
</div>
);
};
export default ResetPassword;