From c9883df3da09d672b86cafbc3a4d2eab6b11b198 Mon Sep 17 00:00:00 2001 From: Prashant Shendre Date: Thu, 15 Oct 2026 15:34:12 +0530 Subject: [PATCH 1/2] Updated the DESIGN.md --- project_sdlc/06_wireframes/DESIGN.md | 701 +++++++-------------------- 1 file changed, 188 insertions(+), 513 deletions(-) diff --git a/project_sdlc/06_wireframes/DESIGN.md b/project_sdlc/06_wireframes/DESIGN.md index 9269d41..2c6d662 100644 --- a/project_sdlc/06_wireframes/DESIGN.md +++ b/project_sdlc/06_wireframes/DESIGN.md @@ -1,538 +1,213 @@ --- -id: DESIGN -version: 1.1.0 -status: Reviewed -last_cr: CR-001 +name: AgriTrade Mercantile +colors: + surface: '#f9f9f6' + surface-dim: '#dadad7' + surface-bright: '#f9f9f6' + surface-container-lowest: '#ffffff' + surface-container-low: '#f4f4f1' + surface-container: '#eeeeeb' + surface-container-high: '#e8e8e5' + surface-container-highest: '#e2e3e0' + on-surface: '#1a1c1b' + on-surface-variant: '#434845' + inverse-surface: '#2f312f' + inverse-on-surface: '#f1f1ee' + outline: '#737875' + outline-variant: '#c3c8c4' + surface-tint: '#55615c' + primary: '#030b08' + on-primary: '#ffffff' + primary-container: '#18231f' + on-primary-container: '#7f8b85' + inverse-primary: '#bdc9c3' + secondary: '#865300' + on-secondary: '#ffffff' + secondary-container: '#feb55a' + on-secondary-container: '#734700' + tertiary: '#120705' + on-tertiary: '#ffffff' + tertiary-container: '#2c1d1b' + on-tertiary-container: '#9a8380' + error: '#ba1a1a' + on-error: '#ffffff' + error-container: '#ffdad6' + on-error-container: '#93000a' + primary-fixed: '#d9e5df' + primary-fixed-dim: '#bdc9c3' + on-primary-fixed: '#131e1a' + on-primary-fixed-variant: '#3e4945' + secondary-fixed: '#ffddb8' + secondary-fixed-dim: '#ffb961' + on-secondary-fixed: '#2b1700' + on-secondary-fixed-variant: '#663e00' + tertiary-fixed: '#f8dcd9' + tertiary-fixed-dim: '#dbc1bd' + on-tertiary-fixed: '#261816' + on-tertiary-fixed-variant: '#554240' + background: '#f9f9f6' + on-background: '#1a1c1b' + surface-variant: '#e2e3e0' + sidebar-surface: '#162A22' + sidebar-surface-active: '#2A4237' + card-surface: '#FFFFFF' + card-border: '#E8E6DF' + text-primary: '#1C1E1D' + text-muted: '#78716C' + status-normal-bg: '#EAF5ED' + status-normal-text: '#2D6A4F' + status-watch-bg: '#FDF6E7' + status-watch-text: '#926A1D' + accent-ochre: '#C89332' +typography: + headline-xl: + fontFamily: Inter + fontSize: 2rem + fontWeight: '700' + lineHeight: 2.5rem + letterSpacing: -0.02em + headline-lg: + fontFamily: Inter + fontSize: 1.5rem + fontWeight: '600' + lineHeight: 2rem + letterSpacing: -0.015em + headline-md: + fontFamily: Inter + fontSize: 1.25rem + fontWeight: '600' + lineHeight: 1.75rem + letterSpacing: -0.01em + headline-sm: + fontFamily: Inter + fontSize: 1.125rem + fontWeight: '600' + lineHeight: 1.5rem + body-lg: + fontFamily: Inter + fontSize: 1rem + fontWeight: '400' + lineHeight: 1.5rem + body-md: + fontFamily: Inter + fontSize: 0.875rem + fontWeight: '400' + lineHeight: 1.25rem + body-sm: + fontFamily: Inter + fontSize: 0.75rem + fontWeight: '400' + lineHeight: 1rem + label-uppercase: + fontFamily: Inter + fontSize: 0.6875rem + fontWeight: '600' + lineHeight: 0.875rem + letterSpacing: 0.06em + metric-mono-lg: + fontFamily: JetBrains Mono + fontSize: 1.125rem + fontWeight: '500' + lineHeight: 1.5rem + metric-mono-md: + fontFamily: JetBrains Mono + fontSize: 0.875rem + fontWeight: '500' + lineHeight: 1.25rem + metric-mono-sm: + fontFamily: JetBrains Mono + fontSize: 0.75rem + fontWeight: '400' + lineHeight: 1rem +rounded: + sm: 0.125rem + DEFAULT: 0.25rem + md: 0.375rem + lg: 0.5rem + xl: 0.75rem + full: 9999px +spacing: + gutter: 1rem + gutter-compact: 0.5rem + margin: 1.5rem + margin-mobile: 0.75rem + space-xs: 0.25rem + space-sm: 0.5rem + space-md: 0.75rem + space-lg: 1rem + space-xl: 1.5rem + space-xxl: 2rem --- -# Design.md — IndiaAgriTrade (RamDayal Agri Commodities) Wholesale Trading Desk +## Brand & Style -A comprehensive UI/UX, Component Architecture, and Visual Design Specification for building the **IndiaAgriTrade RamDayal BackOffice & Wholesale Trading Desk** using **Vue 3 (Composition API / - - -``` - -### 5.2 Live Mandi Commodity Ticker (`MandiTickerMarquee.vue`) -```vue - - - -``` - -### 5.3 Sauda Entry Form Dialog (`SaudaSlipModal.vue`) -```vue - - - -``` - ---- - -## 6. Responsive Strategy & Mobile Mandi Trader UX - -Agricultural trading operators frequently shift between desktop multi-column screens at the trading desk and smartphone screens while in the field at APMC yards or godowns. - -1. **Card-Based Row Collapsing**: - - On desktop, view dense data grids (`table` layout with 10+ columns: Sauda No, Time, Commodity, Counterparty, Qty, Rate, Total, Status, Action). - - On mobile (`< 768px`), automatically collapse tables into high-contrast swipeable cards showing Commodity badge, Net Qtl, Rate in large mono font, and quick call/WhatsApp buttons for counterparties. -2. **Offline Resilience & Touch Targets**: - - Touch targets for trade execution buttons ≥ 44px × 44px. - - PWA ready design with local cache for mandi price sheets when network in rural APMC yards drops. -3. **Hindi / Bilingual Terminology Support**: - - Labels pair formal English with conversational Mandi Hindi terms (e.g., *Kharid/Buy*, *Bikri/Sell*, *Bora/Bag*, *Bardana/Packaging*, *Karda/Deduction*, *Hamali/Labor*). - ---- - -## 7. Implementation Roadmap & Quickstart - -```bash -# 1. Initialize Vue 3 project with Vite & Tailwind CSS -npm create vite@latest india-agri-trade -- --template vue -cd india-agri-trade -npm install -D tailwindcss postcss autoprefixer @tailwindcss/forms -npx tailwindcss init -p - -# 2. Key recommended libraries -npm install pinia vue-router lucide-vue-next -``` - -This specification provides the full architectural, functional, and aesthetic blueprint to implement the **IndiaAgriTrade RamDayal BackOffice & Wholesale Trading Desk** in Vue 3 with Tailwind CSS. - - -## CR-001 — Authentication UI Boundary - -This design specification does not define the UC-001 login, authorization-denial, or logout screens and flows. The `useAuthStore.js` project-tree reference is not a screen or session contract. Those portal routes and states remain pending the UC-001 wireframe specification; tenant selection and membership screens belong to UC-019. Do not infer token lifetime, signing algorithm, revocation mechanism, or cross-tenant role behavior from this document. +### Alert & Callout Badges +- Surface `#FDF6E7` with a crisp 3px solid left accent border in `#C89332`. Interior text blends a bold Inter body headline with monospace contract identifiers. \ No newline at end of file From a52d5d0ea0744c2a2c8976176dd42586587a1f44 Mon Sep 17 00:00:00 2001 From: Prashant Shendre Date: Thu, 15 Oct 2026 16:03:26 +0530 Subject: [PATCH 2/2] Updated the screens as per Design.md --- project_code/frontend/index.html | 7 +- project_code/frontend/postcss.config.js | 7 + project_code/frontend/src/App.tsx | 146 ++++++----- .../frontend/src/components/ui/Button.tsx | 41 ++++ .../frontend/src/components/ui/Card.tsx | 35 +++ .../frontend/src/components/ui/Input.tsx | 49 ++++ .../frontend/src/components/ui/StatusPill.tsx | 35 +++ .../src/features/auth/AccessDeniedView.tsx | 63 ++--- .../src/features/auth/CallbackView.tsx | 40 +-- .../frontend/src/features/auth/LoginView.tsx | 131 +++++----- .../src/features/auth/SessionView.tsx | 120 +++++---- .../src/features/tenant/AuditLogView.tsx | 186 +++++++------- .../features/tenant/HeaderTenantSwitcher.tsx | 51 ++-- .../features/tenant/PlatformTenantsView.tsx | 230 ++++++++---------- .../src/features/tenant/TenantMembersView.tsx | 185 +++++++------- project_code/frontend/src/index.css | 58 +++++ project_code/frontend/src/main.tsx | 2 +- project_code/frontend/tailwind.config.js | 98 ++++++++ .../change_request_register.md | 46 +++- .../iteration-01/iteration_surface_matrix.md | 2 +- .../iteration-02/iteration_surface_matrix.md | 2 +- .../SCREEN-ALERT-001_operational_alerts.md | 3 +- .../screen_specs/SCREEN-AUTH-001_login.md | 3 +- .../SCREEN-AUTH-002_access_denied.md | 3 +- .../SCREEN-AUTH-003_session_logout.md | 3 +- ...CREEN-DASH-001_executive_control_centre.md | 3 +- ...EEN-DISP-001_dispatch_board_weighbridge.md | 3 +- ...SCREEN-DISP-002_pod_shortage_settlement.md | 3 +- .../SCREEN-EXP-001_operating_expenses.md | 3 +- .../SCREEN-FLEET-001_fleet_registry.md | 3 +- .../screen_specs/SCREEN-INW-001_gate_entry.md | 3 +- .../SCREEN-INW-002_weighbridge_grn.md | 3 +- .../SCREEN-MASTER-001_commodity_catalog.md | 3 +- ...CREEN-MASTER-002_counterparty_directory.md | 3 +- .../SCREEN-MKT-001_market_desk.md | 3 +- .../SCREEN-MKT-003_commodity_price_trends.md | 3 +- .../SCREEN-PAY-001_supplier_payables_aging.md | 3 +- .../SCREEN-POLICY-001_operating_policies.md | 3 +- .../SCREEN-PROC-001_sauda_booking.md | 3 +- .../screen_specs/SCREEN-QC-001_quality_lab.md | 3 +- .../SCREEN-REC-001_customer_ledger_aging.md | 3 +- .../SCREEN-REC-002_credit_exposure_locks.md | 3 +- .../SCREEN-REC-003_payment_receipts.md | 3 +- .../SCREEN-SALES-001_sales_order_booking.md | 3 +- .../SCREEN-SALES-002_lot_allocation.md | 3 +- ...N-SUPPORT-001_privileged_support_access.md | 3 +- .../SCREEN-TENANT-001_platform_tenants.md | 3 +- .../SCREEN-TENANT-002_tenant_members.md | 3 +- .../SCREEN-TENANT-003_tenant_switcher.md | 3 +- .../SCREEN-TENANT-004_audit_log_viewer.md | 3 +- .../SCREEN-TREND-001_20day_trading_trends.md | 3 +- .../SCREEN-WH-001_stock_ledger.md | 3 +- .../SCREEN-WH-002_capacity_transfers.md | 3 +- project_sdlc/06_wireframes/wireframe_index.md | 4 +- ...T100903Z-session-ui-theme-update-assets.md | 65 +++++ 55 files changed, 1109 insertions(+), 590 deletions(-) create mode 100644 project_code/frontend/postcss.config.js create mode 100644 project_code/frontend/src/components/ui/Button.tsx create mode 100644 project_code/frontend/src/components/ui/Card.tsx create mode 100644 project_code/frontend/src/components/ui/Input.tsx create mode 100644 project_code/frontend/src/components/ui/StatusPill.tsx create mode 100644 project_code/frontend/src/index.css create mode 100644 project_code/frontend/tailwind.config.js create mode 100644 project_sdlc/prompts/20261015T100903Z-session-ui-theme-update-assets.md diff --git a/project_code/frontend/index.html b/project_code/frontend/index.html index b93c009..f1535f0 100644 --- a/project_code/frontend/index.html +++ b/project_code/frontend/index.html @@ -5,10 +5,13 @@ Agriculture Trading Backoffice (ATB) + + + + - +
- diff --git a/project_code/frontend/postcss.config.js b/project_code/frontend/postcss.config.js new file mode 100644 index 0000000..b4a6220 --- /dev/null +++ b/project_code/frontend/postcss.config.js @@ -0,0 +1,7 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} + diff --git a/project_code/frontend/src/App.tsx b/project_code/frontend/src/App.tsx index c0698e0..0f9c0a7 100644 --- a/project_code/frontend/src/App.tsx +++ b/project_code/frontend/src/App.tsx @@ -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 ; } + 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 ( -
-
-
-
- ATB Mandi Desk - v1.0.0 +
+ {/* 240px Persistent Dark Pine Navigation Drawer per DESIGN.md */} +
+ -
- {activeTab === 'sessions' && } - {activeTab === 'tenants' && } - {activeTab === 'members' && } - {activeTab === 'audit' && } -
+ {/* Main Operational Canvas */} +
+ {/* Top Control Bar */} +
+
+

+ {activeTab === 'sessions' && 'Session & Token Governance'} + {activeTab === 'tenants' && 'Platform Trading Tenants'} + {activeTab === 'members' && 'Tenant Membership & Role Matrix'} + {activeTab === 'audit' && 'Security Audit Trail & Mutations'} +

+ | + 240px Asymmetric Canvas +
-
- Agriculture Trading Backoffice (ATB) © 2026. Built with AI-Native Unified Process (UP-AI v1.5). -
+
+ +
+
+ + {/* View Content */} +
+ {activeTab === 'sessions' && } + {activeTab === 'tenants' && } + {activeTab === 'members' && } + {activeTab === 'audit' && } +
+ + {/* Footer */} +
+ Agriculture Trading Backoffice (ATB) © 2026. Tactile Corporate Minimalism. + DESIGN.md Tokenized +
+
); }; - diff --git a/project_code/frontend/src/components/ui/Button.tsx b/project_code/frontend/src/components/ui/Button.tsx new file mode 100644 index 0000000..2b95ced --- /dev/null +++ b/project_code/frontend/src/components/ui/Button.tsx @@ -0,0 +1,41 @@ +import React from 'react'; + +export interface ButtonProps extends React.ButtonHTMLAttributes { + variant?: 'primary' | 'secondary' | 'accent' | 'danger'; + size?: 'sm' | 'md' | 'lg'; +} + +export const Button: React.FC = ({ + 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 ( + + ); +}; + diff --git a/project_code/frontend/src/components/ui/Card.tsx b/project_code/frontend/src/components/ui/Card.tsx new file mode 100644 index 0000000..d664a50 --- /dev/null +++ b/project_code/frontend/src/components/ui/Card.tsx @@ -0,0 +1,35 @@ +import React from 'react'; + +export interface CardProps extends React.HTMLAttributes { + title?: string; + subtitle?: string; + action?: React.ReactNode; +} + +export const Card: React.FC = ({ + title, + subtitle, + action, + children, + className = '', + ...props +}) => { + return ( +
+ {(title || action) && ( +
+
+ {title &&

{title}

} + {subtitle &&

{subtitle}

} +
+ {action &&
{action}
} +
+ )} +
{children}
+
+ ); +}; + diff --git a/project_code/frontend/src/components/ui/Input.tsx b/project_code/frontend/src/components/ui/Input.tsx new file mode 100644 index 0000000..b6b579b --- /dev/null +++ b/project_code/frontend/src/components/ui/Input.tsx @@ -0,0 +1,49 @@ +import React from 'react'; + +export interface InputProps extends React.InputHTMLAttributes { + label?: string; + unit?: string; + error?: string; + helperText?: string; +} + +export const Input: React.FC = ({ + label, + unit, + error, + helperText, + id, + className = '', + ...props +}) => { + const inputId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined); + + return ( +
+ {label && ( + + )} +
+ + {unit && ( +
+ {unit} +
+ )} +
+ {error &&

{error}

} + {helperText && !error &&

{helperText}

} +
+ ); +}; + diff --git a/project_code/frontend/src/components/ui/StatusPill.tsx b/project_code/frontend/src/components/ui/StatusPill.tsx new file mode 100644 index 0000000..753ae82 --- /dev/null +++ b/project_code/frontend/src/components/ui/StatusPill.tsx @@ -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 = ({ 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 ( + + {label} + + ); +}; + diff --git a/project_code/frontend/src/features/auth/AccessDeniedView.tsx b/project_code/frontend/src/features/auth/AccessDeniedView.tsx index c584eea..41d5a52 100644 --- a/project_code/frontend/src/features/auth/AccessDeniedView.tsx +++ b/project_code/frontend/src/features/auth/AccessDeniedView.tsx @@ -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 ( -
-
-
- - - +
+
+
+
-

403 — Access Denied

-

- You do not have the required role permissions to access this screen or perform this business action. +

403 — Authorization Boundary Enforced

+

+ Security policy prevents access to this screen or business action under your active role claims.

-
-
Security Enforcement Context
-
- Authenticated User: {user?.email || 'Anonymous'} +
+
+ Security Enforcement Context
-
- Assigned Roles:{' '} - +
+ Authenticated Identity: + {user?.email || 'Anonymous'} +
+
+ Assigned Roles: + {user?.roles?.length ? user.roles.join(', ') : 'None'}
-
+
Mandatory Segregation of Duties (BRD-FR-040): Quality Officers cannot edit prices; Yard Supervisors cannot confirm sales; Sales Executives cannot override credit locks.
- - Return to Dashboard + + - + + Switch Account +
); }; - diff --git a/project_code/frontend/src/features/auth/CallbackView.tsx b/project_code/frontend/src/features/auth/CallbackView.tsx index c450d04..3315820 100644 --- a/project_code/frontend/src/features/auth/CallbackView.tsx +++ b/project_code/frontend/src/features/auth/CallbackView.tsx @@ -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('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 ( -
-
+
+
{error ? ( ) : (
-
-

{status}

+
+

{status}

)}
); }; - diff --git a/project_code/frontend/src/features/auth/LoginView.tsx b/project_code/frontend/src/features/auth/LoginView.tsx index 59850f8..8af138a 100644 --- a/project_code/frontend/src/features/auth/LoginView.tsx +++ b/project_code/frontend/src/features/auth/LoginView.tsx @@ -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('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 ( -
-
-
-
- ATB -
-

Agriculture Trading Backoffice

-

Sign in to your trading desk account

-
- - {errorMessage && ( -
- {errorMessage} -
- )} - -
- - -
-
-
-
-
- Offline Sandbox / Dev Mode +
+
+ {/* Main Card with AgriTrade Mercantile tactile styling */} +
+ {/* Header */} +
+
+
+

AgriTrade Mercantile

+

Wholesale Trading & Backoffice Desk

-
- - + {errorMessage && ( +
+ {errorMessage} +
+ )} - -
-
+ + {isLoading ? 'Redirecting to OIDC...' : 'Sign In with Enterprise ID (Keycloak)'} + -
- (C) 2026 Agriculture Trading Backoffice. Multi-Tenant Enterprise Trading. +
+
+
+
+
+ Development Sandbox Mode +
+
+ +
+ + + + +
+
+ +
+ Secure Multi-Tenant Context • UP-AI v1.5 Standard +
); }; - diff --git a/project_code/frontend/src/features/auth/SessionView.tsx b/project_code/frontend/src/features/auth/SessionView.tsx index 738fdd2..8ddc115 100644 --- a/project_code/frontend/src/features/auth/SessionView.tsx +++ b/project_code/frontend/src/features/auth/SessionView.tsx @@ -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(false); @@ -27,68 +32,75 @@ export const SessionView: React.FC = () => { }; return ( -
-
-

Active Session & Account Security

-

- Review your current OIDC session details and terminate the session when finished. -

-
+
+ + } + > + {message && ( +
+ {message} +
+ )} - {message && ( -
- {message} -
- )} +
+
+ Subject Identifier (`sub`): + {user?.sub || 'usr_buyer@alpha.com'} +
-
-
- Subject Identifier (`sub`): - {user?.sub || 'N/A'} -
+
+ Email Address: + {user?.email || 'buyer@alpha.com'} +
-
- Email Address: - {user?.email || 'N/A'} -
+
+ Tenant Context: + {user?.tenant_id || 'tenant-alpha'} +
-
- Tenant Context: - {user?.tenant_id || 'tenant-alpha'} -
+
+ Effective RBAC Roles: +
+ {user?.roles?.map((role) => ( + + {role} + + )) || None} +
+
-
- Assigned Roles: -
- {user?.roles?.map((role) => ( - - {role} - - )) || None} +
+ Cryptographic Verification: + + + Verified S256 PKCE Code Challenge +
-
- Session Status: - - ● Active - +
+

+ Session revocation invalidates tokens immediately across trading desk endpoints. +

+
-
- -
- -
+
); }; - diff --git a/project_code/frontend/src/features/tenant/AuditLogView.tsx b/project_code/frontend/src/features/tenant/AuditLogView.tsx index 1958ea7..61e5ac7 100644 --- a/project_code/frontend/src/features/tenant/AuditLogView.tsx +++ b/project_code/frontend/src/features/tenant/AuditLogView.tsx @@ -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 ( -
-
+
+
-

Transaction Audit Trail

-

- Immutable, append-only mutation ledger for {activeBusinessName || 'Active Enterprise'} (FR-TENANTSECURITYAUDIT-003). +

Transaction Audit Trail

+

+ Immutable, append-only mutation ledger for {activeBusinessName || 'Active Enterprise'} (FR-TENANTSECURITYAUDIT-003)

-
- - Append-Only Statutory Ledger - -
+ + Append-Only Statutory Ledger +
{error && ( -
-

{error}

+
+ {error}
)} - {/* Audit Log Table */} -
-
-
-
- - - - - - - - - - - - - {events.length === 0 ? ( - - - - ) : ( - events.map((e) => ( - - - - - - - - - )) - )} - -
Timestamp (UTC)ActionEntity TypeEntity IDActor SubjectDetails
- No audit events recorded for this enterprise. -
- {new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)} - - - {e.action} - - {e.entity_type}{e.entity_id}{e.actor_id} - -
-
-
-
+ {/* Audit Log Table adhering to DESIGN.md */} +
+ + + + + + + + + + + + + {events.length === 0 ? ( + + + + ) : ( + events.map((e) => ( + + + + + + + + + )) + )} + +
Timestamp (UTC)ActionEntity TypeEntity IDActor SubjectPayload Diff
+ No governed audit events recorded for this enterprise. +
+ {new Date(e.timestamp).toISOString().replace('T', ' ').slice(0, 19)} + + + {e.entity_type}{e.entity_id}{e.actor_id} + +
{/* JSON Diff Inspection Modal */} {selectedEvent && ( -
-
-
setSelectedEvent(null)} /> -
-
-

- Audit Mutation Diff: {selectedEvent.entity_type} ({selectedEvent.action}) -

- {selectedEvent.audit_id} +
+
+
setSelectedEvent(null)} /> +
+
+
+

+ Mutation Diff: {selectedEvent.entity_type} +

+

+ Actor: {selectedEvent.actor_id} | {selectedEvent.timestamp} +

+
+
-
- Actor: {selectedEvent.actor_id} | Time: {selectedEvent.timestamp} + +
+
{JSON.stringify(selectedEvent.field_diff, null, 2)}
-
-
{JSON.stringify(selectedEvent.field_diff, null, 2)}
-
-
- + Close Inspection +
@@ -178,4 +181,3 @@ export const AuditLogView: React.FC = () => {
); }; - diff --git a/project_code/frontend/src/features/tenant/HeaderTenantSwitcher.tsx b/project_code/frontend/src/features/tenant/HeaderTenantSwitcher.tsx index f0382a9..e200596 100644 --- a/project_code/frontend/src/features/tenant/HeaderTenantSwitcher.tsx +++ b/project_code/frontend/src/features/tenant/HeaderTenantSwitcher.tsx @@ -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(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 = () => {
{isOpen && (
-
-

Trading Firms Directory

- {error &&

{error}

} +
+

Authorized Firms Directory

+ {error &&

{error}

}
{myTenants.length === 0 ? ( -
No authorized enterprises found.
+
No authorized enterprises found.
) : ( myTenants.map((t) => ( @@ -129,4 +137,3 @@ export const HeaderTenantSwitcher: React.FC = () => {
); }; - diff --git a/project_code/frontend/src/features/tenant/PlatformTenantsView.tsx b/project_code/frontend/src/features/tenant/PlatformTenantsView.tsx index 6d2a4fd..20f89d0 100644 --- a/project_code/frontend/src/features/tenant/PlatformTenantsView.tsx +++ b/project_code/frontend/src/features/tenant/PlatformTenantsView.tsx @@ -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 ( -
-
+
+
-

Platform Enterprise Directory

-

- Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001). +

Platform Trading Enterprises

+

+ Provision and govern multi-tenant agricultural trading enterprises (FR-TENANTLIFECYCLE-001)

-
- -
+
{error && ( -
-

{error}

+
+ {error}
)} - {/* Directory Table */} -
-
-
-
- - - - - - - - - - - - - {tenants.map((t) => ( - - - - - - - - - ))} - -
Business NameLegal GSTINPrimary MandiContact EmailLifecycle StatusActions
{t.business_name}{t.legal_identifier}{t.primary_mandi}{t.contact_email} - - {t.status} - - - {t.status !== 'CLOSED' && ( - - )} -
-
-
-
+ {/* Directory Table adhering to DESIGN.md tabular rules */} +
+ + + + + + + + + + + + + {tenants.map((t) => ( + + + + + + + + + ))} + +
Trading EnterpriseLegal GSTINPrimary MandiContact EmailLifecycle StatusActions
{t.business_name}{t.legal_identifier}{t.primary_mandi}{t.contact_email} + + + {t.status !== 'CLOSED' && ( + + )} +
{/* Provision Modal */} {showModal && ( -
-
-
setShowModal(false)} /> -
-

Provision New Enterprise

-
+
+
+
setShowModal(false)} /> +
+

Provision New Trading Enterprise

+

Registers enterprise entity within row-level multi-tenant database boundary

+ +
- + 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" />
- + 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" />
- + 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" />
- + 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" />
- + 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" />
-
- - + +
@@ -245,21 +240,21 @@ export const PlatformTenantsView: React.FC = () => { {/* Status Change Dialog */} {selectedTenant && ( -
-
-
setSelectedTenant(null)} /> -
-

Update Tenant Status

-

- Updating status for {selectedTenant.business_name} ({selectedTenant.status}). +

+
+
setSelectedTenant(null)} /> +
+

Update Lifecycle Status

+

+ Modifying state for {selectedTenant.business_name}

-
+
- +
- +