mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
1e05501b9d
Mechanical, and it ends the migration visibly.
45 files imported the whole react-dom default export to reach one function.
They now import createPortal by name, across 54 call sites; six files already
did it this way. main.tsx keeps its react-dom/client import, which is a
different module and already correct.
forwardRef is gone from every component. In React 19 ref is an ordinary prop,
so the wrapper only obscured the signature:
NumericInput — a plain DOM ref, no imperative handle involved
JourneyMap — useImperativeHandle stays, only the wrapping goes
JourneyMapGL — same
JourneyMapAuto — same
Each takes `ref?: Ref<Handle>` in its own Props interface now, so the ref is
part of the declared surface instead of arriving through a generic parameter.
The two journey bindings in glLazy shrink to one line each. They existed as
forwardRef wrappers purely to carry the ref past the lazy boundary; with ref an
ordinary prop it rides through the spread like everything else, which makes all
six bindings in that file identical again.
The five React.FC annotations go. Three were `Record<string, React.FC<{size?:
number}>>` for provider icons in files that never import React at all — those
only typechecked through the UMD global — and are now ComponentType. The two
pages become function declarations.
TranslationContext uses the 19 context shorthand, which leaves its React default
import unused, so that goes too.
Also drops two dead vi.mocks of react-dom/server. Their comment still said "used
in createMarkerIcon", which stopped being true when marker icons moved to the
in-house serializer — nothing under src/ imports react-dom/server any more
except the parity test that exists to compare against it.
167 lines
8.2 KiB
TypeScript
167 lines
8.2 KiB
TypeScript
import React, { ChangeEvent } from 'react'
|
|
import { Lock, KeyRound, CheckCircle2, AlertTriangle, Eye, EyeOff } from 'lucide-react'
|
|
import { useTranslation } from '../i18n'
|
|
import { useResetPassword } from './resetPassword/useResetPassword'
|
|
|
|
const inputBase: React.CSSProperties = {
|
|
width: '100%', padding: '11px 44px 11px 38px', borderRadius: 12,
|
|
border: '1px solid #e5e7eb', fontSize: 'calc(14px * var(--fs-scale-body, 1))', fontFamily: 'inherit',
|
|
outline: 'none', transition: 'border-color 120ms',
|
|
background: 'white', color: '#111827',
|
|
}
|
|
|
|
function ResetPasswordPage() {
|
|
const { t } = useTranslation()
|
|
// Page = wiring container: token, form state, validation + submit live in the hook.
|
|
const {
|
|
navigate, token,
|
|
pw, setPw, pw2, setPw2, showPw, setShowPw,
|
|
mfaCode, setMfaCode, mfaRequired, error, success, isLoading,
|
|
handleSubmit,
|
|
} = useResetPassword()
|
|
|
|
const shell = (inner: React.ReactNode) => (
|
|
<div style={{
|
|
minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
background: 'linear-gradient(180deg, #f9fafb, #ffffff)', padding: 24, fontFamily: 'inherit',
|
|
}}>
|
|
<div style={{
|
|
width: '100%', maxWidth: 440, background: 'white', borderRadius: 20,
|
|
boxShadow: '0 12px 40px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04)',
|
|
padding: '32px 28px',
|
|
}}>{inner}</div>
|
|
</div>
|
|
)
|
|
|
|
if (success) {
|
|
return shell(
|
|
<div style={{ textAlign: 'center', padding: '12px 0' }}>
|
|
<div style={{
|
|
width: 56, height: 56, borderRadius: '50%', background: '#ecfdf5',
|
|
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
color: '#059669', marginBottom: 16,
|
|
}}><CheckCircle2 size={28} /></div>
|
|
<h1 style={{ fontSize: 'calc(22px * var(--fs-scale-title, 1))', fontWeight: 700, color: '#111827', margin: '0 0 10px 0' }}>
|
|
{t('login.resetPasswordSuccessTitle')}
|
|
</h1>
|
|
<p style={{ fontSize: 'calc(14px * var(--fs-scale-body, 1))', color: '#4b5563', lineHeight: 1.55, margin: 0 }}>
|
|
{t('login.resetPasswordSuccessBody')}
|
|
</p>
|
|
<button type="button" onClick={() => navigate('/login')} style={{
|
|
marginTop: 24, padding: '11px 22px', background: '#111827', color: 'white',
|
|
border: 'none', borderRadius: 12, fontSize: 'calc(14px * var(--fs-scale-body, 1))', fontWeight: 700,
|
|
cursor: 'pointer', fontFamily: 'inherit',
|
|
}}>{t('login.signIn')}</button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!token) {
|
|
return shell(
|
|
<div style={{ textAlign: 'center', padding: '12px 0' }}>
|
|
<div style={{
|
|
width: 56, height: 56, borderRadius: '50%', background: '#fef2f2',
|
|
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
color: '#dc2626', marginBottom: 16,
|
|
}}><AlertTriangle size={28} /></div>
|
|
<h1 style={{ fontSize: 'calc(22px * var(--fs-scale-title, 1))', fontWeight: 700, color: '#111827', margin: '0 0 10px 0' }}>
|
|
{t('login.resetPasswordInvalidLink')}
|
|
</h1>
|
|
<p style={{ fontSize: 'calc(14px * var(--fs-scale-body, 1))', color: '#4b5563', lineHeight: 1.55, margin: 0 }}>
|
|
{t('login.resetPasswordInvalidLinkBody')}
|
|
</p>
|
|
<button type="button" onClick={() => navigate('/forgot-password')} style={{
|
|
marginTop: 24, padding: '11px 22px', background: '#111827', color: 'white',
|
|
border: 'none', borderRadius: 12, fontSize: 'calc(14px * var(--fs-scale-body, 1))', fontWeight: 700,
|
|
cursor: 'pointer', fontFamily: 'inherit',
|
|
}}>{t('login.forgotPasswordSubmit')}</button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return shell(
|
|
<>
|
|
<h1 style={{ fontSize: 'calc(22px * var(--fs-scale-title, 1))', fontWeight: 700, color: '#111827', margin: '0 0 8px 0' }}>
|
|
{t('login.resetPasswordTitle')}
|
|
</h1>
|
|
<p style={{ fontSize: 'calc(13.5px * var(--fs-scale-body, 1))', color: '#6b7280', lineHeight: 1.55, margin: '0 0 22px 0' }}>
|
|
{mfaRequired ? t('login.resetPasswordMfaBody') : t('login.resetPasswordBody')}
|
|
</p>
|
|
{error && (
|
|
<div style={{
|
|
padding: '10px 12px', background: '#fef2f2', border: '1px solid #fecaca',
|
|
borderRadius: 10, color: '#991b1b', fontSize: 'calc(13px * var(--fs-scale-body, 1))', marginBottom: 14,
|
|
}}>{error}</div>
|
|
)}
|
|
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
{!mfaRequired && (
|
|
<>
|
|
<div>
|
|
<label style={{ display: 'block', fontSize: 'calc(12.5px * var(--fs-scale-body, 1))', fontWeight: 600, color: '#374151', marginBottom: 6 }}>
|
|
{t('login.newPassword')}
|
|
</label>
|
|
<div style={{ position: 'relative' }}>
|
|
<Lock size={15} className="text-[#9ca3af]" style={{ position: 'absolute', left: 13, top: '50%', transform: 'translateY(-50%)', pointerEvents: 'none' }} />
|
|
<input
|
|
type={showPw ? 'text' : 'password'} value={pw}
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) => setPw(e.target.value)}
|
|
required placeholder="••••••••" style={inputBase}
|
|
onFocus={(e) => { e.currentTarget.style.borderColor = '#111827' }}
|
|
onBlur={(e) => { e.currentTarget.style.borderColor = '#e5e7eb' }}
|
|
/>
|
|
<button type="button" onClick={() => setShowPw(v => !v)} style={{
|
|
position: 'absolute', right: 12, top: '50%', transform: 'translateY(-50%)',
|
|
background: 'none', border: 'none', cursor: 'pointer', padding: 2, color: '#9ca3af',
|
|
}}>{showPw ? <EyeOff size={16} /> : <Eye size={16} />}</button>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<label style={{ display: 'block', fontSize: 'calc(12.5px * var(--fs-scale-body, 1))', fontWeight: 600, color: '#374151', marginBottom: 6 }}>
|
|
{t('login.confirmPassword')}
|
|
</label>
|
|
<div style={{ position: 'relative' }}>
|
|
<Lock size={15} className="text-[#9ca3af]" style={{ position: 'absolute', left: 13, top: '50%', transform: 'translateY(-50%)', pointerEvents: 'none' }} />
|
|
<input
|
|
type={showPw ? 'text' : 'password'} value={pw2}
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) => setPw2(e.target.value)}
|
|
required placeholder="••••••••" style={inputBase}
|
|
onFocus={(e) => { e.currentTarget.style.borderColor = '#111827' }}
|
|
onBlur={(e) => { e.currentTarget.style.borderColor = '#e5e7eb' }}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</>
|
|
)}
|
|
{mfaRequired && (
|
|
<div>
|
|
<label style={{ display: 'block', fontSize: 'calc(12.5px * var(--fs-scale-body, 1))', fontWeight: 600, color: '#374151', marginBottom: 6 }}>
|
|
{t('login.mfaCode')}
|
|
</label>
|
|
<div style={{ position: 'relative' }}>
|
|
<KeyRound size={15} className="text-[#9ca3af]" style={{ position: 'absolute', left: 13, top: '50%', transform: 'translateY(-50%)', pointerEvents: 'none' }} />
|
|
<input
|
|
type="text" inputMode="numeric" value={mfaCode}
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) => setMfaCode(e.target.value)}
|
|
required placeholder="123456 or backup-code" style={{ ...inputBase, paddingRight: 12 }}
|
|
autoFocus
|
|
onFocus={(e) => { e.currentTarget.style.borderColor = '#111827' }}
|
|
onBlur={(e) => { e.currentTarget.style.borderColor = '#e5e7eb' }}
|
|
/>
|
|
</div>
|
|
</div>
|
|
)}
|
|
<button type="submit" disabled={isLoading} style={{
|
|
width: '100%', padding: '12px', background: '#111827', color: 'white',
|
|
border: 'none', borderRadius: 12, fontSize: 'calc(14px * var(--fs-scale-body, 1))', fontWeight: 700,
|
|
cursor: isLoading ? 'default' : 'pointer', fontFamily: 'inherit',
|
|
opacity: isLoading ? 0.7 : 1,
|
|
}}>
|
|
{isLoading ? '…' : (mfaRequired ? t('login.resetPasswordVerify') : t('login.resetPasswordSubmit'))}
|
|
</button>
|
|
</form>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default ResetPasswordPage
|