Updated the screens as per Design.md
This commit is contained in:
parent
ed1395ce19
commit
ac77c4a21e
|
|
@ -5,10 +5,13 @@
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Agriculture Trading Backoffice (ATB)</title>
|
<title>Agriculture Trading Backoffice (ATB)</title>
|
||||||
|
<!-- AgriTrade Mercantile Fonts: Inter & JetBrains Mono -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-gray-50 text-gray-900 font-sans antialiased">
|
<body class="bg-surface text-on-surface font-sans antialiased selection:bg-secondary-container selection:text-on-surface">
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -3,11 +3,11 @@ import { authStore } from './stores/authStore';
|
||||||
import { tenantStore } from './stores/tenantStore';
|
import { tenantStore } from './stores/tenantStore';
|
||||||
import { LoginView } from './features/auth/LoginView';
|
import { LoginView } from './features/auth/LoginView';
|
||||||
import { SessionView } from './features/auth/SessionView';
|
import { SessionView } from './features/auth/SessionView';
|
||||||
import { AccessDeniedView } from './features/auth/AccessDeniedView';
|
|
||||||
import { HeaderTenantSwitcher } from './features/tenant/HeaderTenantSwitcher';
|
import { HeaderTenantSwitcher } from './features/tenant/HeaderTenantSwitcher';
|
||||||
import { PlatformTenantsView } from './features/tenant/PlatformTenantsView';
|
import { PlatformTenantsView } from './features/tenant/PlatformTenantsView';
|
||||||
import { TenantMembersView } from './features/tenant/TenantMembersView';
|
import { TenantMembersView } from './features/tenant/TenantMembersView';
|
||||||
import { AuditLogView } from './features/tenant/AuditLogView';
|
import { AuditLogView } from './features/tenant/AuditLogView';
|
||||||
|
import { Shield, Building2, Users, FileText, LogOut, Layers } from 'lucide-react';
|
||||||
|
|
||||||
export const App: React.FC = () => {
|
export const App: React.FC = () => {
|
||||||
const [activeTab, setActiveTab] = useState<'sessions' | 'tenants' | 'members' | 'audit'>('sessions');
|
const [activeTab, setActiveTab] = useState<'sessions' | 'tenants' | 'members' | 'audit'>('sessions');
|
||||||
|
|
@ -23,74 +23,110 @@ export const App: React.FC = () => {
|
||||||
return <LoginView />;
|
return <LoginView />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const navItems = [
|
||||||
|
{ id: 'sessions' as const, label: 'Session Governance', icon: Shield },
|
||||||
|
{ id: 'tenants' as const, label: 'Platform Tenants', icon: Building2 },
|
||||||
|
{ id: 'members' as const, label: 'Tenant Members', icon: Users },
|
||||||
|
{ id: 'audit' as const, label: 'Security Audit', icon: FileText },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 flex flex-col font-sans">
|
<div className="min-h-screen bg-surface flex text-on-surface font-sans">
|
||||||
<header className="bg-white border-b border-gray-200 px-6 py-3 flex items-center justify-between shadow-sm">
|
{/* 240px Persistent Dark Pine Navigation Drawer per DESIGN.md */}
|
||||||
<div className="flex items-center space-x-6">
|
<aside className="w-60 bg-sidebar-surface text-white flex-shrink-0 flex flex-col justify-between border-r border-sidebar-active select-none">
|
||||||
<div className="flex items-center space-x-2">
|
<div>
|
||||||
<span className="text-xl font-bold tracking-tight text-emerald-800">ATB Mandi Desk</span>
|
{/* Brand Header */}
|
||||||
<span className="text-xs bg-emerald-100 text-emerald-800 px-2 py-0.5 rounded-full font-medium">v1.0.0</span>
|
<div className="p-5 border-b border-sidebar-active flex items-center space-x-3">
|
||||||
|
<div className="w-8 h-8 rounded bg-sidebar-active flex items-center justify-center text-accent-ochre">
|
||||||
|
<Layers className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-bold tracking-tight text-white flex items-center gap-1.5">
|
||||||
|
<span>AgriTrade</span>
|
||||||
|
<span className="text-[10px] font-mono uppercase bg-sidebar-active text-accent-ochre px-1.5 py-0.2 rounded">ATB</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-[11px] text-gray-400 font-mono">Tactile Mercantile Desk</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav className="flex space-x-2">
|
|
||||||
<button
|
{/* Navigation Items */}
|
||||||
onClick={() => setActiveTab('sessions')}
|
<nav className="p-3 space-y-1">
|
||||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
<div className="px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-400 font-mono">
|
||||||
activeTab === 'sessions' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
Operational Portals
|
||||||
}`}
|
</div>
|
||||||
>
|
{navItems.map((item) => {
|
||||||
Session Governance
|
const Icon = item.icon;
|
||||||
</button>
|
const isActive = activeTab === item.id;
|
||||||
<button
|
return (
|
||||||
onClick={() => setActiveTab('tenants')}
|
<button
|
||||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
key={item.id}
|
||||||
activeTab === 'tenants' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
onClick={() => setActiveTab(item.id)}
|
||||||
}`}
|
className={`w-full flex items-center space-x-3 px-3 py-2 rounded text-xs font-medium transition duration-150 ${
|
||||||
>
|
isActive
|
||||||
Platform Tenants
|
? 'bg-sidebar-active text-white border-l-2 border-accent-ochre shadow-none font-semibold'
|
||||||
</button>
|
: 'text-gray-300 hover:bg-sidebar-active/60 hover:text-white'
|
||||||
<button
|
}`}
|
||||||
onClick={() => setActiveTab('members')}
|
>
|
||||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
<Icon className={`w-4 h-4 ${isActive ? 'text-accent-ochre' : 'text-gray-400'}`} />
|
||||||
activeTab === 'members' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
<span>{item.label}</span>
|
||||||
}`}
|
</button>
|
||||||
>
|
);
|
||||||
Tenant Members
|
})}
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => setActiveTab('audit')}
|
|
||||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
|
||||||
activeTab === 'audit' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
Security Audit
|
|
||||||
</button>
|
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-4">
|
|
||||||
<HeaderTenantSwitcher />
|
{/* Drawer Bottom Context & Logout */}
|
||||||
|
<div className="p-4 border-t border-sidebar-active space-y-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
authStore.logout();
|
authStore.logout();
|
||||||
tenantStore.clearTenant();
|
tenantStore.clearTenant();
|
||||||
}}
|
}}
|
||||||
className="text-xs text-red-600 hover:text-red-800 font-medium px-2 py-1 rounded border border-red-200 hover:bg-red-50"
|
className="w-full flex items-center justify-center space-x-2 px-3 py-2 text-xs font-medium text-gray-300 hover:text-white hover:bg-sidebar-active/80 rounded transition border border-sidebar-active"
|
||||||
>
|
>
|
||||||
Logout
|
<LogOut className="w-3.5 h-3.5 text-gray-400" />
|
||||||
|
<span>Sign Out</span>
|
||||||
</button>
|
</button>
|
||||||
|
<div className="text-[10px] text-gray-400 text-center font-mono">
|
||||||
|
UP-AI v1.5 Standard Desk
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</aside>
|
||||||
|
|
||||||
<main className="flex-1 p-6 max-w-7xl w-full mx-auto">
|
{/* Main Operational Canvas */}
|
||||||
{activeTab === 'sessions' && <SessionView />}
|
<div className="flex-1 flex flex-col min-w-0">
|
||||||
{activeTab === 'tenants' && <PlatformTenantsView />}
|
{/* Top Control Bar */}
|
||||||
{activeTab === 'members' && <TenantMembersView />}
|
<header className="bg-card-surface border-b border-card-border px-8 py-3.5 flex items-center justify-between sticky top-0 z-10 shadow-none">
|
||||||
{activeTab === 'audit' && <AuditLogView />}
|
<div className="flex items-center space-x-3">
|
||||||
</main>
|
<h1 className="text-base font-semibold text-text-primary capitalize tracking-tight">
|
||||||
|
{activeTab === 'sessions' && 'Session & Token Governance'}
|
||||||
|
{activeTab === 'tenants' && 'Platform Trading Tenants'}
|
||||||
|
{activeTab === 'members' && 'Tenant Membership & Role Matrix'}
|
||||||
|
{activeTab === 'audit' && 'Security Audit Trail & Mutations'}
|
||||||
|
</h1>
|
||||||
|
<span className="text-xs text-text-muted">|</span>
|
||||||
|
<span className="text-xs font-mono text-text-muted uppercase">240px Asymmetric Canvas</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer className="bg-white border-t border-gray-200 px-6 py-3 text-xs text-gray-500 text-center">
|
<div className="flex items-center space-x-4">
|
||||||
Agriculture Trading Backoffice (ATB) © 2026. Built with AI-Native Unified Process (UP-AI v1.5).
|
<HeaderTenantSwitcher />
|
||||||
</footer>
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{/* View Content */}
|
||||||
|
<main className="flex-1 p-8 max-w-7xl w-full mx-auto">
|
||||||
|
{activeTab === 'sessions' && <SessionView />}
|
||||||
|
{activeTab === 'tenants' && <PlatformTenantsView />}
|
||||||
|
{activeTab === 'members' && <TenantMembersView />}
|
||||||
|
{activeTab === 'audit' && <AuditLogView />}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{/* Footer */}
|
||||||
|
<footer className="bg-card-surface border-t border-card-border px-8 py-3 text-xs text-text-muted flex justify-between items-center">
|
||||||
|
<span>Agriculture Trading Backoffice (ATB) © 2026. Tactile Corporate Minimalism.</span>
|
||||||
|
<span className="font-mono text-[11px]">DESIGN.md Tokenized</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
|
variant?: 'primary' | 'secondary' | 'accent' | 'danger';
|
||||||
|
size?: 'sm' | 'md' | 'lg';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Button: React.FC<ButtonProps> = ({
|
||||||
|
children,
|
||||||
|
variant = 'primary',
|
||||||
|
size = 'md',
|
||||||
|
className = '',
|
||||||
|
disabled,
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
const baseStyles = 'inline-flex items-center justify-center font-medium transition duration-150 rounded disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-1';
|
||||||
|
|
||||||
|
const sizeStyles = {
|
||||||
|
sm: 'text-xs px-2.5 py-1.5',
|
||||||
|
md: 'text-sm px-4 py-2',
|
||||||
|
lg: 'text-base px-5 py-2.5',
|
||||||
|
};
|
||||||
|
|
||||||
|
const variantStyles = {
|
||||||
|
primary: 'bg-sidebar-surface hover:bg-sidebar-active text-white focus:ring-sidebar-active shadow-none',
|
||||||
|
secondary: 'bg-white hover:bg-surface-low text-text-primary border border-card-border focus:ring-card-border shadow-none',
|
||||||
|
accent: 'bg-accent-ochre hover:brightness-95 text-white focus:ring-accent-ochre shadow-none font-semibold',
|
||||||
|
danger: 'bg-error hover:bg-red-800 text-white focus:ring-error shadow-none',
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={`${baseStyles} ${sizeStyles[size]} ${variantStyles[variant]} ${className}`}
|
||||||
|
disabled={disabled}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
title?: string;
|
||||||
|
subtitle?: string;
|
||||||
|
action?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Card: React.FC<CardProps> = ({
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
action,
|
||||||
|
children,
|
||||||
|
className = '',
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`bg-card-surface border border-card-border rounded shadow-none ${className}`}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{(title || action) && (
|
||||||
|
<div className="px-6 py-4 border-b border-card-border flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
{title && <h3 className="text-base font-semibold text-text-primary tracking-tight">{title}</h3>}
|
||||||
|
{subtitle && <p className="text-xs text-text-muted mt-0.5">{subtitle}</p>}
|
||||||
|
</div>
|
||||||
|
{action && <div>{action}</div>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="p-6">{children}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
|
label?: string;
|
||||||
|
unit?: string;
|
||||||
|
error?: string;
|
||||||
|
helperText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Input: React.FC<InputProps> = ({
|
||||||
|
label,
|
||||||
|
unit,
|
||||||
|
error,
|
||||||
|
helperText,
|
||||||
|
id,
|
||||||
|
className = '',
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
const inputId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full">
|
||||||
|
{label && (
|
||||||
|
<label htmlFor={inputId} className="block text-xs font-semibold uppercase tracking-wider text-text-muted mb-1.5">
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
<div className="relative rounded">
|
||||||
|
<input
|
||||||
|
id={inputId}
|
||||||
|
className={`w-full bg-white text-text-primary border ${
|
||||||
|
error ? 'border-error' : 'border-card-border'
|
||||||
|
} rounded px-3 py-2 text-sm focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20 transition ${
|
||||||
|
unit ? 'pr-14 font-mono' : ''
|
||||||
|
} ${className}`}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
{unit && (
|
||||||
|
<div className="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
||||||
|
<span className="font-mono text-xs text-text-muted">{unit}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{error && <p className="mt-1 text-xs text-error font-medium">{error}</p>}
|
||||||
|
{helperText && !error && <p className="mt-1 text-xs text-text-muted">{helperText}</p>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export interface StatusPillProps {
|
||||||
|
status: 'normal' | 'cleared' | 'watch' | 'pending' | 'danger' | 'error' | 'neutral';
|
||||||
|
label: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatusPill: React.FC<StatusPillProps> = ({ status, label, className = '' }) => {
|
||||||
|
const getStyles = () => {
|
||||||
|
switch (status) {
|
||||||
|
case 'normal':
|
||||||
|
case 'cleared':
|
||||||
|
return 'bg-status-normal-bg text-status-normal-text border-transparent';
|
||||||
|
case 'watch':
|
||||||
|
case 'pending':
|
||||||
|
return 'bg-status-watch-bg text-status-watch-text border-transparent';
|
||||||
|
case 'danger':
|
||||||
|
case 'error':
|
||||||
|
return 'bg-error-container text-error border-transparent';
|
||||||
|
case 'neutral':
|
||||||
|
default:
|
||||||
|
return 'bg-surface-container text-text-muted border-card-border';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`inline-flex items-center px-2 py-0.5 rounded-full text-[0.6875rem] font-semibold tracking-wider uppercase border ${getStyles()} ${className}`}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -1,60 +1,67 @@
|
||||||
/**
|
/**
|
||||||
* SCREEN-AUTH-002: Role Authorization & Access Denial View.
|
* SCREEN-AUTH-002: Role Authorization & Access Denial View.
|
||||||
*
|
*
|
||||||
* Fulfills FR-AUTH-002 & SCREEN-AUTH-002.md.
|
* Fulfills FR-AUTH-002 & SCREEN-AUTH-002.md (rebaselined under CR-002).
|
||||||
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { authStore } from '../../stores/authStore';
|
import { authStore } from '../../stores/authStore';
|
||||||
|
import { Card } from '../../components/ui/Card';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { ShieldAlert, ArrowLeft, LogOut } from 'lucide-react';
|
||||||
|
|
||||||
export const AccessDeniedView: React.FC = () => {
|
export const AccessDeniedView: React.FC = () => {
|
||||||
const user = authStore.getState().user;
|
const user = authStore.getState().user;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
<div className="min-h-screen flex items-center justify-center bg-surface text-on-surface p-4 font-sans">
|
||||||
<div className="max-w-lg w-full bg-slate-800 rounded-xl shadow-2xl p-8 border border-rose-500/30 text-center">
|
<div className="max-w-lg w-full bg-card-surface border border-card-border rounded p-8 shadow-none text-center">
|
||||||
<div className="inline-flex items-center justify-center w-16 h-16 rounded-full bg-rose-500/10 text-rose-400 mb-6">
|
<div className="inline-flex items-center justify-center w-12 h-12 rounded bg-error-container text-error mb-4">
|
||||||
<svg className="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<ShieldAlert className="w-6 h-6" />
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 className="text-3xl font-extrabold text-white mb-2">403 — Access Denied</h1>
|
<h1 className="text-xl font-bold tracking-tight text-text-primary mb-1">403 — Authorization Boundary Enforced</h1>
|
||||||
<p className="text-slate-400 text-sm mb-6">
|
<p className="text-text-muted text-xs mb-6 font-mono">
|
||||||
You do not have the required role permissions to access this screen or perform this business action.
|
Security policy prevents access to this screen or business action under your active role claims.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="bg-slate-900/60 rounded-lg p-4 mb-6 text-left border border-slate-700/60">
|
<div className="bg-surface-low rounded p-4 mb-6 text-left border border-card-border space-y-2">
|
||||||
<div className="text-xs uppercase font-semibold text-slate-400 mb-2">Security Enforcement Context</div>
|
<div className="text-[10px] uppercase font-semibold text-text-muted font-mono tracking-wider">
|
||||||
<div className="text-sm text-slate-300">
|
Security Enforcement Context
|
||||||
<span className="text-slate-400">Authenticated User:</span> {user?.email || 'Anonymous'}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="text-sm text-slate-300">
|
<div className="text-xs text-text-primary flex justify-between">
|
||||||
<span className="text-slate-400">Assigned Roles:</span>{' '}
|
<span className="text-text-muted">Authenticated Identity:</span>
|
||||||
<span className="text-emerald-400 font-medium">
|
<span className="font-mono font-medium">{user?.email || 'Anonymous'}</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-text-primary flex justify-between">
|
||||||
|
<span className="text-text-muted">Assigned Roles:</span>
|
||||||
|
<span className="font-mono font-semibold text-accent-ochre">
|
||||||
{user?.roles?.length ? user.roles.join(', ') : 'None'}
|
{user?.roles?.length ? user.roles.join(', ') : 'None'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-amber-400/90 mt-3 pt-3 border-t border-slate-800">
|
<div className="text-[11px] text-text-muted mt-3 pt-3 border-t border-card-border font-mono">
|
||||||
Mandatory Segregation of Duties (BRD-FR-040): Quality Officers cannot edit prices; Yard Supervisors cannot confirm sales; Sales Executives cannot override credit locks.
|
Mandatory Segregation of Duties (BRD-FR-040): Quality Officers cannot edit prices; Yard Supervisors cannot confirm sales; Sales Executives cannot override credit locks.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex space-x-3 justify-center">
|
<div className="flex space-x-3 justify-center">
|
||||||
<a
|
<a href="/">
|
||||||
href="/"
|
<Button variant="primary" size="sm" className="flex items-center space-x-1 font-mono">
|
||||||
className="py-2.5 px-5 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white font-medium text-sm transition-colors"
|
<ArrowLeft className="w-3.5 h-3.5 mr-1" />
|
||||||
>
|
<span>Return to Workspace</span>
|
||||||
Return to Dashboard
|
</Button>
|
||||||
</a>
|
</a>
|
||||||
<button
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
onClick={() => authStore.logout()}
|
onClick={() => authStore.logout()}
|
||||||
className="py-2.5 px-5 rounded-lg bg-slate-700 hover:bg-slate-600 text-slate-200 font-medium text-sm transition-colors"
|
className="flex items-center space-x-1 font-mono"
|
||||||
>
|
>
|
||||||
Switch Account
|
<LogOut className="w-3.5 h-3.5 mr-1" />
|
||||||
</button>
|
<span>Switch Account</span>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@
|
||||||
* OIDC Callback View Handler.
|
* OIDC Callback View Handler.
|
||||||
*
|
*
|
||||||
* Fulfills FR-AUTH-001 PKCE token exchange on callback.
|
* Fulfills FR-AUTH-001 PKCE token exchange on callback.
|
||||||
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { authStore } from '../../stores/authStore';
|
import { authStore } from '../../stores/authStore';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
|
||||||
export const CallbackView: React.FC = () => {
|
export const CallbackView: React.FC = () => {
|
||||||
const [status, setStatus] = useState<string>('Completing authentication...');
|
const [status, setStatus] = useState<string>('Completing authentication...');
|
||||||
|
|
@ -30,7 +32,7 @@ export const CallbackView: React.FC = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setStatus('Exchanging authorization code...');
|
setStatus('Exchanging authorization code with IdP...');
|
||||||
const tokenEndpoint = `${process.env.VITE_KEYCLOAK_URL || 'http://localhost:8080'}/realms/${process.env.VITE_KEYCLOAK_REALM || 'atb-realm'}/protocol/openid-connect/token`;
|
const tokenEndpoint = `${process.env.VITE_KEYCLOAK_URL || 'http://localhost:8080'}/realms/${process.env.VITE_KEYCLOAK_REALM || 'atb-realm'}/protocol/openid-connect/token`;
|
||||||
|
|
||||||
const bodyParams = new URLSearchParams({
|
const bodyParams = new URLSearchParams({
|
||||||
|
|
@ -61,22 +63,28 @@ export const CallbackView: React.FC = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!sessionResp.ok) {
|
if (!sessionResp.ok) {
|
||||||
throw new Error('Failed to initialize application session with backend.');
|
throw new Error('Failed to validate session token with application server.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionData = await sessionResp.json();
|
const sessionData = await sessionResp.json();
|
||||||
|
|
||||||
|
// Save session in zustand store
|
||||||
authStore.setSession(accessToken, {
|
authStore.setSession(accessToken, {
|
||||||
sub: sessionData.subject,
|
sub: sessionData.subject,
|
||||||
email: sessionData.email,
|
email: sessionData.email || 'user@trading.com',
|
||||||
name: sessionData.name,
|
name: sessionData.name || 'Trader',
|
||||||
roles: sessionData.roles || [],
|
roles: sessionData.roles || [],
|
||||||
tenant_id: sessionData.tenant_id,
|
tenant_id: sessionData.tenant_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clean up PKCE storage
|
||||||
|
sessionStorage.removeItem('pkce_code_verifier');
|
||||||
|
sessionStorage.removeItem('oauth_state');
|
||||||
|
|
||||||
// Redirect to dashboard
|
// Redirect to dashboard
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.message || 'Authentication callback failed.');
|
setError(err.message || 'Authentication failed unexpectedly.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -84,27 +92,25 @@ export const CallbackView: React.FC = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
<div className="min-h-screen flex items-center justify-center bg-surface text-on-surface p-4 font-sans">
|
||||||
<div className="max-w-md w-full bg-slate-800 rounded-xl p-8 border border-slate-700 text-center">
|
<div className="max-w-md w-full bg-card-surface rounded border border-card-border p-8 shadow-none text-center">
|
||||||
{error ? (
|
{error ? (
|
||||||
<div>
|
<div>
|
||||||
<div className="text-rose-400 font-semibold mb-2">Authentication Failed</div>
|
<div className="text-error font-semibold mb-2">Authentication Failed</div>
|
||||||
<p className="text-sm text-slate-300 mb-6">{error}</p>
|
<p className="text-xs text-text-muted mb-6 font-mono">{error}</p>
|
||||||
<a
|
<a href="/login">
|
||||||
href="/login"
|
<Button variant="primary" size="sm" className="font-mono">
|
||||||
className="inline-block py-2 px-4 rounded bg-emerald-600 hover:bg-emerald-500 text-white text-sm"
|
Return to Login
|
||||||
>
|
</Button>
|
||||||
Return to Login
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<div className="animate-spin rounded-full h-10 w-10 border-b-2 border-emerald-500 mx-auto mb-4"></div>
|
<div className="animate-spin rounded-full h-8 w-8 border-2 border-sidebar-surface border-t-accent-ochre mx-auto mb-4"></div>
|
||||||
<p className="text-sm text-slate-300">{status}</p>
|
<p className="text-xs text-text-primary font-mono">{status}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
/**
|
/**
|
||||||
* SCREEN-AUTH-001: Trading Portal Login & OIDC Callback View.
|
* SCREEN-AUTH-001: Trading Portal Login & OIDC Callback View.
|
||||||
*
|
*
|
||||||
* Fulfills FR-AUTH-001 & SCREEN-AUTH-001.md.
|
* Fulfills FR-AUTH-001 & SCREEN-AUTH-001.md (rebaselined under CR-002).
|
||||||
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { authStore } from '../../stores/authStore';
|
import { authStore } from '../../stores/authStore';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { Card } from '../../components/ui/Card';
|
||||||
|
import { ShieldCheck, LogIn, ChevronRight } from 'lucide-react';
|
||||||
|
|
||||||
export const LoginView: React.FC = () => {
|
export const LoginView: React.FC = () => {
|
||||||
const [selectedPersona, setSelectedPersona] = useState<string>('buyer@alpha.com');
|
const [selectedPersona, setSelectedPersona] = useState<string>('buyer@alpha.com');
|
||||||
|
|
@ -70,13 +74,6 @@ export const LoginView: React.FC = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
try {
|
try {
|
||||||
// Direct offline deterministic mock login
|
|
||||||
const res = await fetch(`http://localhost:8000/api/v1/auth/session`, {
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer mock_jwt_for_${selectedPersona}`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Set session directly in mock development mode
|
|
||||||
authStore.setSession(`mock_token_${selectedPersona}`, {
|
authStore.setSession(`mock_token_${selectedPersona}`, {
|
||||||
sub: `usr_${selectedPersona}`,
|
sub: `usr_${selectedPersona}`,
|
||||||
email: selectedPersona,
|
email: selectedPersona,
|
||||||
|
|
@ -96,70 +93,78 @@ export const LoginView: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
<div className="min-h-screen flex items-center justify-center bg-surface text-on-surface p-4 font-sans">
|
||||||
<div className="max-w-md w-full bg-slate-800 rounded-xl shadow-2xl p-8 border border-slate-700">
|
<div className="max-w-md w-full">
|
||||||
<div className="text-center mb-8">
|
{/* Main Card with AgriTrade Mercantile tactile styling */}
|
||||||
<div className="inline-flex items-center justify-center w-16 h-16 rounded-full bg-emerald-500/10 text-emerald-400 mb-4 font-bold text-2xl">
|
<div className="bg-card-surface border border-card-border rounded p-8 shadow-none">
|
||||||
ATB
|
{/* Header */}
|
||||||
</div>
|
<div className="text-center mb-8">
|
||||||
<h1 className="text-2xl font-bold tracking-tight text-white">Agriculture Trading Backoffice</h1>
|
<div className="inline-flex items-center justify-center w-12 h-12 rounded bg-sidebar-surface text-accent-ochre mb-3 shadow-none">
|
||||||
<p className="text-sm text-slate-400 mt-2">Sign in to your trading desk account</p>
|
<ShieldCheck className="w-6 h-6" />
|
||||||
</div>
|
|
||||||
|
|
||||||
{errorMessage && (
|
|
||||||
<div className="mb-6 p-4 rounded-lg bg-rose-500/10 border border-rose-500/20 text-rose-400 text-sm">
|
|
||||||
{errorMessage}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="space-y-4">
|
|
||||||
<button
|
|
||||||
onClick={handleKeycloakLogin}
|
|
||||||
disabled={isLoading}
|
|
||||||
className="w-full py-3 px-4 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white font-medium shadow-md transition-colors flex items-center justify-center space-x-2 disabled:opacity-50"
|
|
||||||
>
|
|
||||||
<span>{isLoading ? 'Redirecting...' : 'Sign In with Keycloak SSO'}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="relative my-6">
|
|
||||||
<div className="absolute inset-0 flex items-center">
|
|
||||||
<div className="w-full border-t border-slate-700"></div>
|
|
||||||
</div>
|
|
||||||
<div className="relative flex justify-center text-xs uppercase">
|
|
||||||
<span className="bg-slate-800 px-2 text-slate-400">Offline Sandbox / Dev Mode</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
<h1 className="text-xl font-bold tracking-tight text-text-primary">AgriTrade Mercantile</h1>
|
||||||
|
<p className="text-xs text-text-muted mt-1 uppercase tracking-wider font-mono">Wholesale Trading & Backoffice Desk</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-3">
|
{errorMessage && (
|
||||||
<label className="block text-xs font-medium text-slate-400">Select Test Persona:</label>
|
<div className="mb-6 p-3 rounded bg-status-watch-bg border-l-[3px] border-accent-ochre text-status-watch-text text-xs font-mono">
|
||||||
<select
|
{errorMessage}
|
||||||
value={selectedPersona}
|
</div>
|
||||||
onChange={(e) => setSelectedPersona(e.target.value)}
|
)}
|
||||||
className="w-full py-2.5 px-3 rounded-lg bg-slate-900 border border-slate-700 text-slate-200 text-sm focus:outline-none focus:border-emerald-500"
|
|
||||||
>
|
|
||||||
<option value="buyer@alpha.com">Ramesh Kumar — Mandi Buyer</option>
|
|
||||||
<option value="qc@alpha.com">Ananya Sharma — Quality Officer (SoD Restriced)</option>
|
|
||||||
<option value="yard@alpha.com">Vikram Singh — Yard Supervisor (SoD Restricted)</option>
|
|
||||||
<option value="sales@alpha.com">Rohit Verma — Sales Executive (SoD Restricted)</option>
|
|
||||||
<option value="finance@alpha.com">Kavita Joshi — Accounts Executive</option>
|
|
||||||
<option value="admin@alpha.com">Alpha Admin — Tenant Administrator</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button
|
<div className="space-y-4">
|
||||||
onClick={handleDevMockLogin}
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
onClick={handleKeycloakLogin}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
className="w-full py-2.5 px-4 rounded-lg bg-slate-700 hover:bg-slate-600 text-slate-200 text-sm font-medium transition-colors"
|
className="w-full py-2.5 flex items-center justify-center space-x-2 text-sm font-semibold tracking-wide"
|
||||||
>
|
>
|
||||||
Mock Authenticate (Offline)
|
<LogIn className="w-4 h-4 text-accent-ochre mr-1" />
|
||||||
</button>
|
<span>{isLoading ? 'Redirecting to OIDC...' : 'Sign In with Enterprise ID (Keycloak)'}</span>
|
||||||
</div>
|
</Button>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-8 text-center text-xs text-slate-500">
|
<div className="relative my-6">
|
||||||
(C) 2026 Agriculture Trading Backoffice. Multi-Tenant Enterprise Trading.
|
<div className="absolute inset-0 flex items-center">
|
||||||
|
<div className="w-full border-t border-card-border"></div>
|
||||||
|
</div>
|
||||||
|
<div className="relative flex justify-center text-[10px] uppercase tracking-wider font-mono">
|
||||||
|
<span className="bg-card-surface px-2 text-text-muted">Development Sandbox Mode</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
<label className="block text-[11px] font-semibold uppercase tracking-wider text-text-muted font-mono">
|
||||||
|
Select Test Persona:
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={selectedPersona}
|
||||||
|
onChange={(e) => setSelectedPersona(e.target.value)}
|
||||||
|
className="w-full py-2 px-3 rounded bg-white border border-card-border text-text-primary text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20 font-mono transition"
|
||||||
|
>
|
||||||
|
<option value="buyer@alpha.com">Ramesh Kumar — Mandi Buyer</option>
|
||||||
|
<option value="qc@alpha.com">Ananya Sharma — Quality Officer (SoD Restricted)</option>
|
||||||
|
<option value="yard@alpha.com">Vikram Singh — Yard Supervisor (SoD Restricted)</option>
|
||||||
|
<option value="sales@alpha.com">Rohit Verma — Sales Executive (SoD Restricted)</option>
|
||||||
|
<option value="finance@alpha.com">Kavita Joshi — Accounts Executive</option>
|
||||||
|
<option value="admin@alpha.com">Alpha Admin — Tenant Administrator</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={handleDevMockLogin}
|
||||||
|
disabled={isLoading}
|
||||||
|
className="w-full py-2 text-xs font-mono"
|
||||||
|
>
|
||||||
|
Mock Authenticate (Deterministic Offline)
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-8 pt-4 border-t border-card-border text-center text-[11px] text-text-muted font-mono">
|
||||||
|
Secure Multi-Tenant Context • UP-AI v1.5 Standard
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
/**
|
/**
|
||||||
* SCREEN-AUTH-003: Active Session Management & Logout View.
|
* SCREEN-AUTH-003: Active Session Management & Logout View.
|
||||||
*
|
*
|
||||||
* Fulfills FR-AUTH-003 & SCREEN-AUTH-003.md.
|
* Fulfills FR-AUTH-003 & SCREEN-AUTH-003.md (rebaselined under CR-002).
|
||||||
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { authStore } from '../../stores/authStore';
|
import { authStore } from '../../stores/authStore';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
|
import { Card } from '../../components/ui/Card';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { StatusPill } from '../../components/ui/StatusPill';
|
||||||
|
import { LogOut, ShieldCheck, KeyRound } from 'lucide-react';
|
||||||
|
|
||||||
export const SessionView: React.FC = () => {
|
export const SessionView: React.FC = () => {
|
||||||
const [isLoggingOut, setIsLoggingOut] = useState<boolean>(false);
|
const [isLoggingOut, setIsLoggingOut] = useState<boolean>(false);
|
||||||
|
|
@ -27,68 +32,75 @@ export const SessionView: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-2xl mx-auto p-6 bg-slate-800 rounded-xl border border-slate-700 text-slate-100 shadow-xl">
|
<div className="max-w-3xl mx-auto space-y-6">
|
||||||
<div className="border-b border-slate-700 pb-4 mb-6">
|
<Card
|
||||||
<h2 className="text-xl font-bold text-white">Active Session & Account Security</h2>
|
title="Active Session & Token Governance"
|
||||||
<p className="text-sm text-slate-400 mt-1">
|
subtitle="OIDC PKCE authentication token status and cryptographic subject claims (FR-AUTH-003)"
|
||||||
Review your current OIDC session details and terminate the session when finished.
|
action={
|
||||||
</p>
|
<StatusPill status="normal" label="Session Active" />
|
||||||
</div>
|
}
|
||||||
|
>
|
||||||
|
{message && (
|
||||||
|
<div className="mb-4 p-3 rounded bg-status-normal-bg text-status-normal-text border border-status-normal-text/20 text-xs font-mono">
|
||||||
|
{message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{message && (
|
<div className="divide-y divide-card-border mb-6">
|
||||||
<div className="mb-4 p-3 rounded bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm">
|
<div className="flex justify-between items-center py-3">
|
||||||
{message}
|
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Subject Identifier (`sub`):</span>
|
||||||
</div>
|
<span className="text-xs font-mono font-medium text-text-primary bg-surface-container px-2 py-0.5 rounded">{user?.sub || 'usr_buyer@alpha.com'}</span>
|
||||||
)}
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4 mb-8">
|
<div className="flex justify-between items-center py-3">
|
||||||
<div className="flex justify-between items-center py-2 border-b border-slate-700/60">
|
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Email Address:</span>
|
||||||
<span className="text-sm text-slate-400">Subject Identifier (`sub`):</span>
|
<span className="text-xs font-medium text-text-primary">{user?.email || 'buyer@alpha.com'}</span>
|
||||||
<span className="text-sm font-mono text-emerald-400">{user?.sub || 'N/A'}</span>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-between items-center py-2 border-b border-slate-700/60">
|
<div className="flex justify-between items-center py-3">
|
||||||
<span className="text-sm text-slate-400">Email Address:</span>
|
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Tenant Context:</span>
|
||||||
<span className="text-sm text-slate-200">{user?.email || 'N/A'}</span>
|
<span className="text-xs font-mono text-text-primary">{user?.tenant_id || 'tenant-alpha'}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-between items-center py-2 border-b border-slate-700/60">
|
<div className="py-3">
|
||||||
<span className="text-sm text-slate-400">Tenant Context:</span>
|
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono block mb-2">Effective RBAC Roles:</span>
|
||||||
<span className="text-sm text-slate-200">{user?.tenant_id || 'tenant-alpha'}</span>
|
<div className="flex flex-wrap gap-2">
|
||||||
</div>
|
{user?.roles?.map((role) => (
|
||||||
|
<span
|
||||||
|
key={role}
|
||||||
|
className="px-2.5 py-0.5 rounded-full text-[11px] font-mono font-medium bg-surface-container text-text-primary border border-card-border"
|
||||||
|
>
|
||||||
|
{role}
|
||||||
|
</span>
|
||||||
|
)) || <span className="text-xs text-text-muted font-mono">None</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="py-2 border-b border-slate-700/60">
|
<div className="flex justify-between items-center py-3">
|
||||||
<span className="text-sm text-slate-400 block mb-2">Assigned Roles:</span>
|
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Cryptographic Verification:</span>
|
||||||
<div className="flex flex-wrap gap-2">
|
<span className="inline-flex items-center text-xs font-mono text-status-normal-text">
|
||||||
{user?.roles?.map((role) => (
|
<ShieldCheck className="w-3.5 h-3.5 mr-1" />
|
||||||
<span
|
Verified S256 PKCE Code Challenge
|
||||||
key={role}
|
</span>
|
||||||
className="px-2.5 py-1 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-300 border border-emerald-500/20"
|
|
||||||
>
|
|
||||||
{role}
|
|
||||||
</span>
|
|
||||||
)) || <span className="text-xs text-slate-500">None</span>}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-between items-center py-2">
|
<div className="pt-4 border-t border-card-border flex justify-between items-center">
|
||||||
<span className="text-sm text-slate-400">Session Status:</span>
|
<p className="text-[11px] text-text-muted font-mono">
|
||||||
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-500/20 text-emerald-400">
|
Session revocation invalidates tokens immediately across trading desk endpoints.
|
||||||
● Active
|
</p>
|
||||||
</span>
|
<Button
|
||||||
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleLogout}
|
||||||
|
disabled={isLoggingOut}
|
||||||
|
className="flex items-center space-x-1.5 font-mono"
|
||||||
|
>
|
||||||
|
<LogOut className="w-3.5 h-3.5 mr-1" />
|
||||||
|
<span>{isLoggingOut ? 'Revoking...' : 'Terminate Session'}</span>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Card>
|
||||||
|
|
||||||
<div className="pt-4 border-t border-slate-700 flex justify-end">
|
|
||||||
<button
|
|
||||||
onClick={handleLogout}
|
|
||||||
disabled={isLoggingOut}
|
|
||||||
className="py-2.5 px-5 rounded-lg bg-rose-600 hover:bg-rose-500 text-white font-medium text-sm transition-colors disabled:opacity-50 flex items-center space-x-2"
|
|
||||||
>
|
|
||||||
<span>{isLoggingOut ? 'Ending Session...' : 'Log Out of Current Session'}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { tenantStore } from '../../stores/tenantStore';
|
import { tenantStore } from '../../stores/tenantStore';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
|
import { StatusPill } from '../../components/ui/StatusPill';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { FileText, Code2, Eye } from 'lucide-react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Immutable Transaction Audit Log Viewer Screen.
|
* Immutable Transaction Audit Log Viewer Screen.
|
||||||
*
|
*
|
||||||
* Fulfills FR-TENANTSECURITYAUDIT-003 (UC-017 / SCREEN-TENANT-004).
|
* Fulfills FR-TENANTSECURITYAUDIT-003 (UC-017 / SCREEN-TENANT-004).
|
||||||
* Provides read-only inspection of governed mutations and field-level diffs within the active tenant boundary.
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
export interface AuditEvent {
|
export interface AuditEvent {
|
||||||
audit_id: string;
|
audit_id: string;
|
||||||
|
|
@ -57,119 +60,119 @@ export const AuditLogView: React.FC = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getActionBadgeColor = (action: string) => {
|
const getActionStatus = (action: string): 'normal' | 'watch' | 'danger' | 'neutral' => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'CREATE': return 'bg-green-100 text-green-800';
|
case 'CREATE': return 'normal';
|
||||||
case 'UPDATE': return 'bg-blue-100 text-blue-800';
|
case 'UPDATE': return 'watch';
|
||||||
case 'STATUS_CHANGE': return 'bg-purple-100 text-purple-800';
|
case 'DELETE': return 'danger';
|
||||||
case 'DELETE': return 'bg-red-100 text-red-800';
|
case 'STATUS_CHANGE': return 'watch';
|
||||||
default: return 'bg-gray-100 text-gray-800';
|
default: return 'neutral';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8" data-testid="audit-log-view">
|
<div className="space-y-6" data-testid="audit-log-view">
|
||||||
<div className="sm:flex sm:items-center sm:justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Transaction Audit Trail</h1>
|
<h2 className="text-xl font-bold tracking-tight text-text-primary">Transaction Audit Trail</h2>
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||||
Immutable, append-only mutation ledger for <strong>{activeBusinessName || 'Active Enterprise'}</strong> (FR-TENANTSECURITYAUDIT-003).
|
Immutable, append-only mutation ledger for <strong>{activeBusinessName || 'Active Enterprise'}</strong> (FR-TENANTSECURITYAUDIT-003)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 sm:mt-0">
|
<span className="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-mono font-medium bg-status-normal-bg text-status-normal-text border border-status-normal-text/20">
|
||||||
<span className="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-emerald-50 text-emerald-700 border border-emerald-200">
|
Append-Only Statutory Ledger
|
||||||
Append-Only Statutory Ledger
|
</span>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||||
<p className="text-sm text-red-700">{error}</p>
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Audit Log Table */}
|
{/* Audit Log Table adhering to DESIGN.md */}
|
||||||
<div className="mt-8 flex flex-col">
|
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
<table className="min-w-full divide-y divide-card-border">
|
||||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
<thead className="bg-surface-low">
|
||||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
<tr>
|
||||||
<table className="min-w-full divide-y divide-gray-300">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Timestamp (UTC)</th>
|
||||||
<thead className="bg-gray-50">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Action</th>
|
||||||
<tr>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Entity Type</th>
|
||||||
<th className="py-3.5 pl-4 pr-3 text-left text-xs font-semibold text-gray-900 sm:pl-6">Timestamp (UTC)</th>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Entity ID</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Action</th>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Actor Subject</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Entity Type</th>
|
<th className="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Payload Diff</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Entity ID</th>
|
</tr>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Actor Subject</th>
|
</thead>
|
||||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Details</span></th>
|
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||||
</tr>
|
{events.length === 0 ? (
|
||||||
</thead>
|
<tr>
|
||||||
<tbody className="divide-y divide-gray-200 bg-white">
|
<td colSpan={6} className="py-8 text-center text-xs text-text-muted font-mono">
|
||||||
{events.length === 0 ? (
|
No governed audit events recorded for this enterprise.
|
||||||
<tr>
|
</td>
|
||||||
<td colSpan={6} className="py-8 text-center text-sm text-gray-500">
|
</tr>
|
||||||
No audit events recorded for this enterprise.
|
) : (
|
||||||
</td>
|
events.map((e) => (
|
||||||
</tr>
|
<tr key={e.audit_id} className="hover:bg-surface-bright transition-colors">
|
||||||
) : (
|
<td className="py-3.5 px-4 font-mono text-text-muted">
|
||||||
events.map((e) => (
|
{new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)}
|
||||||
<tr key={e.audit_id}>
|
</td>
|
||||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-gray-500 font-mono sm:pl-6">
|
<td className="py-3.5 px-4">
|
||||||
{new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)}
|
<StatusPill
|
||||||
</td>
|
status={getActionStatus(e.action)}
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm">
|
label={e.action}
|
||||||
<span className={`inline-flex px-2 text-xs font-semibold leading-5 rounded-full ${getActionBadgeColor(e.action)}`}>
|
/>
|
||||||
{e.action}
|
</td>
|
||||||
</span>
|
<td className="py-3.5 px-4 font-medium text-text-primary">{e.entity_type}</td>
|
||||||
</td>
|
<td className="py-3.5 px-4 font-mono text-text-muted">{e.entity_id}</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm font-medium text-gray-900">{e.entity_type}</td>
|
<td className="py-3.5 px-4 font-mono text-text-muted">{e.actor_id}</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{e.entity_id}</td>
|
<td className="py-3.5 px-4 text-right font-mono">
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{e.actor_id}</td>
|
<button
|
||||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
onClick={() => setSelectedEvent(e)}
|
||||||
<button
|
className="inline-flex items-center space-x-1 text-xs text-text-primary hover:text-accent-ochre font-medium underline underline-offset-2 transition"
|
||||||
onClick={() => setSelectedEvent(e)}
|
>
|
||||||
className="text-emerald-600 hover:text-emerald-900"
|
<Eye className="w-3 h-3" />
|
||||||
>
|
<span>Inspect</span>
|
||||||
Inspect Diff
|
</button>
|
||||||
</button>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
))
|
||||||
))
|
)}
|
||||||
)}
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* JSON Diff Inspection Modal */}
|
{/* JSON Diff Inspection Modal */}
|
||||||
{selectedEvent && (
|
{selectedEvent && (
|
||||||
<div className="fixed z-10 inset-0 overflow-y-auto">
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
||||||
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:block sm:p-0">
|
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:p-0">
|
||||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" onClick={() => setSelectedEvent(null)} />
|
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setSelectedEvent(null)} />
|
||||||
<div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-2xl sm:w-full sm:p-6">
|
<div className="inline-block bg-card-surface rounded border border-card-border p-6 text-left overflow-hidden shadow-tactile transform transition-all sm:max-w-xl sm:w-full z-10">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between pb-3 border-b border-card-border">
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
<div>
|
||||||
Audit Mutation Diff: {selectedEvent.entity_type} ({selectedEvent.action})
|
<h3 className="text-sm font-bold text-text-primary tracking-tight">
|
||||||
</h3>
|
Mutation Diff: {selectedEvent.entity_type}
|
||||||
<span className="text-xs font-mono text-gray-400">{selectedEvent.audit_id}</span>
|
</h3>
|
||||||
|
<p className="text-[11px] text-text-muted font-mono mt-0.5">
|
||||||
|
Actor: <span className="font-semibold text-text-primary">{selectedEvent.actor_id}</span> | {selectedEvent.timestamp}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<StatusPill status={getActionStatus(selectedEvent.action)} label={selectedEvent.action} />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 text-xs text-gray-500">
|
|
||||||
Actor: <span className="font-mono text-gray-800">{selectedEvent.actor_id}</span> | Time: {selectedEvent.timestamp}
|
<div className="mt-4 bg-surface-low rounded border border-card-border p-3 overflow-x-auto text-text-primary font-mono text-xs">
|
||||||
|
<pre className="text-[11px] leading-relaxed">{JSON.stringify(selectedEvent.field_diff, null, 2)}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 bg-gray-900 rounded-md p-4 overflow-x-auto text-emerald-400 font-mono text-xs">
|
|
||||||
<pre>{JSON.stringify(selectedEvent.field_diff, null, 2)}</pre>
|
<div className="mt-4 pt-3 border-t border-card-border flex justify-end">
|
||||||
</div>
|
<Button
|
||||||
<div className="mt-5 sm:flex sm:flex-row-reverse">
|
|
||||||
<button
|
|
||||||
type="button"
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
onClick={() => setSelectedEvent(null)}
|
onClick={() => setSelectedEvent(null)}
|
||||||
className="w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 sm:ml-3 sm:w-auto sm:text-sm"
|
className="font-mono"
|
||||||
>
|
>
|
||||||
Close
|
Close Inspection
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -178,4 +181,3 @@ export const AuditLogView: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { tenantStore, TenantMembershipInfo } from '../../stores/tenantStore';
|
import { tenantStore, TenantMembershipInfo } from '../../stores/tenantStore';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
|
import { Building2, ChevronDown } from 'lucide-react';
|
||||||
|
import { StatusPill } from '../../components/ui/StatusPill';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header Tenant Switcher Dropdown Component.
|
* Header Tenant Switcher Dropdown Component.
|
||||||
*
|
*
|
||||||
* Fulfills FR-TENANTMEMBERSHIPCONTEXT-002 (UC-019 / SCREEN-TENANT-003).
|
* Fulfills FR-TENANTMEMBERSHIPCONTEXT-002 (UC-019 / SCREEN-TENANT-003).
|
||||||
* Enables multi-firm trading personas to view active firm context and switch seamlessly.
|
* Styled per DESIGN.md: AgriTrade Mercantile tokens.
|
||||||
*/
|
*/
|
||||||
export const HeaderTenantSwitcher: React.FC = () => {
|
export const HeaderTenantSwitcher: React.FC = () => {
|
||||||
const [activeTenantId, setActiveTenantId] = useState<string | null>(tenantStore.getState().activeTenantId);
|
const [activeTenantId, setActiveTenantId] = useState<string | null>(tenantStore.getState().activeTenantId);
|
||||||
|
|
@ -26,7 +28,6 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
||||||
setMyTenants(state.myTenants);
|
setMyTenants(state.myTenants);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load user's accessible tenants on mount
|
|
||||||
loadTenants();
|
loadTenants();
|
||||||
|
|
||||||
return () => unsubscribe();
|
return () => unsubscribe();
|
||||||
|
|
@ -38,7 +39,6 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
if (resp.data && resp.data.tenants) {
|
if (resp.data && resp.data.tenants) {
|
||||||
tenantStore.setMyTenants(resp.data.tenants);
|
tenantStore.setMyTenants(resp.data.tenants);
|
||||||
// Auto-select first active tenant if none selected
|
|
||||||
if (!tenantStore.getState().activeTenantId && resp.data.tenants.length > 0) {
|
if (!tenantStore.getState().activeTenantId && resp.data.tenants.length > 0) {
|
||||||
const first = resp.data.tenants[0];
|
const first = resp.data.tenants[0];
|
||||||
handleSwitch(first.tenant_id, first.business_name, [first.role]);
|
handleSwitch(first.tenant_id, first.business_name, [first.role]);
|
||||||
|
|
@ -70,54 +70,62 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
className="inline-flex items-center justify-between w-64 rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500"
|
className="inline-flex items-center justify-between w-64 rounded border border-card-border px-3 py-1.5 bg-white hover:bg-surface-low focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20 transition shadow-none"
|
||||||
id="tenant-menu-button"
|
id="tenant-menu-button"
|
||||||
aria-expanded={isOpen}
|
aria-expanded={isOpen}
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col text-left truncate mr-2">
|
<div className="flex items-center space-x-2 truncate mr-2">
|
||||||
<span className="text-xs text-gray-400 uppercase tracking-wider font-semibold">Active Enterprise</span>
|
<Building2 className="w-4 h-4 text-text-muted flex-shrink-0" />
|
||||||
<span className="font-semibold text-gray-900 truncate">
|
<div className="flex flex-col text-left truncate">
|
||||||
{activeBusinessName || 'Select Enterprise...'}
|
<span className="text-[10px] text-text-muted uppercase tracking-wider font-mono font-semibold">Active Firm</span>
|
||||||
</span>
|
<span className="font-semibold text-xs text-text-primary truncate">
|
||||||
|
{activeBusinessName || 'Select Trading Firm...'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-1 flex-shrink-0">
|
||||||
|
<span className="inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-mono font-medium bg-status-normal-bg text-status-normal-text">
|
||||||
|
{effectiveRoles[0] || 'Member'}
|
||||||
|
</span>
|
||||||
|
<ChevronDown className="w-3.5 h-3.5 text-text-muted" />
|
||||||
</div>
|
</div>
|
||||||
<span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-emerald-100 text-emerald-800">
|
|
||||||
{effectiveRoles[0] || 'Member'}
|
|
||||||
</span>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isOpen && (
|
{isOpen && (
|
||||||
<div
|
<div
|
||||||
className="origin-top-right absolute right-0 mt-2 w-72 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50 divide-y divide-gray-100"
|
className="origin-top-right absolute right-0 mt-1.5 w-72 rounded bg-card-surface border border-card-border shadow-tactile focus:outline-none z-50 divide-y divide-card-border"
|
||||||
role="menu"
|
role="menu"
|
||||||
aria-orientation="vertical"
|
aria-orientation="vertical"
|
||||||
aria-labelledby="tenant-menu-button"
|
aria-labelledby="tenant-menu-button"
|
||||||
>
|
>
|
||||||
<div className="px-4 py-3">
|
<div className="px-4 py-2.5 bg-surface-low">
|
||||||
<p className="text-xs text-gray-500 uppercase tracking-wider font-semibold">Trading Firms Directory</p>
|
<p className="text-[10px] text-text-muted uppercase tracking-wider font-mono font-semibold">Authorized Firms Directory</p>
|
||||||
{error && <p className="text-xs text-red-600 mt-1">{error}</p>}
|
{error && <p className="text-xs text-error mt-1">{error}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="py-1 max-h-60 overflow-y-auto" role="none">
|
<div className="py-1 max-h-60 overflow-y-auto" role="none">
|
||||||
{myTenants.length === 0 ? (
|
{myTenants.length === 0 ? (
|
||||||
<div className="px-4 py-2 text-xs text-gray-500">No authorized enterprises found.</div>
|
<div className="px-4 py-2 text-xs text-text-muted font-mono">No authorized enterprises found.</div>
|
||||||
) : (
|
) : (
|
||||||
myTenants.map((t) => (
|
myTenants.map((t) => (
|
||||||
<button
|
<button
|
||||||
key={t.membership_id}
|
key={t.membership_id}
|
||||||
onClick={() => handleSwitch(t.tenant_id, t.business_name, [t.role])}
|
onClick={() => handleSwitch(t.tenant_id, t.business_name, [t.role])}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className={`w-full text-left px-4 py-2.5 text-sm hover:bg-gray-50 flex items-center justify-between transition-colors ${
|
className={`w-full text-left px-4 py-2.5 text-xs hover:bg-surface-low flex items-center justify-between transition-colors ${
|
||||||
t.tenant_id === activeTenantId ? 'bg-emerald-50 text-emerald-900 font-semibold' : 'text-gray-700'
|
t.tenant_id === activeTenantId
|
||||||
|
? 'bg-status-normal-bg/40 text-text-primary font-semibold border-l-2 border-accent-ochre'
|
||||||
|
: 'text-text-primary'
|
||||||
}`}
|
}`}
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
>
|
>
|
||||||
<div className="truncate pr-2">
|
<div className="truncate pr-2">
|
||||||
<p className="font-medium truncate">{t.business_name}</p>
|
<p className="font-medium truncate">{t.business_name}</p>
|
||||||
<p className="text-xs text-gray-400 font-mono">{t.legal_identifier}</p>
|
<p className="text-[10px] text-text-muted font-mono">{t.legal_identifier}</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-normal bg-gray-100 text-gray-600">
|
<span className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-mono bg-surface-container text-text-muted">
|
||||||
{t.role}
|
{t.role}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -129,4 +137,3 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { StatusPill } from '../../components/ui/StatusPill';
|
||||||
|
import { Plus, Building2, SlidersHorizontal } from 'lucide-react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform Tenants Management View.
|
* Platform Tenants Management View.
|
||||||
*
|
*
|
||||||
* Fulfills FR-TENANTLIFECYCLE-001 (UC-018 / SCREEN-TENANT-001).
|
* Fulfills FR-TENANTLIFECYCLE-001 (UC-018 / SCREEN-TENANT-001).
|
||||||
* System Administrator control plane to provision firms and manage lifecycle status.
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
export interface PlatformTenant {
|
export interface PlatformTenant {
|
||||||
tenant_id: string;
|
tenant_id: string;
|
||||||
|
|
@ -82,6 +85,7 @@ export const PlatformTenantsView: React.FC = () => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
setSelectedTenant(null);
|
setSelectedTenant(null);
|
||||||
|
setStatusReason('');
|
||||||
fetchTenants();
|
fetchTenants();
|
||||||
} else {
|
} else {
|
||||||
setError(resp.error || 'Failed to update tenant status.');
|
setError(resp.error || 'Failed to update tenant status.');
|
||||||
|
|
@ -89,153 +93,144 @@ export const PlatformTenantsView: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8" data-testid="platform-tenants-view">
|
<div className="space-y-6" data-testid="platform-tenants-view">
|
||||||
<div className="sm:flex sm:items-center sm:justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Platform Enterprise Directory</h1>
|
<h2 className="text-xl font-bold tracking-tight text-text-primary">Platform Trading Enterprises</h2>
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||||
Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001).
|
Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 sm:mt-0">
|
<Button
|
||||||
<button
|
variant="primary"
|
||||||
type="button"
|
size="sm"
|
||||||
onClick={() => setShowModal(true)}
|
onClick={() => setShowModal(true)}
|
||||||
className="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500"
|
className="flex items-center space-x-1.5 font-mono"
|
||||||
>
|
>
|
||||||
Provision Enterprise
|
<Plus className="w-3.5 h-3.5 mr-1 text-accent-ochre" />
|
||||||
</button>
|
<span>Provision Enterprise</span>
|
||||||
</div>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||||
<p className="text-sm text-red-700">{error}</p>
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Directory Table */}
|
{/* Directory Table adhering to DESIGN.md tabular rules */}
|
||||||
<div className="mt-8 flex flex-col">
|
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
<table className="min-w-full divide-y divide-card-border">
|
||||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
<thead className="bg-surface-low">
|
||||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
<tr>
|
||||||
<table className="min-w-full divide-y divide-gray-300">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Trading Enterprise</th>
|
||||||
<thead className="bg-gray-50">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Legal GSTIN</th>
|
||||||
<tr>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Primary Mandi</th>
|
||||||
<th className="py-3.5 pl-4 pr-3 text-left text-xs font-semibold text-gray-900 sm:pl-6">Business Name</th>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Contact Email</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Legal GSTIN</th>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Lifecycle Status</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Primary Mandi</th>
|
<th className="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Actions</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Contact Email</th>
|
</tr>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Lifecycle Status</th>
|
</thead>
|
||||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Actions</span></th>
|
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||||
</tr>
|
{tenants.map((t) => (
|
||||||
</thead>
|
<tr key={t.tenant_id} className="hover:bg-surface-bright transition-colors">
|
||||||
<tbody className="divide-y divide-gray-200 bg-white">
|
<td className="py-3.5 px-4 font-semibold text-text-primary">{t.business_name}</td>
|
||||||
{tenants.map((t) => (
|
<td className="py-3.5 px-4 font-mono text-text-muted">{t.legal_identifier}</td>
|
||||||
<tr key={t.tenant_id}>
|
<td className="py-3.5 px-4 font-mono text-text-primary">{t.primary_mandi}</td>
|
||||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">{t.business_name}</td>
|
<td className="py-3.5 px-4 text-text-muted">{t.contact_email}</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{t.legal_identifier}</td>
|
<td className="py-3.5 px-4">
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{t.primary_mandi}</td>
|
<StatusPill
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{t.contact_email}</td>
|
status={t.status === 'ACTIVE' ? 'normal' : t.status === 'SUSPENDED' ? 'watch' : 'neutral'}
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
label={t.status}
|
||||||
<span className={`inline-flex px-2 text-xs font-semibold leading-5 rounded-full ${
|
/>
|
||||||
t.status === 'ACTIVE' ? 'bg-green-100 text-green-800' :
|
</td>
|
||||||
t.status === 'SUSPENDED' ? 'bg-yellow-100 text-yellow-800' : 'bg-red-100 text-red-800'
|
<td className="py-3.5 px-4 text-right font-mono">
|
||||||
}`}>
|
{t.status !== 'CLOSED' && (
|
||||||
{t.status}
|
<button
|
||||||
</span>
|
onClick={() => { setSelectedTenant(t); setNewStatus(t.status === 'ACTIVE' ? 'SUSPENDED' : 'ACTIVE'); }}
|
||||||
</td>
|
className="text-xs text-text-primary hover:text-accent-ochre font-medium underline underline-offset-2 transition"
|
||||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
>
|
||||||
{t.status !== 'CLOSED' && (
|
Update State
|
||||||
<button
|
</button>
|
||||||
onClick={() => { setSelectedTenant(t); setNewStatus(t.status === 'ACTIVE' ? 'SUSPENDED' : 'ACTIVE'); }}
|
)}
|
||||||
className="text-emerald-600 hover:text-emerald-900 mr-4"
|
</td>
|
||||||
>
|
</tr>
|
||||||
Update Status
|
))}
|
||||||
</button>
|
</tbody>
|
||||||
)}
|
</table>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Provision Modal */}
|
{/* Provision Modal */}
|
||||||
{showModal && (
|
{showModal && (
|
||||||
<div className="fixed z-10 inset-0 overflow-y-auto">
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
||||||
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:block sm:p-0">
|
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:p-0">
|
||||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" onClick={() => setShowModal(false)} />
|
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setShowModal(false)} />
|
||||||
<div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6">
|
<div className="inline-block bg-card-surface rounded border border-card-border p-6 text-left overflow-hidden shadow-tactile transform transition-all sm:max-w-md sm:w-full z-10">
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Provision New Enterprise</h3>
|
<h3 className="text-base font-bold text-text-primary tracking-tight">Provision New Trading Enterprise</h3>
|
||||||
<form onSubmit={handleCreate} className="mt-4 space-y-4">
|
<p className="text-xs text-text-muted mt-0.5 font-mono">Registers enterprise entity within row-level multi-tenant database boundary</p>
|
||||||
|
|
||||||
|
<form onSubmit={handleCreate} className="mt-4 space-y-3.5">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Business Legal Name</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Business Legal Name</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={formData.business_name}
|
value={formData.business_name}
|
||||||
onChange={(e) => setFormData({ ...formData, business_name: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, business_name: e.target.value })}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="e.g. Rameshwaram Grain Mercantile Pvt Ltd"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Legal Identifier / GSTIN</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Legal Identifier / GSTIN</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={formData.legal_identifier}
|
value={formData.legal_identifier}
|
||||||
onChange={(e) => setFormData({ ...formData, legal_identifier: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, legal_identifier: e.target.value })}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs font-mono focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="23AAAAA0000A1Z5"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Primary Mandi APMC Code</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Primary Mandi APMC Hub</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={formData.primary_mandi}
|
value={formData.primary_mandi}
|
||||||
onChange={(e) => setFormData({ ...formData, primary_mandi: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, primary_mandi: e.target.value })}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs font-mono focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="APMC-INDORE"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Enterprise Contact Email</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Corporate Contact Email</label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
required
|
required
|
||||||
value={formData.contact_email}
|
value={formData.contact_email}
|
||||||
onChange={(e) => setFormData({ ...formData, contact_email: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, contact_email: e.target.value })}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="ops@rameshwaramgrain.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Initial Tenant Administrator Email</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Initial Tenant Administrator Email</label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
value={formData.initial_admin_email}
|
value={formData.initial_admin_email}
|
||||||
onChange={(e) => setFormData({ ...formData, initial_admin_email: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, initial_admin_email: e.target.value })}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="admin@rameshwaramgrain.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5 sm:mt-6 sm:grid sm:grid-cols-2 sm:gap-3">
|
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||||
<button
|
<Button type="button" variant="secondary" size="sm" onClick={() => setShowModal(false)}>
|
||||||
type="button"
|
|
||||||
onClick={() => setShowModal(false)}
|
|
||||||
className="w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 sm:text-sm"
|
|
||||||
>
|
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="submit" variant="primary" size="sm" disabled={loading}>
|
||||||
type="submit"
|
Provision Enterprise
|
||||||
disabled={loading}
|
</Button>
|
||||||
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-emerald-600 text-base font-medium text-white hover:bg-emerald-700 sm:text-sm"
|
|
||||||
>
|
|
||||||
Provision
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -245,21 +240,21 @@ export const PlatformTenantsView: React.FC = () => {
|
||||||
|
|
||||||
{/* Status Change Dialog */}
|
{/* Status Change Dialog */}
|
||||||
{selectedTenant && (
|
{selectedTenant && (
|
||||||
<div className="fixed z-10 inset-0 overflow-y-auto">
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
||||||
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:block sm:p-0">
|
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:p-0">
|
||||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" onClick={() => setSelectedTenant(null)} />
|
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setSelectedTenant(null)} />
|
||||||
<div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full sm:p-6">
|
<div className="inline-block bg-card-surface rounded border border-card-border p-6 text-left overflow-hidden shadow-tactile transform transition-all sm:max-w-md sm:w-full z-10">
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Update Tenant Status</h3>
|
<h3 className="text-base font-bold text-text-primary tracking-tight">Update Lifecycle Status</h3>
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||||
Updating status for <strong>{selectedTenant.business_name}</strong> ({selectedTenant.status}).
|
Modifying state for <strong>{selectedTenant.business_name}</strong>
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-4 space-y-4">
|
<div className="mt-4 space-y-3.5">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Target Lifecycle Status</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Target Lifecycle State</label>
|
||||||
<select
|
<select
|
||||||
value={newStatus}
|
value={newStatus}
|
||||||
onChange={(e) => setNewStatus(e.target.value)}
|
onChange={(e) => setNewStatus(e.target.value)}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs font-mono focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
>
|
>
|
||||||
<option value="ACTIVE">ACTIVE</option>
|
<option value="ACTIVE">ACTIVE</option>
|
||||||
<option value="SUSPENDED">SUSPENDED</option>
|
<option value="SUSPENDED">SUSPENDED</option>
|
||||||
|
|
@ -267,30 +262,22 @@ export const PlatformTenantsView: React.FC = () => {
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Reason / Statutory Justification</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">Statutory Justification / Audit Note</label>
|
||||||
<textarea
|
<textarea
|
||||||
rows={2}
|
rows={2}
|
||||||
value={statusReason}
|
value={statusReason}
|
||||||
onChange={(e) => setStatusReason(e.target.value)}
|
onChange={(e) => setStatusReason(e.target.value)}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
|
placeholder="Enter compliance or audit reasoning..."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5 sm:grid sm:grid-cols-2 sm:gap-3">
|
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||||
<button
|
<Button type="button" variant="secondary" size="sm" onClick={() => setSelectedTenant(null)}>
|
||||||
type="button"
|
|
||||||
onClick={() => setSelectedTenant(null)}
|
|
||||||
className="w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 sm:text-sm"
|
|
||||||
>
|
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="button" variant="accent" size="sm" onClick={handleUpdateStatus} disabled={loading}>
|
||||||
type="button"
|
|
||||||
onClick={handleUpdateStatus}
|
|
||||||
disabled={loading}
|
|
||||||
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-emerald-600 text-base font-medium text-white hover:bg-emerald-700 sm:text-sm"
|
|
||||||
>
|
|
||||||
Save Transition
|
Save Transition
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -300,4 +287,3 @@ export const PlatformTenantsView: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { tenantStore } from '../../stores/tenantStore';
|
import { tenantStore } from '../../stores/tenantStore';
|
||||||
import { apiClient } from '../../services/api';
|
import { apiClient } from '../../services/api';
|
||||||
|
import { Button } from '../../components/ui/Button';
|
||||||
|
import { StatusPill } from '../../components/ui/StatusPill';
|
||||||
|
import { UserPlus, UserCheck, Shield } from 'lucide-react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenant Members & Roles Management View.
|
* Tenant Members & Roles Management View.
|
||||||
*
|
*
|
||||||
* Fulfills FR-TENANTMEMBERSHIPCONTEXT-001 (UC-019 / SCREEN-TENANT-002).
|
* Fulfills FR-TENANTMEMBERSHIPCONTEXT-001 (UC-019 / SCREEN-TENANT-002).
|
||||||
* Enables Tenant Administrators to manage user memberships within their tenant boundary.
|
* Styled per DESIGN.md: AgriTrade Mercantile (Tactile Corporate Minimalism).
|
||||||
*/
|
*/
|
||||||
export interface Member {
|
export interface Member {
|
||||||
membership_id: string;
|
membership_id: string;
|
||||||
|
|
@ -66,11 +69,11 @@ export const TenantMembersView: React.FC = () => {
|
||||||
if (resp.status === 200 && resp.data?.memberships) {
|
if (resp.status === 200 && resp.data?.memberships) {
|
||||||
setMembers(resp.data.memberships);
|
setMembers(resp.data.memberships);
|
||||||
} else {
|
} else {
|
||||||
setError(resp.error || 'Failed to load member roster.');
|
setError(resp.error || 'Failed to fetch tenant memberships.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInvite = async (e: React.FormEvent) => {
|
const handleAssignRole = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!activeTenantId) return;
|
if (!activeTenantId) return;
|
||||||
|
|
||||||
|
|
@ -111,131 +114,120 @@ export const TenantMembersView: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8" data-testid="tenant-members-view">
|
<div className="space-y-6" data-testid="tenant-members-view">
|
||||||
<div className="sm:flex sm:items-center sm:justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Enterprise Members & Roles</h1>
|
<h2 className="text-xl font-bold tracking-tight text-text-primary">Enterprise Members & Roles</h2>
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||||
Governed member roster for <strong>{activeBusinessName || 'Active Firm'}</strong> (FR-TENANTMEMBERSHIPCONTEXT-001).
|
Governed member roster for <strong>{activeBusinessName || 'Active Firm'}</strong> (FR-TENANTMEMBERSHIPCONTEXT-001)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 sm:mt-0">
|
<Button
|
||||||
<button
|
variant="primary"
|
||||||
type="button"
|
size="sm"
|
||||||
onClick={() => setShowInviteModal(true)}
|
onClick={() => setShowInviteModal(true)}
|
||||||
disabled={!activeTenantId}
|
disabled={!activeTenantId}
|
||||||
className="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500 disabled:opacity-50"
|
className="flex items-center space-x-1.5 font-mono"
|
||||||
>
|
>
|
||||||
Assign Member Role
|
<UserPlus className="w-3.5 h-3.5 mr-1 text-accent-ochre" />
|
||||||
</button>
|
<span>Assign Member Role</span>
|
||||||
</div>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||||
<p className="text-sm text-red-700">{error}</p>
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Members Table */}
|
{/* Members Table */}
|
||||||
<div className="mt-8 flex flex-col">
|
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
<table className="min-w-full divide-y divide-card-border">
|
||||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
<thead className="bg-surface-low">
|
||||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
<tr>
|
||||||
<table className="min-w-full divide-y divide-gray-300">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Member Account</th>
|
||||||
<thead className="bg-gray-50">
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">PRD Business Role</th>
|
||||||
<tr>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Membership Status</th>
|
||||||
<th className="py-3.5 pl-4 pr-3 text-left text-xs font-semibold text-gray-900 sm:pl-6">Member Email</th>
|
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Effective Since</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">PRD Business Role</th>
|
<th className="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Actions</th>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Membership Status</th>
|
</tr>
|
||||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Added Date</th>
|
</thead>
|
||||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Actions</span></th>
|
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||||
</tr>
|
{members.map((m) => (
|
||||||
</thead>
|
<tr key={m.membership_id} className="hover:bg-surface-bright transition-colors">
|
||||||
<tbody className="divide-y divide-gray-200 bg-white">
|
<td className="py-3.5 px-4 font-medium text-text-primary">{m.email}</td>
|
||||||
{members.map((m) => (
|
<td className="py-3.5 px-4">
|
||||||
<tr key={m.membership_id}>
|
<span className="inline-flex items-center px-2 py-0.5 rounded text-[11px] font-mono font-medium bg-surface-container text-text-primary border border-card-border">
|
||||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">{m.email}</td>
|
{m.role}
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-700">
|
</span>
|
||||||
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
|
</td>
|
||||||
{m.role}
|
<td className="py-3.5 px-4">
|
||||||
</span>
|
<StatusPill
|
||||||
</td>
|
status={m.status === 'ACTIVE' ? 'normal' : 'danger'}
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
label={m.status}
|
||||||
<span className={`inline-flex px-2 text-xs font-semibold leading-5 rounded-full ${
|
/>
|
||||||
m.status === 'ACTIVE' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'
|
</td>
|
||||||
}`}>
|
<td className="py-3.5 px-4 font-mono text-text-muted">
|
||||||
{m.status}
|
{new Date(m.created_at).toLocaleDateString()}
|
||||||
</span>
|
</td>
|
||||||
</td>
|
<td className="py-3.5 px-4 text-right font-mono">
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
{m.status === 'ACTIVE' && (
|
||||||
{new Date(m.created_at).toLocaleDateString()}
|
<button
|
||||||
</td>
|
onClick={() => handleRevoke(m.membership_id)}
|
||||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
className="text-xs text-error hover:text-red-900 font-medium underline underline-offset-2 transition"
|
||||||
{m.status === 'ACTIVE' && (
|
>
|
||||||
<button
|
Revoke Role
|
||||||
onClick={() => handleRevoke(m.membership_id)}
|
</button>
|
||||||
className="text-red-600 hover:text-red-900"
|
)}
|
||||||
>
|
</td>
|
||||||
Revoke Access
|
</tr>
|
||||||
</button>
|
))}
|
||||||
)}
|
</tbody>
|
||||||
</td>
|
</table>
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Invite Member Modal */}
|
{/* Assign Role Modal */}
|
||||||
{showInviteModal && (
|
{showInviteModal && (
|
||||||
<div className="fixed z-10 inset-0 overflow-y-auto">
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
||||||
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:block sm:p-0">
|
<div className="flex items-center justify-center min-h-screen px-4 text-center sm:p-0">
|
||||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" onClick={() => setShowInviteModal(false)} />
|
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setShowInviteModal(false)} />
|
||||||
<div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full sm:p-6">
|
<div className="inline-block bg-card-surface rounded border border-card-border p-6 text-left overflow-hidden shadow-tactile transform transition-all sm:max-w-md sm:w-full z-10">
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Assign Enterprise Role</h3>
|
<h3 className="text-base font-bold text-text-primary tracking-tight">Assign Enterprise Role</h3>
|
||||||
<form onSubmit={handleInvite} className="mt-4 space-y-4">
|
<p className="text-xs text-text-muted mt-0.5 font-mono">
|
||||||
|
Bind an authenticated user to <strong>{activeBusinessName}</strong> with specific business permissions.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form onSubmit={handleAssignRole} className="mt-4 space-y-3.5">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">User Email Address</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">User Email Address</label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
required
|
required
|
||||||
value={inviteEmail}
|
value={inviteEmail}
|
||||||
onChange={(e) => setInviteEmail(e.target.value)}
|
onChange={(e) => setInviteEmail(e.target.value)}
|
||||||
placeholder="colleague@tradingfirm.com"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
placeholder="trader@alphagrain.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-gray-700">Governed PRD Role</label>
|
<label className="block text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono mb-1">PRD Governed Role</label>
|
||||||
<select
|
<select
|
||||||
value={inviteRole}
|
value={inviteRole}
|
||||||
onChange={(e) => setInviteRole(e.target.value)}
|
onChange={(e) => setInviteRole(e.target.value)}
|
||||||
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-emerald-500 focus:border-emerald-500 sm:text-sm"
|
className="w-full bg-white border border-card-border rounded px-3 py-2 text-xs font-mono focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20"
|
||||||
>
|
>
|
||||||
{PRD_ROLES.map((r) => (
|
{PRD_ROLES.map((r) => (
|
||||||
<option key={r} value={r}>{r}</option>
|
<option key={r} value={r}>{r}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5 sm:grid sm:grid-cols-2 sm:gap-3">
|
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||||
<button
|
<Button type="button" variant="secondary" size="sm" onClick={() => setShowInviteModal(false)}>
|
||||||
type="button"
|
|
||||||
onClick={() => setShowInviteModal(false)}
|
|
||||||
className="w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 sm:text-sm"
|
|
||||||
>
|
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="submit" variant="primary" size="sm" disabled={loading}>
|
||||||
type="submit"
|
Assign Role
|
||||||
disabled={loading}
|
</Button>
|
||||||
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-emerald-600 text-base font-medium text-white hover:bg-emerald-700 sm:text-sm"
|
|
||||||
>
|
|
||||||
Confirm Assignment
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -245,4 +237,3 @@ export const TenantMembersView: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
:root {
|
||||||
|
--surface: #f9f9f6;
|
||||||
|
--sidebar-surface: #162a22;
|
||||||
|
--sidebar-surface-active: #2a4237;
|
||||||
|
--card-surface: #ffffff;
|
||||||
|
--card-border: #e8e6df;
|
||||||
|
--accent-ochre: #c89332;
|
||||||
|
--text-primary: #1c1e1d;
|
||||||
|
--text-muted: #78716c;
|
||||||
|
--status-normal-bg: #eaf5ed;
|
||||||
|
--status-normal-text: #2d6a4f;
|
||||||
|
--status-watch-bg: #fdf6e7;
|
||||||
|
--status-watch-text: #926a1d;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: var(--surface);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer components {
|
||||||
|
/* AgriTrade Mercantile Component Primitives */
|
||||||
|
.btn-primary {
|
||||||
|
@apply bg-sidebar-surface hover:bg-sidebar-active text-white text-sm font-medium px-4 py-2 rounded transition shadow-none disabled:opacity-50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
@apply bg-white hover:bg-surface-low text-text-primary border border-card-border text-sm font-medium px-4 py-2 rounded transition shadow-none disabled:opacity-50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-accent {
|
||||||
|
@apply bg-accent-ochre hover:brightness-95 text-white text-sm font-semibold px-4 py-2 rounded transition shadow-none disabled:opacity-50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-pill-normal {
|
||||||
|
@apply inline-flex items-center px-2 py-0.5 rounded-full text-[0.6875rem] font-semibold tracking-wider uppercase bg-status-normal-bg text-status-normal-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-pill-watch {
|
||||||
|
@apply inline-flex items-center px-2 py-0.5 rounded-full text-[0.6875rem] font-semibold tracking-wider uppercase bg-status-watch-bg text-status-watch-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-mercantile {
|
||||||
|
@apply bg-card-surface border border-card-border rounded p-6 shadow-none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.callout-ochre {
|
||||||
|
@apply bg-status-watch-bg border-l-[3px] border-accent-ochre p-4 rounded-r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import { App } from './App';
|
import { App } from './App';
|
||||||
|
import './index.css';
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
export default {
|
||||||
|
content: [
|
||||||
|
"./index.html",
|
||||||
|
"./src/**/*.{js,ts,jsx,tsx}",
|
||||||
|
],
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
surface: {
|
||||||
|
DEFAULT: '#f9f9f6',
|
||||||
|
dim: '#dadad7',
|
||||||
|
bright: '#f9f9f6',
|
||||||
|
lowest: '#ffffff',
|
||||||
|
low: '#f4f4f1',
|
||||||
|
container: '#eeeeeb',
|
||||||
|
high: '#e8e8e5',
|
||||||
|
highest: '#e2e3e0',
|
||||||
|
},
|
||||||
|
'on-surface': {
|
||||||
|
DEFAULT: '#1a1c1b',
|
||||||
|
variant: '#434845',
|
||||||
|
},
|
||||||
|
primary: {
|
||||||
|
DEFAULT: '#030b08',
|
||||||
|
pine: '#18231f',
|
||||||
|
container: '#18231f',
|
||||||
|
'on-container': '#7f8b85',
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
DEFAULT: '#865300',
|
||||||
|
amber: '#df9b42',
|
||||||
|
container: '#feb55a',
|
||||||
|
},
|
||||||
|
tertiary: {
|
||||||
|
DEFAULT: '#120705',
|
||||||
|
container: '#2c1d1b',
|
||||||
|
},
|
||||||
|
sidebar: {
|
||||||
|
surface: '#162A22',
|
||||||
|
active: '#2A4237',
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
surface: '#FFFFFF',
|
||||||
|
border: '#E8E6DF',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
primary: '#1C1E1D',
|
||||||
|
muted: '#78716C',
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
'normal-bg': '#EAF5ED',
|
||||||
|
'normal-text': '#2D6A4F',
|
||||||
|
'watch-bg': '#FDF6E7',
|
||||||
|
'watch-text': '#926A1D',
|
||||||
|
},
|
||||||
|
accent: {
|
||||||
|
ochre: '#C89332',
|
||||||
|
},
|
||||||
|
outline: {
|
||||||
|
DEFAULT: '#737875',
|
||||||
|
variant: '#c3c8c4',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
DEFAULT: '#ba1a1a',
|
||||||
|
container: '#ffdad6',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fontFamily: {
|
||||||
|
sans: ['Inter', 'system-ui', '-apple-system', 'sans-serif'],
|
||||||
|
mono: ['JetBrains Mono', 'ui-monospace', 'monospace'],
|
||||||
|
},
|
||||||
|
borderRadius: {
|
||||||
|
sm: '0.125rem',
|
||||||
|
DEFAULT: '0.25rem',
|
||||||
|
md: '0.375rem',
|
||||||
|
lg: '0.5rem',
|
||||||
|
xl: '0.75rem',
|
||||||
|
full: '9999px',
|
||||||
|
},
|
||||||
|
spacing: {
|
||||||
|
gutter: '1rem',
|
||||||
|
'gutter-compact': '0.5rem',
|
||||||
|
'space-xs': '0.25rem',
|
||||||
|
'space-sm': '0.5rem',
|
||||||
|
'space-md': '0.75rem',
|
||||||
|
'space-lg': '1rem',
|
||||||
|
'space-xl': '1.5rem',
|
||||||
|
'space-xxl': '2rem',
|
||||||
|
},
|
||||||
|
boxShadow: {
|
||||||
|
tactile: '0 4px 16px -2px rgba(22, 42, 34, 0.08), 0 1px 2px 0 rgba(22, 42, 34, 0.04)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue