refactor(ui): tokenize reset password colors
This commit is contained in:
parent
987ccae747
commit
e4c4c60cff
@ -1,28 +1,28 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { resetPlatformPassword } from '../lib/authSession';
|
import { resetPlatformPassword } from '../lib/authSession';
|
||||||
import { Button, Input } from './ui/Primitives';
|
import { Button, Input } from './ui/Primitives';
|
||||||
|
|
||||||
export function ResetPassword() {
|
export function ResetPassword() {
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [message, setMessage] = useState<string | null>(null);
|
const [message, setMessage] = useState<string | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Handle hash fragment if present (implicit flow)
|
// Handle hash fragment if present (implicit flow)
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
if (hash && hash.includes('type=recovery')) {
|
if (hash && hash.includes('type=recovery')) {
|
||||||
// Supabase handles the session automatically if the link is clicked
|
// Supabase handles the session automatically if the link is clicked
|
||||||
// We just need to let the user set a new password
|
// We just need to let the user set a new password
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handlePasswordReset = async (e: React.FormEvent) => {
|
const handlePasswordReset = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await resetPlatformPassword(password);
|
await resetPlatformPassword(password);
|
||||||
setMessage('Password updated successfully! You can now login.');
|
setMessage('Password updated successfully! You can now login.');
|
||||||
@ -32,19 +32,19 @@ export function ResetPassword() {
|
|||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="login-container">
|
<div className="login-container">
|
||||||
<div className="login-card">
|
<div className="login-card">
|
||||||
<h1>Reset Password</h1>
|
<h1>Reset Password</h1>
|
||||||
<p className="subtitle">Enter your new password below</p>
|
<p className="subtitle">Enter your new password below</p>
|
||||||
|
|
||||||
<form onSubmit={handlePasswordReset}>
|
<form onSubmit={handlePasswordReset}>
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<Input
|
<Input
|
||||||
label="New Password"
|
label="New Password"
|
||||||
@ -52,111 +52,125 @@ export function ResetPassword() {
|
|||||||
value={password}
|
value={password}
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
placeholder="New password"
|
placeholder="New password"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="error-message">{error}</div>}
|
{error && <div className="error-message">{error}</div>}
|
||||||
{message && <div className="success-message" style={{ color: '#00ff88', marginBottom: '20px', textAlign: 'center' }}>{message}</div>}
|
{message && <div className="success-message">{message}</div>}
|
||||||
|
|
||||||
<Button type="submit" disabled={loading || !!message} className="auth-button">
|
<Button type="submit" disabled={loading || !!message} className="auth-button">
|
||||||
{loading ? 'Updating...' : 'Update Password'}
|
{loading ? 'Updating...' : 'Update Password'}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<style>{`
|
<style>{`
|
||||||
.login-container {
|
.login-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #0a0b0d;
|
background: var(--background);
|
||||||
color: #fff;
|
color: var(--foreground);
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-card {
|
.login-card {
|
||||||
background: #14151a;
|
background: var(--card);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border: 1px solid var(--border);
|
||||||
padding: 40px;
|
|
||||||
border-radius: 16px;
|
padding: 40px;
|
||||||
width: 100%;
|
border-radius: 16px;
|
||||||
max-width: 400px;
|
width: 100%;
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
max-width: 400px;
|
||||||
}
|
box-shadow: var(--card-shadow);
|
||||||
|
}
|
||||||
h1 {
|
|
||||||
margin: 0 0 8px 0;
|
h1 {
|
||||||
font-size: 1.5rem;
|
margin: 0 0 8px 0;
|
||||||
text-align: center;
|
font-size: 1.5rem;
|
||||||
background: linear-gradient(90deg, #fff, #00ff88);
|
text-align: center;
|
||||||
-webkit-background-clip: text;
|
background: linear-gradient(90deg, var(--foreground), var(--bl-success));
|
||||||
background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
-webkit-background-clip: text;
|
||||||
}
|
background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
.subtitle {
|
}
|
||||||
text-align: center;
|
|
||||||
color: #929292;
|
.subtitle {
|
||||||
margin-bottom: 32px;
|
text-align: center;
|
||||||
font-size: 0.9rem;
|
color: var(--muted-foreground);
|
||||||
}
|
|
||||||
|
margin-bottom: 32px;
|
||||||
.form-group {
|
font-size: 0.9rem;
|
||||||
margin-bottom: 20px;
|
}
|
||||||
}
|
|
||||||
|
.form-group {
|
||||||
label {
|
margin-bottom: 20px;
|
||||||
display: block;
|
}
|
||||||
margin-bottom: 8px;
|
|
||||||
color: #ccc;
|
label {
|
||||||
font-size: 0.9rem;
|
display: block;
|
||||||
}
|
margin-bottom: 8px;
|
||||||
|
color: var(--muted-foreground);
|
||||||
input {
|
|
||||||
width: 100%;
|
font-size: 0.9rem;
|
||||||
padding: 12px;
|
}
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
input {
|
||||||
border-radius: 8px;
|
width: 100%;
|
||||||
color: #fff;
|
padding: 12px;
|
||||||
font-size: 1rem;
|
background: var(--input);
|
||||||
box-sizing: border-box;
|
border: 1px solid var(--border);
|
||||||
}
|
|
||||||
|
border-radius: 8px;
|
||||||
input:focus {
|
color: var(--foreground);
|
||||||
outline: none;
|
font-size: 1rem;
|
||||||
border-color: #00ff88;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.auth-button {
|
input:focus {
|
||||||
width: 100%;
|
outline: none;
|
||||||
padding: 12px;
|
border-color: var(--bl-focus-ring);
|
||||||
background: #00ff88;
|
|
||||||
color: #000;
|
}
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
.auth-button {
|
||||||
font-weight: bold;
|
width: 100%;
|
||||||
font-size: 1rem;
|
padding: 12px;
|
||||||
cursor: pointer;
|
background: var(--bl-success);
|
||||||
margin-top: 10px;
|
color: var(--primary-foreground);
|
||||||
transition: opacity 0.2s;
|
|
||||||
}
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
.auth-button:disabled {
|
font-weight: bold;
|
||||||
opacity: 0.7;
|
font-size: 1rem;
|
||||||
cursor: not-allowed;
|
cursor: pointer;
|
||||||
}
|
margin-top: 10px;
|
||||||
|
transition: opacity 0.2s;
|
||||||
.error-message {
|
}
|
||||||
color: #ff3366;
|
|
||||||
background: rgba(255, 51, 102, 0.1);
|
.auth-button:disabled {
|
||||||
padding: 10px;
|
opacity: 0.7;
|
||||||
border-radius: 6px;
|
cursor: not-allowed;
|
||||||
margin-bottom: 20px;
|
}
|
||||||
font-size: 0.9rem;
|
|
||||||
text-align: center;
|
.error-message {
|
||||||
}
|
color: var(--bl-danger);
|
||||||
`}</style>
|
background: var(--bl-danger-muted);
|
||||||
</div>
|
|
||||||
);
|
padding: 10px;
|
||||||
}
|
border-radius: 6px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-message {
|
||||||
|
color: var(--bl-success);
|
||||||
|
margin-bottom: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user