modcomms/frontend/types.ts
michael 05e74becfe Add frontend RBAC: UserContext, role-based sidebar, agency filter, user management
- Add UserRole type and AppUser interface to types.ts
- Create UserContext with useUser() hook providing role-based permission booleans
- Split App into App (auth wrapper) + AppContent (uses UserContext)
- Update Sidebar to filter nav items by UserRole instead of boolean isAdmin
- Add User Management nav item (super_admin only)
- Add AgencyFilterBar component for oversight_admin/super_admin session-level filtering
- Pass agencyId to getCampaigns, getAnalytics, audit endpoints in apiService
- Add getMe, getUsers, updateUser, createAgency to apiService
- Build UserManagement page with user table (role/agency dropdowns) and agency CRUD
- Add readOnly prop to Campaigns (hides create/delete/status-toggle for oversight_admin)
- Add readOnly prop to Settings (disables all ManagementCards, shows view-only banner)
- Pass agencyId to Analytics component for filtered data
- Update urlState with Knowledge Base and User Management views

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 08:36:38 -06:00

180 lines
4.2 KiB
TypeScript
Executable file

// Fix: Broke a circular dependency by defining the AgentName type directly in this file instead of importing it.
export type AgentName = 'Legal Agent' | 'Brand Agent' | 'Channel Best Practices Agent' | 'Channel Tech Specs Agent';
// RBAC types
export type UserRole = 'super_admin' | 'oversight_admin' | 'agency_admin' | 'basic_user';
export interface AppUser {
id: string;
email: string;
name: string;
role: UserRole;
agencyId: string | null;
agencyName: string | null;
}
export type AgentStatus = 'pending' | 'in-progress' | 'complete' | 'issues-found' | 'error';
export type ReviewStatus = {
[key in AgentName]?: AgentStatus;
};
export type RagStatus = 'Red' | 'Amber' | 'Green' | 'Error';
export interface SubReview {
ragStatus: RagStatus;
feedback: string;
issues: string[];
// Revision-aware fields (populated when analyzing version N > 1)
resolvedIssues?: string[];
outstandingIssues?: string[];
newIssues?: string[];
}
export type OverallStatus = 'Passed' | 'Failed' | 'Analysis Error' | 'Requires Manual Legal Review';
export interface AgentReview {
legalAgentReview: SubReview;
brandAgentReview: SubReview;
channelBestPracticesAgentReview: SubReview;
channelTechSpecsAgentReview: SubReview;
leadAgentSummary: string;
overallStatus: OverallStatus;
financialPromotionReason?: string;
}
export interface FlaggedItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
agentFlagged: string;
comments: string;
timestamp: string;
}
export interface ResolvedItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
agent: string;
issue: string;
resolution: string;
timestamp: string;
}
export interface ErrorItem {
id: string;
campaignName: string;
proofName: string;
version: number;
submitter: string;
submitAgency: string;
errorSummary: string;
timestamp: string;
}
export interface PDFPage {
page: number;
data_url: string;
width: number;
height: number;
}
export interface ProofVersion {
version: number;
timestamp: string;
workfrontId: string;
proofPreviewUrl?: string;
fileStorageKey?: string;
feedback: AgentReview;
isIdenticalFile?: boolean;
}
// Knowledge Base types
export interface KnowledgeBaseListItem {
id: string;
agent_key: string;
display_name: string;
description: string | null;
source_document_count: number;
active_spec_version: number | null;
active_spec_char_count: number | null;
latest_job_status: string | null;
latest_job_completed_at: string | null;
created_at: string;
}
export interface SourceDocument {
id: string;
knowledge_base_id: string;
filename: string;
file_storage_key: string;
file_size_bytes: number;
mime_type: string;
uploaded_by_name: string | null;
parse_status: string;
parse_error: string | null;
created_at: string;
}
export interface ProcessingJob {
id: string;
knowledge_base_id: string;
status: string;
triggered_by_name: string | null;
total_documents: number;
parsed_documents: number;
spec_version_id: string | null;
error_message: string | null;
started_at: string | null;
completed_at: string | null;
created_at: string;
}
export interface KnowledgeBaseDetail {
id: string;
agent_key: string;
display_name: string;
description: string | null;
source_documents: SourceDocument[];
active_spec_version: number | null;
active_spec_char_count: number | null;
latest_job: ProcessingJob | null;
created_at: string;
}
export interface SpecVersionListItem {
id: string;
knowledge_base_id: string;
version_number: number;
generated_by_name: string | null;
source_document_ids: string[] | null;
is_active: boolean;
char_count: number;
created_at: string;
}
export interface SpecVersionDetail extends SpecVersionListItem {
content: string;
}
export interface DiffLine {
type: 'add' | 'remove' | 'context';
content: string;
line_number_old: number | null;
line_number_new: number | null;
}
export interface DiffResult {
version_a: number;
version_b: number;
additions: number;
deletions: number;
lines: DiffLine[];
}