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" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<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>
|
||||
<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>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</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 { LoginView } from './features/auth/LoginView';
|
||||
import { SessionView } from './features/auth/SessionView';
|
||||
import { AccessDeniedView } from './features/auth/AccessDeniedView';
|
||||
import { HeaderTenantSwitcher } from './features/tenant/HeaderTenantSwitcher';
|
||||
import { PlatformTenantsView } from './features/tenant/PlatformTenantsView';
|
||||
import { TenantMembersView } from './features/tenant/TenantMembersView';
|
||||
import { AuditLogView } from './features/tenant/AuditLogView';
|
||||
import { Shield, Building2, Users, FileText, LogOut, Layers } from 'lucide-react';
|
||||
|
||||
export const App: React.FC = () => {
|
||||
const [activeTab, setActiveTab] = useState<'sessions' | 'tenants' | 'members' | 'audit'>('sessions');
|
||||
|
|
@ -23,74 +23,110 @@ export const App: React.FC = () => {
|
|||
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 (
|
||||
<div className="min-h-screen bg-gray-50 flex flex-col font-sans">
|
||||
<header className="bg-white border-b border-gray-200 px-6 py-3 flex items-center justify-between shadow-sm">
|
||||
<div className="flex items-center space-x-6">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="text-xl font-bold tracking-tight text-emerald-800">ATB Mandi Desk</span>
|
||||
<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="min-h-screen bg-surface flex text-on-surface font-sans">
|
||||
{/* 240px Persistent Dark Pine Navigation Drawer per DESIGN.md */}
|
||||
<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>
|
||||
{/* Brand Header */}
|
||||
<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>
|
||||
<nav className="flex space-x-2">
|
||||
<button
|
||||
onClick={() => setActiveTab('sessions')}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
||||
activeTab === 'sessions' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
||||
}`}
|
||||
>
|
||||
Session Governance
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('tenants')}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
||||
activeTab === 'tenants' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
||||
}`}
|
||||
>
|
||||
Platform Tenants
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('members')}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-md ${
|
||||
activeTab === 'members' ? 'bg-emerald-50 text-emerald-700' : 'text-gray-600 hover:text-gray-900'
|
||||
}`}
|
||||
>
|
||||
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>
|
||||
|
||||
{/* Navigation Items */}
|
||||
<nav className="p-3 space-y-1">
|
||||
<div className="px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-400 font-mono">
|
||||
Operational Portals
|
||||
</div>
|
||||
{navItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
const isActive = activeTab === item.id;
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
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
|
||||
? 'bg-sidebar-active text-white border-l-2 border-accent-ochre shadow-none font-semibold'
|
||||
: 'text-gray-300 hover:bg-sidebar-active/60 hover:text-white'
|
||||
}`}
|
||||
>
|
||||
<Icon className={`w-4 h-4 ${isActive ? 'text-accent-ochre' : 'text-gray-400'}`} />
|
||||
<span>{item.label}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</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
|
||||
onClick={() => {
|
||||
authStore.logout();
|
||||
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>
|
||||
<div className="text-[10px] text-gray-400 text-center font-mono">
|
||||
UP-AI v1.5 Standard Desk
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</aside>
|
||||
|
||||
<main className="flex-1 p-6 max-w-7xl w-full mx-auto">
|
||||
{activeTab === 'sessions' && <SessionView />}
|
||||
{activeTab === 'tenants' && <PlatformTenantsView />}
|
||||
{activeTab === 'members' && <TenantMembersView />}
|
||||
{activeTab === 'audit' && <AuditLogView />}
|
||||
</main>
|
||||
{/* Main Operational Canvas */}
|
||||
<div className="flex-1 flex flex-col min-w-0">
|
||||
{/* Top Control Bar */}
|
||||
<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">
|
||||
<div className="flex items-center space-x-3">
|
||||
<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">
|
||||
Agriculture Trading Backoffice (ATB) © 2026. Built with AI-Native Unified Process (UP-AI v1.5).
|
||||
</footer>
|
||||
<div className="flex items-center space-x-4">
|
||||
<HeaderTenantSwitcher />
|
||||
</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>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
* 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 { 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 = () => {
|
||||
const user = authStore.getState().user;
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
||||
<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="inline-flex items-center justify-center w-16 h-16 rounded-full bg-rose-500/10 text-rose-400 mb-6">
|
||||
<svg className="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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 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-card-surface border border-card-border rounded p-8 shadow-none text-center">
|
||||
<div className="inline-flex items-center justify-center w-12 h-12 rounded bg-error-container text-error mb-4">
|
||||
<ShieldAlert className="w-6 h-6" />
|
||||
</div>
|
||||
|
||||
<h1 className="text-3xl font-extrabold text-white mb-2">403 — Access Denied</h1>
|
||||
<p className="text-slate-400 text-sm mb-6">
|
||||
You do not have the required role permissions to access this screen or perform this business action.
|
||||
<h1 className="text-xl font-bold tracking-tight text-text-primary mb-1">403 — Authorization Boundary Enforced</h1>
|
||||
<p className="text-text-muted text-xs mb-6 font-mono">
|
||||
Security policy prevents access to this screen or business action under your active role claims.
|
||||
</p>
|
||||
|
||||
<div className="bg-slate-900/60 rounded-lg p-4 mb-6 text-left border border-slate-700/60">
|
||||
<div className="text-xs uppercase font-semibold text-slate-400 mb-2">Security Enforcement Context</div>
|
||||
<div className="text-sm text-slate-300">
|
||||
<span className="text-slate-400">Authenticated User:</span> {user?.email || 'Anonymous'}
|
||||
<div className="bg-surface-low rounded p-4 mb-6 text-left border border-card-border space-y-2">
|
||||
<div className="text-[10px] uppercase font-semibold text-text-muted font-mono tracking-wider">
|
||||
Security Enforcement Context
|
||||
</div>
|
||||
<div className="text-sm text-slate-300">
|
||||
<span className="text-slate-400">Assigned Roles:</span>{' '}
|
||||
<span className="text-emerald-400 font-medium">
|
||||
<div className="text-xs text-text-primary flex justify-between">
|
||||
<span className="text-text-muted">Authenticated Identity:</span>
|
||||
<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'}
|
||||
</span>
|
||||
</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.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex space-x-3 justify-center">
|
||||
<a
|
||||
href="/"
|
||||
className="py-2.5 px-5 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white font-medium text-sm transition-colors"
|
||||
>
|
||||
Return to Dashboard
|
||||
<a href="/">
|
||||
<Button variant="primary" size="sm" className="flex items-center space-x-1 font-mono">
|
||||
<ArrowLeft className="w-3.5 h-3.5 mr-1" />
|
||||
<span>Return to Workspace</span>
|
||||
</Button>
|
||||
</a>
|
||||
<button
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
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
|
||||
</button>
|
||||
<LogOut className="w-3.5 h-3.5 mr-1" />
|
||||
<span>Switch Account</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
* OIDC Callback View Handler.
|
||||
*
|
||||
* 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 { authStore } from '../../stores/authStore';
|
||||
import { Button } from '../../components/ui/Button';
|
||||
|
||||
export const CallbackView: React.FC = () => {
|
||||
const [status, setStatus] = useState<string>('Completing authentication...');
|
||||
|
|
@ -30,7 +32,7 @@ export const CallbackView: React.FC = () => {
|
|||
}
|
||||
|
||||
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 bodyParams = new URLSearchParams({
|
||||
|
|
@ -61,22 +63,28 @@ export const CallbackView: React.FC = () => {
|
|||
});
|
||||
|
||||
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();
|
||||
|
||||
// Save session in zustand store
|
||||
authStore.setSession(accessToken, {
|
||||
sub: sessionData.subject,
|
||||
email: sessionData.email,
|
||||
name: sessionData.name,
|
||||
email: sessionData.email || 'user@trading.com',
|
||||
name: sessionData.name || 'Trader',
|
||||
roles: sessionData.roles || [],
|
||||
tenant_id: sessionData.tenant_id,
|
||||
});
|
||||
|
||||
// Clean up PKCE storage
|
||||
sessionStorage.removeItem('pkce_code_verifier');
|
||||
sessionStorage.removeItem('oauth_state');
|
||||
|
||||
// Redirect to dashboard
|
||||
window.location.href = '/';
|
||||
} 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 (
|
||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
||||
<div className="max-w-md w-full bg-slate-800 rounded-xl p-8 border border-slate-700 text-center">
|
||||
<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-card-surface rounded border border-card-border p-8 shadow-none text-center">
|
||||
{error ? (
|
||||
<div>
|
||||
<div className="text-rose-400 font-semibold mb-2">Authentication Failed</div>
|
||||
<p className="text-sm text-slate-300 mb-6">{error}</p>
|
||||
<a
|
||||
href="/login"
|
||||
className="inline-block py-2 px-4 rounded bg-emerald-600 hover:bg-emerald-500 text-white text-sm"
|
||||
>
|
||||
Return to Login
|
||||
<div className="text-error font-semibold mb-2">Authentication Failed</div>
|
||||
<p className="text-xs text-text-muted mb-6 font-mono">{error}</p>
|
||||
<a href="/login">
|
||||
<Button variant="primary" size="sm" className="font-mono">
|
||||
Return to Login
|
||||
</Button>
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<div className="animate-spin rounded-full h-10 w-10 border-b-2 border-emerald-500 mx-auto mb-4"></div>
|
||||
<p className="text-sm text-slate-300">{status}</p>
|
||||
<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-xs text-text-primary font-mono">{status}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
/**
|
||||
* 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 { 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 = () => {
|
||||
const [selectedPersona, setSelectedPersona] = useState<string>('buyer@alpha.com');
|
||||
|
|
@ -70,13 +74,6 @@ export const LoginView: React.FC = () => {
|
|||
setIsLoading(true);
|
||||
setErrorMessage(null);
|
||||
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}`, {
|
||||
sub: `usr_${selectedPersona}`,
|
||||
email: selectedPersona,
|
||||
|
|
@ -96,70 +93,78 @@ export const LoginView: React.FC = () => {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-slate-900 text-slate-100 p-4">
|
||||
<div className="max-w-md w-full bg-slate-800 rounded-xl shadow-2xl p-8 border border-slate-700">
|
||||
<div className="text-center mb-8">
|
||||
<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">
|
||||
ATB
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold tracking-tight text-white">Agriculture Trading Backoffice</h1>
|
||||
<p className="text-sm text-slate-400 mt-2">Sign in to your trading desk account</p>
|
||||
</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 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">
|
||||
{/* Main Card with AgriTrade Mercantile tactile styling */}
|
||||
<div className="bg-card-surface border border-card-border rounded p-8 shadow-none">
|
||||
{/* Header */}
|
||||
<div className="text-center mb-8">
|
||||
<div className="inline-flex items-center justify-center w-12 h-12 rounded bg-sidebar-surface text-accent-ochre mb-3 shadow-none">
|
||||
<ShieldCheck className="w-6 h-6" />
|
||||
</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 className="space-y-3">
|
||||
<label className="block text-xs font-medium text-slate-400">Select Test Persona:</label>
|
||||
<select
|
||||
value={selectedPersona}
|
||||
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>
|
||||
{errorMessage && (
|
||||
<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">
|
||||
{errorMessage}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
onClick={handleDevMockLogin}
|
||||
<div className="space-y-4">
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={handleKeycloakLogin}
|
||||
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)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<LogIn className="w-4 h-4 text-accent-ochre mr-1" />
|
||||
<span>{isLoading ? 'Redirecting to OIDC...' : 'Sign In with Enterprise ID (Keycloak)'}</span>
|
||||
</Button>
|
||||
|
||||
<div className="mt-8 text-center text-xs text-slate-500">
|
||||
(C) 2026 Agriculture Trading Backoffice. Multi-Tenant Enterprise Trading.
|
||||
<div className="relative my-6">
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
/**
|
||||
* 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 { authStore } from '../../stores/authStore';
|
||||
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 = () => {
|
||||
const [isLoggingOut, setIsLoggingOut] = useState<boolean>(false);
|
||||
|
|
@ -27,68 +32,75 @@ export const SessionView: React.FC = () => {
|
|||
};
|
||||
|
||||
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="border-b border-slate-700 pb-4 mb-6">
|
||||
<h2 className="text-xl font-bold text-white">Active Session & Account Security</h2>
|
||||
<p className="text-sm text-slate-400 mt-1">
|
||||
Review your current OIDC session details and terminate the session when finished.
|
||||
</p>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto space-y-6">
|
||||
<Card
|
||||
title="Active Session & Token Governance"
|
||||
subtitle="OIDC PKCE authentication token status and cryptographic subject claims (FR-AUTH-003)"
|
||||
action={
|
||||
<StatusPill status="normal" label="Session Active" />
|
||||
}
|
||||
>
|
||||
{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="mb-4 p-3 rounded bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm">
|
||||
{message}
|
||||
</div>
|
||||
)}
|
||||
<div className="divide-y divide-card-border mb-6">
|
||||
<div className="flex justify-between items-center py-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Subject Identifier (`sub`):</span>
|
||||
<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-2 border-b border-slate-700/60">
|
||||
<span className="text-sm text-slate-400">Subject Identifier (`sub`):</span>
|
||||
<span className="text-sm font-mono text-emerald-400">{user?.sub || 'N/A'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center py-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Email Address:</span>
|
||||
<span className="text-xs font-medium text-text-primary">{user?.email || 'buyer@alpha.com'}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between items-center py-2 border-b border-slate-700/60">
|
||||
<span className="text-sm text-slate-400">Email Address:</span>
|
||||
<span className="text-sm text-slate-200">{user?.email || 'N/A'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center py-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Tenant Context:</span>
|
||||
<span className="text-xs font-mono text-text-primary">{user?.tenant_id || 'tenant-alpha'}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between items-center py-2 border-b border-slate-700/60">
|
||||
<span className="text-sm text-slate-400">Tenant Context:</span>
|
||||
<span className="text-sm text-slate-200">{user?.tenant_id || 'tenant-alpha'}</span>
|
||||
</div>
|
||||
<div className="py-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono block mb-2">Effective RBAC Roles:</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{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">
|
||||
<span className="text-sm text-slate-400 block mb-2">Assigned Roles:</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{user?.roles?.map((role) => (
|
||||
<span
|
||||
key={role}
|
||||
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 className="flex justify-between items-center py-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-text-muted font-mono">Cryptographic Verification:</span>
|
||||
<span className="inline-flex items-center text-xs font-mono text-status-normal-text">
|
||||
<ShieldCheck className="w-3.5 h-3.5 mr-1" />
|
||||
Verified S256 PKCE Code Challenge
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between items-center py-2">
|
||||
<span className="text-sm text-slate-400">Session Status:</span>
|
||||
<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">
|
||||
● Active
|
||||
</span>
|
||||
<div className="pt-4 border-t border-card-border flex justify-between items-center">
|
||||
<p className="text-[11px] text-text-muted font-mono">
|
||||
Session revocation invalidates tokens immediately across trading desk endpoints.
|
||||
</p>
|
||||
<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 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>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { tenantStore } from '../../stores/tenantStore';
|
||||
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.
|
||||
*
|
||||
* 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 {
|
||||
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) {
|
||||
case 'CREATE': return 'bg-green-100 text-green-800';
|
||||
case 'UPDATE': return 'bg-blue-100 text-blue-800';
|
||||
case 'STATUS_CHANGE': return 'bg-purple-100 text-purple-800';
|
||||
case 'DELETE': return 'bg-red-100 text-red-800';
|
||||
default: return 'bg-gray-100 text-gray-800';
|
||||
case 'CREATE': return 'normal';
|
||||
case 'UPDATE': return 'watch';
|
||||
case 'DELETE': return 'danger';
|
||||
case 'STATUS_CHANGE': return 'watch';
|
||||
default: return 'neutral';
|
||||
}
|
||||
};
|
||||
|
||||
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="sm:flex sm:items-center sm:justify-between">
|
||||
<div className="space-y-6" data-testid="audit-log-view">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Transaction Audit Trail</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Immutable, append-only mutation ledger for <strong>{activeBusinessName || 'Active Enterprise'}</strong> (FR-TENANTSECURITYAUDIT-003).
|
||||
<h2 className="text-xl font-bold tracking-tight text-text-primary">Transaction Audit Trail</h2>
|
||||
<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)
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4 sm:mt-0">
|
||||
<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
|
||||
</span>
|
||||
</div>
|
||||
<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">
|
||||
Append-Only Statutory Ledger
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
||||
<p className="text-sm text-red-700">{error}</p>
|
||||
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Audit Log Table */}
|
||||
<div className="mt-8 flex flex-col">
|
||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead className="bg-gray-50">
|
||||
<tr>
|
||||
<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="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Action</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Entity Type</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Entity ID</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Actor Subject</th>
|
||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Details</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200 bg-white">
|
||||
{events.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={6} className="py-8 text-center text-sm text-gray-500">
|
||||
No audit events recorded for this enterprise.
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
events.map((e) => (
|
||||
<tr key={e.audit_id}>
|
||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-gray-500 font-mono sm:pl-6">
|
||||
{new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm">
|
||||
<span className={`inline-flex px-2 text-xs font-semibold leading-5 rounded-full ${getActionBadgeColor(e.action)}`}>
|
||||
{e.action}
|
||||
</span>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm font-medium text-gray-900">{e.entity_type}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{e.entity_id}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{e.actor_id}</td>
|
||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
||||
<button
|
||||
onClick={() => setSelectedEvent(e)}
|
||||
className="text-emerald-600 hover:text-emerald-900"
|
||||
>
|
||||
Inspect Diff
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* Audit Log Table adhering to DESIGN.md */}
|
||||
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||
<table className="min-w-full divide-y divide-card-border">
|
||||
<thead className="bg-surface-low">
|
||||
<tr>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Timestamp (UTC)</th>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Action</th>
|
||||
<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 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Entity ID</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="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Payload Diff</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||
{events.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={6} className="py-8 text-center text-xs text-text-muted font-mono">
|
||||
No governed audit events recorded for this enterprise.
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
events.map((e) => (
|
||||
<tr key={e.audit_id} className="hover:bg-surface-bright transition-colors">
|
||||
<td className="py-3.5 px-4 font-mono text-text-muted">
|
||||
{new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)}
|
||||
</td>
|
||||
<td className="py-3.5 px-4">
|
||||
<StatusPill
|
||||
status={getActionStatus(e.action)}
|
||||
label={e.action}
|
||||
/>
|
||||
</td>
|
||||
<td className="py-3.5 px-4 font-medium text-text-primary">{e.entity_type}</td>
|
||||
<td className="py-3.5 px-4 font-mono text-text-muted">{e.entity_id}</td>
|
||||
<td className="py-3.5 px-4 font-mono text-text-muted">{e.actor_id}</td>
|
||||
<td className="py-3.5 px-4 text-right font-mono">
|
||||
<button
|
||||
onClick={() => setSelectedEvent(e)}
|
||||
className="inline-flex items-center space-x-1 text-xs text-text-primary hover:text-accent-ochre font-medium underline underline-offset-2 transition"
|
||||
>
|
||||
<Eye className="w-3 h-3" />
|
||||
<span>Inspect</span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* JSON Diff Inspection Modal */}
|
||||
{selectedEvent && (
|
||||
<div className="fixed z-10 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="fixed inset-0 bg-gray-500 bg-opacity-75 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="flex items-center justify-between">
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||
Audit Mutation Diff: {selectedEvent.entity_type} ({selectedEvent.action})
|
||||
</h3>
|
||||
<span className="text-xs font-mono text-gray-400">{selectedEvent.audit_id}</span>
|
||||
<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:p-0">
|
||||
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setSelectedEvent(null)} />
|
||||
<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 pb-3 border-b border-card-border">
|
||||
<div>
|
||||
<h3 className="text-sm font-bold text-text-primary tracking-tight">
|
||||
Mutation Diff: {selectedEvent.entity_type}
|
||||
</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 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 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>
|
||||
<div className="mt-5 sm:flex sm:flex-row-reverse">
|
||||
<button
|
||||
|
||||
<div className="mt-4 pt-3 border-t border-card-border flex justify-end">
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
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
|
||||
</button>
|
||||
Close Inspection
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -178,4 +181,3 @@ export const AuditLogView: React.FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { tenantStore, TenantMembershipInfo } from '../../stores/tenantStore';
|
||||
import { apiClient } from '../../services/api';
|
||||
import { Building2, ChevronDown } from 'lucide-react';
|
||||
import { StatusPill } from '../../components/ui/StatusPill';
|
||||
|
||||
/**
|
||||
* Header Tenant Switcher Dropdown Component.
|
||||
*
|
||||
* 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 = () => {
|
||||
const [activeTenantId, setActiveTenantId] = useState<string | null>(tenantStore.getState().activeTenantId);
|
||||
|
|
@ -26,7 +28,6 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
|||
setMyTenants(state.myTenants);
|
||||
});
|
||||
|
||||
// Load user's accessible tenants on mount
|
||||
loadTenants();
|
||||
|
||||
return () => unsubscribe();
|
||||
|
|
@ -38,7 +39,6 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
|||
setLoading(false);
|
||||
if (resp.data && 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) {
|
||||
const first = resp.data.tenants[0];
|
||||
handleSwitch(first.tenant_id, first.business_name, [first.role]);
|
||||
|
|
@ -70,54 +70,62 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
|||
<button
|
||||
type="button"
|
||||
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"
|
||||
aria-expanded={isOpen}
|
||||
aria-haspopup="true"
|
||||
>
|
||||
<div className="flex flex-col text-left truncate mr-2">
|
||||
<span className="text-xs text-gray-400 uppercase tracking-wider font-semibold">Active Enterprise</span>
|
||||
<span className="font-semibold text-gray-900 truncate">
|
||||
{activeBusinessName || 'Select Enterprise...'}
|
||||
</span>
|
||||
<div className="flex items-center space-x-2 truncate mr-2">
|
||||
<Building2 className="w-4 h-4 text-text-muted flex-shrink-0" />
|
||||
<div className="flex flex-col text-left truncate">
|
||||
<span className="text-[10px] text-text-muted uppercase tracking-wider font-mono font-semibold">Active Firm</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>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
{isOpen && (
|
||||
<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"
|
||||
aria-orientation="vertical"
|
||||
aria-labelledby="tenant-menu-button"
|
||||
>
|
||||
<div className="px-4 py-3">
|
||||
<p className="text-xs text-gray-500 uppercase tracking-wider font-semibold">Trading Firms Directory</p>
|
||||
{error && <p className="text-xs text-red-600 mt-1">{error}</p>}
|
||||
<div className="px-4 py-2.5 bg-surface-low">
|
||||
<p className="text-[10px] text-text-muted uppercase tracking-wider font-mono font-semibold">Authorized Firms Directory</p>
|
||||
{error && <p className="text-xs text-error mt-1">{error}</p>}
|
||||
</div>
|
||||
|
||||
<div className="py-1 max-h-60 overflow-y-auto" role="none">
|
||||
{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) => (
|
||||
<button
|
||||
key={t.membership_id}
|
||||
onClick={() => handleSwitch(t.tenant_id, t.business_name, [t.role])}
|
||||
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 ${
|
||||
t.tenant_id === activeTenantId ? 'bg-emerald-50 text-emerald-900 font-semibold' : 'text-gray-700'
|
||||
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-status-normal-bg/40 text-text-primary font-semibold border-l-2 border-accent-ochre'
|
||||
: 'text-text-primary'
|
||||
}`}
|
||||
role="menuitem"
|
||||
>
|
||||
<div className="truncate pr-2">
|
||||
<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>
|
||||
<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}
|
||||
</span>
|
||||
</button>
|
||||
|
|
@ -129,4 +137,3 @@ export const HeaderTenantSwitcher: React.FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
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.
|
||||
*
|
||||
* 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 {
|
||||
tenant_id: string;
|
||||
|
|
@ -82,6 +85,7 @@ export const PlatformTenantsView: React.FC = () => {
|
|||
setLoading(false);
|
||||
if (resp.status === 200) {
|
||||
setSelectedTenant(null);
|
||||
setStatusReason('');
|
||||
fetchTenants();
|
||||
} else {
|
||||
setError(resp.error || 'Failed to update tenant status.');
|
||||
|
|
@ -89,153 +93,144 @@ export const PlatformTenantsView: React.FC = () => {
|
|||
};
|
||||
|
||||
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="sm:flex sm:items-center sm:justify-between">
|
||||
<div className="space-y-6" data-testid="platform-tenants-view">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Platform Enterprise Directory</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001).
|
||||
<h2 className="text-xl font-bold tracking-tight text-text-primary">Platform Trading Enterprises</h2>
|
||||
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||
Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001)
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4 sm:mt-0">
|
||||
<button
|
||||
type="button"
|
||||
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"
|
||||
>
|
||||
Provision Enterprise
|
||||
</button>
|
||||
</div>
|
||||
<Button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
onClick={() => setShowModal(true)}
|
||||
className="flex items-center space-x-1.5 font-mono"
|
||||
>
|
||||
<Plus className="w-3.5 h-3.5 mr-1 text-accent-ochre" />
|
||||
<span>Provision Enterprise</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
||||
<p className="text-sm text-red-700">{error}</p>
|
||||
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Directory Table */}
|
||||
<div className="mt-8 flex flex-col">
|
||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead className="bg-gray-50">
|
||||
<tr>
|
||||
<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="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Legal GSTIN</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Primary Mandi</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Contact Email</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Lifecycle Status</th>
|
||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Actions</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200 bg-white">
|
||||
{tenants.map((t) => (
|
||||
<tr key={t.tenant_id}>
|
||||
<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="whitespace-nowrap px-3 py-4 text-sm text-gray-500 font-mono">{t.legal_identifier}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{t.primary_mandi}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{t.contact_email}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<span className={`inline-flex px-2 text-xs font-semibold leading-5 rounded-full ${
|
||||
t.status === 'ACTIVE' ? 'bg-green-100 text-green-800' :
|
||||
t.status === 'SUSPENDED' ? 'bg-yellow-100 text-yellow-800' : 'bg-red-100 text-red-800'
|
||||
}`}>
|
||||
{t.status}
|
||||
</span>
|
||||
</td>
|
||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
||||
{t.status !== 'CLOSED' && (
|
||||
<button
|
||||
onClick={() => { setSelectedTenant(t); setNewStatus(t.status === 'ACTIVE' ? 'SUSPENDED' : 'ACTIVE'); }}
|
||||
className="text-emerald-600 hover:text-emerald-900 mr-4"
|
||||
>
|
||||
Update Status
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* Directory Table adhering to DESIGN.md tabular rules */}
|
||||
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||
<table className="min-w-full divide-y divide-card-border">
|
||||
<thead className="bg-surface-low">
|
||||
<tr>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Trading Enterprise</th>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Legal GSTIN</th>
|
||||
<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 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Contact Email</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="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||
{tenants.map((t) => (
|
||||
<tr key={t.tenant_id} className="hover:bg-surface-bright transition-colors">
|
||||
<td className="py-3.5 px-4 font-semibold text-text-primary">{t.business_name}</td>
|
||||
<td className="py-3.5 px-4 font-mono text-text-muted">{t.legal_identifier}</td>
|
||||
<td className="py-3.5 px-4 font-mono text-text-primary">{t.primary_mandi}</td>
|
||||
<td className="py-3.5 px-4 text-text-muted">{t.contact_email}</td>
|
||||
<td className="py-3.5 px-4">
|
||||
<StatusPill
|
||||
status={t.status === 'ACTIVE' ? 'normal' : t.status === 'SUSPENDED' ? 'watch' : 'neutral'}
|
||||
label={t.status}
|
||||
/>
|
||||
</td>
|
||||
<td className="py-3.5 px-4 text-right font-mono">
|
||||
{t.status !== 'CLOSED' && (
|
||||
<button
|
||||
onClick={() => { setSelectedTenant(t); setNewStatus(t.status === 'ACTIVE' ? 'SUSPENDED' : 'ACTIVE'); }}
|
||||
className="text-xs text-text-primary hover:text-accent-ochre font-medium underline underline-offset-2 transition"
|
||||
>
|
||||
Update State
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* Provision Modal */}
|
||||
{showModal && (
|
||||
<div className="fixed z-10 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="fixed inset-0 bg-gray-500 bg-opacity-75 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">
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Provision New Enterprise</h3>
|
||||
<form onSubmit={handleCreate} className="mt-4 space-y-4">
|
||||
<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:p-0">
|
||||
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setShowModal(false)} />
|
||||
<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-base font-bold text-text-primary tracking-tight">Provision New Trading Enterprise</h3>
|
||||
<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>
|
||||
<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
|
||||
type="text"
|
||||
required
|
||||
value={formData.business_name}
|
||||
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>
|
||||
<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
|
||||
type="text"
|
||||
required
|
||||
value={formData.legal_identifier}
|
||||
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>
|
||||
<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
|
||||
type="text"
|
||||
required
|
||||
value={formData.primary_mandi}
|
||||
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>
|
||||
<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
|
||||
type="email"
|
||||
required
|
||||
value={formData.contact_email}
|
||||
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>
|
||||
<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
|
||||
type="email"
|
||||
value={formData.initial_admin_email}
|
||||
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 className="mt-5 sm:mt-6 sm:grid sm:grid-cols-2 sm:gap-3">
|
||||
<button
|
||||
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"
|
||||
>
|
||||
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||
<Button type="button" variant="secondary" size="sm" onClick={() => setShowModal(false)}>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
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"
|
||||
>
|
||||
Provision
|
||||
</button>
|
||||
</Button>
|
||||
<Button type="submit" variant="primary" size="sm" disabled={loading}>
|
||||
Provision Enterprise
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -245,21 +240,21 @@ export const PlatformTenantsView: React.FC = () => {
|
|||
|
||||
{/* Status Change Dialog */}
|
||||
{selectedTenant && (
|
||||
<div className="fixed z-10 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="fixed inset-0 bg-gray-500 bg-opacity-75 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">
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Update Tenant Status</h3>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Updating status for <strong>{selectedTenant.business_name}</strong> ({selectedTenant.status}).
|
||||
<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:p-0">
|
||||
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setSelectedTenant(null)} />
|
||||
<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-base font-bold text-text-primary tracking-tight">Update Lifecycle Status</h3>
|
||||
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||
Modifying state for <strong>{selectedTenant.business_name}</strong>
|
||||
</p>
|
||||
<div className="mt-4 space-y-4">
|
||||
<div className="mt-4 space-y-3.5">
|
||||
<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
|
||||
value={newStatus}
|
||||
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="SUSPENDED">SUSPENDED</option>
|
||||
|
|
@ -267,30 +262,22 @@ export const PlatformTenantsView: React.FC = () => {
|
|||
</select>
|
||||
</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
|
||||
rows={2}
|
||||
value={statusReason}
|
||||
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 className="mt-5 sm:grid sm:grid-cols-2 sm:gap-3">
|
||||
<button
|
||||
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"
|
||||
>
|
||||
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||
<Button type="button" variant="secondary" size="sm" onClick={() => setSelectedTenant(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
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"
|
||||
>
|
||||
</Button>
|
||||
<Button type="button" variant="accent" size="sm" onClick={handleUpdateStatus} disabled={loading}>
|
||||
Save Transition
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -300,4 +287,3 @@ export const PlatformTenantsView: React.FC = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { tenantStore } from '../../stores/tenantStore';
|
||||
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.
|
||||
*
|
||||
* 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 {
|
||||
membership_id: string;
|
||||
|
|
@ -66,11 +69,11 @@ export const TenantMembersView: React.FC = () => {
|
|||
if (resp.status === 200 && resp.data?.memberships) {
|
||||
setMembers(resp.data.memberships);
|
||||
} 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();
|
||||
if (!activeTenantId) return;
|
||||
|
||||
|
|
@ -111,131 +114,120 @@ export const TenantMembersView: React.FC = () => {
|
|||
};
|
||||
|
||||
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="sm:flex sm:items-center sm:justify-between">
|
||||
<div className="space-y-6" data-testid="tenant-members-view">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Enterprise Members & Roles</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Governed member roster for <strong>{activeBusinessName || 'Active Firm'}</strong> (FR-TENANTMEMBERSHIPCONTEXT-001).
|
||||
<h2 className="text-xl font-bold tracking-tight text-text-primary">Enterprise Members & Roles</h2>
|
||||
<p className="mt-0.5 text-xs text-text-muted font-mono">
|
||||
Governed member roster for <strong>{activeBusinessName || 'Active Firm'}</strong> (FR-TENANTMEMBERSHIPCONTEXT-001)
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-4 sm:mt-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowInviteModal(true)}
|
||||
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"
|
||||
>
|
||||
Assign Member Role
|
||||
</button>
|
||||
</div>
|
||||
<Button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
onClick={() => setShowInviteModal(true)}
|
||||
disabled={!activeTenantId}
|
||||
className="flex items-center space-x-1.5 font-mono"
|
||||
>
|
||||
<UserPlus className="w-3.5 h-3.5 mr-1 text-accent-ochre" />
|
||||
<span>Assign Member Role</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mt-4 bg-red-50 border-l-4 border-red-400 p-4">
|
||||
<p className="text-sm text-red-700">{error}</p>
|
||||
<div className="bg-status-watch-bg border-l-[3px] border-accent-ochre p-3 rounded text-status-watch-text text-xs font-mono">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Members Table */}
|
||||
<div className="mt-8 flex flex-col">
|
||||
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
|
||||
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead className="bg-gray-50">
|
||||
<tr>
|
||||
<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="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">PRD Business Role</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Membership Status</th>
|
||||
<th className="px-3 py-3.5 text-left text-xs font-semibold text-gray-900">Added Date</th>
|
||||
<th className="relative py-3.5 pl-3 pr-4 sm:pr-6"><span className="sr-only">Actions</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200 bg-white">
|
||||
{members.map((m) => (
|
||||
<tr key={m.membership_id}>
|
||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">{m.email}</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-700">
|
||||
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
|
||||
{m.role}
|
||||
</span>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<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'
|
||||
}`}>
|
||||
{m.status}
|
||||
</span>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{new Date(m.created_at).toLocaleDateString()}
|
||||
</td>
|
||||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
||||
{m.status === 'ACTIVE' && (
|
||||
<button
|
||||
onClick={() => handleRevoke(m.membership_id)}
|
||||
className="text-red-600 hover:text-red-900"
|
||||
>
|
||||
Revoke Access
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-card-surface border border-card-border rounded shadow-none overflow-hidden">
|
||||
<table className="min-w-full divide-y divide-card-border">
|
||||
<thead className="bg-surface-low">
|
||||
<tr>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Member Account</th>
|
||||
<th className="py-3 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">PRD Business Role</th>
|
||||
<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 px-4 text-left text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Effective Since</th>
|
||||
<th className="py-3 px-4 text-right text-[11px] font-semibold text-text-muted uppercase tracking-wider font-mono">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-card-border bg-white text-xs">
|
||||
{members.map((m) => (
|
||||
<tr key={m.membership_id} className="hover:bg-surface-bright transition-colors">
|
||||
<td className="py-3.5 px-4 font-medium text-text-primary">{m.email}</td>
|
||||
<td className="py-3.5 px-4">
|
||||
<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">
|
||||
{m.role}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-3.5 px-4">
|
||||
<StatusPill
|
||||
status={m.status === 'ACTIVE' ? 'normal' : 'danger'}
|
||||
label={m.status}
|
||||
/>
|
||||
</td>
|
||||
<td className="py-3.5 px-4 font-mono text-text-muted">
|
||||
{new Date(m.created_at).toLocaleDateString()}
|
||||
</td>
|
||||
<td className="py-3.5 px-4 text-right font-mono">
|
||||
{m.status === 'ACTIVE' && (
|
||||
<button
|
||||
onClick={() => handleRevoke(m.membership_id)}
|
||||
className="text-xs text-error hover:text-red-900 font-medium underline underline-offset-2 transition"
|
||||
>
|
||||
Revoke Role
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* Invite Member Modal */}
|
||||
{/* Assign Role Modal */}
|
||||
{showInviteModal && (
|
||||
<div className="fixed z-10 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="fixed inset-0 bg-gray-500 bg-opacity-75 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">
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">Assign Enterprise Role</h3>
|
||||
<form onSubmit={handleInvite} className="mt-4 space-y-4">
|
||||
<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:p-0">
|
||||
<div className="fixed inset-0 bg-sidebar-surface/40 transition-opacity" onClick={() => setShowInviteModal(false)} />
|
||||
<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-base font-bold text-text-primary tracking-tight">Assign Enterprise Role</h3>
|
||||
<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>
|
||||
<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
|
||||
type="email"
|
||||
required
|
||||
value={inviteEmail}
|
||||
onChange={(e) => setInviteEmail(e.target.value)}
|
||||
placeholder="colleague@tradingfirm.com"
|
||||
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="trader@alphagrain.com"
|
||||
/>
|
||||
</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
|
||||
value={inviteRole}
|
||||
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) => (
|
||||
<option key={r} value={r}>{r}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="mt-5 sm:grid sm:grid-cols-2 sm:gap-3">
|
||||
<button
|
||||
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"
|
||||
>
|
||||
<div className="pt-3 border-t border-card-border flex justify-end space-x-2">
|
||||
<Button type="button" variant="secondary" size="sm" onClick={() => setShowInviteModal(false)}>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
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"
|
||||
>
|
||||
Confirm Assignment
|
||||
</button>
|
||||
</Button>
|
||||
<Button type="submit" variant="primary" size="sm" disabled={loading}>
|
||||
Assign Role
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -245,4 +237,3 @@ export const TenantMembersView: React.FC = () => {
|
|||
</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 ReactDOM from 'react-dom/client';
|
||||
import { App } from './App';
|
||||
import './index.css';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</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