Simplified lockout modals

This commit is contained in:
2026-10-24 11:48:19 +02:00
parent 7220700bac
commit 16fb6b9434
5 changed files with 168 additions and 339 deletions
@@ -2,18 +2,14 @@ import React, { useState, useEffect } from 'react';
import { createPortal } from 'react-dom';
import { useNavigate } from 'react-router-dom';
import {
ShieldAlert,
RefreshCw,
LogOut,
UserCheck,
CheckCircle2,
AlertTriangle,
ArrowLeft,
Mail,
Building2,
Fingerprint,
Clock,
ArrowLeft,
Sparkles,
} from 'lucide-react';
import { BrandLogo } from '../ui/BrandLogo';
import { PfmPartnerLogo } from '../common/PfmPartnerLogo';
import { AuthUserProfile, UserClaims } from '../../auth/AuthProvider';
import { cancelSessionExpiration, dismissSubordinateModals } from '../../services/sessionExpiration';
@@ -29,7 +25,6 @@ interface AccountActivationModalProps {
export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
user,
claims,
sub,
onSync,
onLogout,
initialError,
@@ -37,7 +32,6 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
const navigate = useNavigate();
const [isSyncing, setIsSyncing] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(initialError || null);
const [syncAttemptCount, setSyncAttemptCount] = useState(0);
useEffect(() => {
if (initialError !== undefined) {
@@ -54,16 +48,9 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
user?.name ||
(claims.name as string) ||
(claims.preferred_username as string) ||
'Registered Partner';
const displayEmail =
user?.email ||
(claims.email as string) ||
(claims['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] as string) ||
'';
'Partner';
const tenant = user?.tenant || (claims.tenant as string) || (claims.org as string) || 'Partner Organisation';
const role = user?.role || (claims.role as string) || 'Partner';
const handleSyncClick = async () => {
if (isSyncing) return;
@@ -80,10 +67,9 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
}
if (!result.success) {
setSyncAttemptCount((prev) => prev + 1);
setErrorMessage(
result.errorMessage ||
'Your partner account is not yet enabled. Please ask your funding administrator to activate your account.'
'Activation is still being reviewed by your funding administrator. Please check back shortly.'
);
}
} catch (err: unknown) {
@@ -93,10 +79,7 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
navigate('/', { replace: true });
return;
}
setErrorMessage(
errObj?.message ||
'Account activation check encountered an error. Please confirm with your administrator and try again.'
);
setErrorMessage('Unable to verify activation right now. Please try again in a few moments.');
} finally {
setIsSyncing(false);
}
@@ -116,147 +99,87 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
role="dialog"
aria-modal="true"
aria-labelledby="activation-modal-title"
className="fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6 bg-[#060a12]/90 backdrop-blur-md animate-in fade-in duration-200 select-none overflow-y-auto"
className="fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6 bg-slate-950/80 backdrop-blur-2xl animate-in fade-in duration-300 select-none overflow-y-auto"
>
{/* Background ambient lighting matching LandingPage */}
<div className="pointer-events-none absolute inset-0 overflow-hidden">
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[500px] bg-gradient-to-tr from-emerald-500/15 via-teal-500/10 to-cyan-500/15 blur-[120px] rounded-full" />
</div>
<div
className="relative w-full max-w-xl bg-[#0d1322] border border-amber-500/30 rounded-2xl shadow-2xl shadow-black/80 overflow-hidden flex flex-col text-slate-100 my-auto"
className="relative w-full max-w-md rounded-3xl border border-white/10 bg-slate-900/85 backdrop-blur-xl shadow-[0_25px_60px_rgba(0,0,0,0.85),inset_0_1px_1px_rgba(255,255,255,0.15)] overflow-hidden flex flex-col items-center text-center p-8 sm:p-10 my-auto space-y-6"
onClick={(e) => e.stopPropagation()}
>
<div className="h-1.5 w-full bg-gradient-to-r from-amber-500 via-amber-400 to-emerald-500" />
{/* Glowing Brand Icon Lockup */}
<div className="relative flex items-center justify-center pt-2">
<div className="absolute -inset-3 rounded-full bg-emerald-500/20 blur-xl animate-pulse" />
<PfmPartnerLogo className="h-16 w-16 drop-shadow-[0_8px_24px_rgba(16,185,129,0.35)] relative z-10" />
</div>
<div className="p-6 pb-4 border-b border-slate-800/80 bg-[#0f172a]/60">
<div className="flex items-start justify-between gap-4">
<div className="flex items-center gap-3.5">
<div className="relative p-2.5 rounded-xl bg-amber-500/10 border border-amber-500/20 text-amber-400">
<ShieldAlert className="w-6 h-6" />
<span className="absolute -top-1 -right-1 flex h-2.5 w-2.5">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"></span>
</span>
</div>
<div>
<span className="inline-flex items-center gap-1.5 text-[11px] font-semibold tracking-wider uppercase text-amber-400 bg-amber-500/10 border border-amber-500/20 px-2 py-0.5 rounded-full mb-1">
Access Restricted • Activation Pending
</span>
<h2 id="activation-modal-title" className="text-lg sm:text-xl font-bold text-white tracking-tight">
{errorMessage?.toLowerCase().includes('tenant')
? 'Organisation Account Inactive'
: 'Partner Account Pending Activation'}
</h2>
</div>
</div>
<BrandLogo size={36} showGlow={false} animateOnHover={false} />
{/* Title & Organization Pill */}
<div className="space-y-2">
<div className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-emerald-500/10 border border-emerald-500/20 text-[11px] font-semibold text-emerald-300">
<Clock className="w-3.5 h-3.5 text-emerald-400" />
<span>Activation Pending</span>
</div>
<h2 id="activation-modal-title" className="text-2xl font-bold tracking-tight text-white">
Welcome,{' '}
<span className="bg-gradient-to-r from-emerald-300 via-teal-200 to-cyan-300 bg-clip-text text-transparent">
{displayName}
</span>
</h2>
<div className="inline-flex items-center gap-1.5 text-xs text-slate-400 font-medium">
<Building2 className="w-3.5 h-3.5 text-teal-400 shrink-0" />
<span>{tenant}</span>
</div>
</div>
<div className="p-6 space-y-5 overflow-y-auto max-h-[70vh]">
<div className="bg-slate-900/80 border border-slate-800 rounded-xl p-4 space-y-2.5">
<div className="flex items-center gap-2 text-emerald-400 text-xs font-semibold">
<CheckCircle2 className="w-4 h-4 shrink-0" />
<span>Signed In Successfully</span>
</div>
<p className="text-xs text-slate-300 leading-relaxed">
You have signed in successfully, but your partner account is waiting to be activated by the funding administrator.
</p>
<p className="text-xs text-slate-400 leading-relaxed border-t border-slate-800/80 pt-2 font-medium">
Once your administrator confirms your account is active, click{' '}
<strong className="text-white">Check Account Status</strong> below to open your dashboard.
</p>
</div>
<div className="rounded-xl border border-slate-800 bg-[#090e1a]/60 p-4 space-y-3">
<div className="text-[11px] font-semibold text-slate-400 uppercase tracking-wider flex items-center justify-between">
<span>Your Partner Profile</span>
<span className="text-amber-400/90 text-[10px] font-mono bg-amber-500/10 px-2 py-0.5 rounded border border-amber-500/20">
Pending Activation
</span>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs">
<div className="flex items-center gap-2.5 bg-slate-900/60 p-2.5 rounded-lg border border-slate-800/60">
<UserCheck className="w-4 h-4 text-emerald-400 shrink-0" />
<div className="min-w-0">
<span className="text-[10px] text-slate-500 block">Name</span>
<span className="font-semibold text-white truncate block">{displayName}</span>
</div>
</div>
<div className="flex items-center gap-2.5 bg-slate-900/60 p-2.5 rounded-lg border border-slate-800/60">
<Mail className="w-4 h-4 text-teal-400 shrink-0" />
<div className="min-w-0">
<span className="text-[10px] text-slate-500 block">Email</span>
<span className="font-semibold text-slate-200 truncate block">{displayEmail || 'Not specified'}</span>
</div>
</div>
<div className="flex items-center gap-2.5 bg-slate-900/60 p-2.5 rounded-lg border border-slate-800/60">
<Building2 className="w-4 h-4 text-cyan-400 shrink-0" />
<div className="min-w-0">
<span className="text-[10px] text-slate-500 block">Organisation / Role</span>
<span className="font-semibold text-slate-200 truncate block">
{tenant} ({role})
</span>
</div>
</div>
<div className="flex items-center gap-2.5 bg-slate-900/60 p-2.5 rounded-lg border border-slate-800/60">
<Fingerprint className="w-4 h-4 text-slate-400 shrink-0" />
<div className="min-w-0">
<span className="text-[10px] text-slate-500 block">Account ID</span>
<span className="font-mono text-[11px] text-slate-400 truncate block">{sub || 'SSO-Principal'}</span>
</div>
</div>
</div>
</div>
{errorMessage && (
<div className="rounded-xl border border-rose-500/30 bg-rose-500/10 p-3.5 flex items-start gap-3 animate-in fade-in duration-150">
<AlertTriangle className="w-4 h-4 text-rose-400 shrink-0 mt-0.5" />
<div className="space-y-1">
<p className="text-xs font-semibold text-rose-300">Account Not Activated Yet</p>
<p className="text-xs text-rose-200/90 leading-relaxed">{errorMessage}</p>
{syncAttemptCount > 0 && (
<p className="text-[11px] text-rose-400/80 pt-1">
Checked #{syncAttemptCount} at {new Date().toLocaleTimeString()}
</p>
)}
</div>
</div>
)}
</div>
<div className="p-5 border-t border-slate-800/80 bg-[#0a0f1d] flex flex-col sm:flex-row items-center justify-between gap-3">
<div className="flex items-center gap-2 w-full sm:w-auto">
<button
onClick={handleNavigateLanding}
type="button"
className="flex-1 sm:flex-none inline-flex items-center justify-center gap-1.5 px-3.5 py-2 text-xs font-medium text-slate-400 hover:text-slate-200 bg-slate-900 hover:bg-slate-800 border border-slate-800 rounded-xl transition cursor-pointer"
>
<ArrowLeft className="w-3.5 h-3.5" />
<span>Home Page</span>
</button>
<button
onClick={handleSignOut}
type="button"
className="flex-1 sm:flex-none inline-flex items-center justify-center gap-1.5 px-3.5 py-2 text-xs font-medium text-slate-400 hover:text-rose-400 bg-slate-900 hover:bg-rose-500/10 border border-slate-800 hover:border-rose-500/30 rounded-xl transition cursor-pointer"
>
<LogOut className="w-3.5 h-3.5" />
<span>Sign Out</span>
</button>
{/* Core Friendly Message */}
<p className="text-sm text-slate-300 leading-relaxed max-w-sm">
Your credentials have been authenticated. Your funding administrator is finalizing your portfolio access.
</p>
{/* Notice badge if check returned not yet ready */}
{errorMessage && (
<div className="w-full rounded-2xl bg-amber-500/10 border border-amber-500/20 p-3 text-xs text-amber-300/90 leading-relaxed text-center flex items-center justify-center gap-2">
<Sparkles className="w-4 h-4 text-amber-400 shrink-0" />
<span>{errorMessage}</span>
</div>
)}
{/* Action Button matching Specular / Landing styling */}
<div className="w-full space-y-3 pt-2">
<button
onClick={handleSyncClick}
disabled={isSyncing}
type="button"
id="activation-sync-btn"
className="w-full sm:w-auto inline-flex items-center justify-center gap-2 px-5 py-2.5 text-xs font-semibold text-white bg-emerald-600 hover:bg-emerald-500 active:bg-emerald-700 disabled:opacity-50 disabled:pointer-events-none rounded-xl shadow-lg shadow-emerald-600/30 transition cursor-pointer"
className="w-full py-3.5 px-6 rounded-2xl bg-gradient-to-r from-emerald-600 via-teal-600 to-emerald-500 hover:from-emerald-500 hover:to-teal-500 active:scale-[0.99] disabled:opacity-60 disabled:pointer-events-none text-white font-bold text-sm tracking-wide shadow-[0_12px_30px_rgba(16,185,129,0.35),inset_0_1px_1px_rgba(255,255,255,0.3)] hover:shadow-[0_16px_36px_rgba(16,185,129,0.5)] transition-all flex items-center justify-center gap-2 cursor-pointer"
>
<RefreshCw className={`w-4 h-4 ${isSyncing ? 'animate-spin' : ''}`} />
<RefreshCw className={`w-4 h-4 text-emerald-100 ${isSyncing ? 'animate-spin' : ''}`} />
<span>{isSyncing ? 'Checking Status...' : 'Check Account Status'}</span>
</button>
{/* Minimal Secondary Actions */}
<div className="flex items-center justify-center gap-4 text-xs pt-1">
<button
onClick={handleNavigateLanding}
type="button"
className="inline-flex items-center gap-1.5 text-slate-400 hover:text-slate-200 transition-colors py-1 cursor-pointer"
>
<ArrowLeft className="w-3.5 h-3.5" />
<span>Landing Page</span>
</button>
<span className="text-slate-700">•</span>
<button
onClick={handleSignOut}
type="button"
className="inline-flex items-center gap-1.5 text-slate-400 hover:text-rose-400 transition-colors py-1 cursor-pointer"
>
<LogOut className="w-3.5 h-3.5" />
<span>Sign Out</span>
</button>
</div>
</div>
</div>
</div>
@@ -266,4 +189,3 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
? createPortal(modalContent, document.body)
: modalContent;
};