Future Admin Portal Features
This document tracks planned features for the Admin Portal that need to be built out.
Status Legend
- 🔴 Critical: Core functionality, blocks other features
- 🟠 High: Important for usability, should prioritize
- 🟡 Medium: Nice to have, improves workflows
- ⚪ Low: Enhancement, can defer
🟠 Team Alias Management
Priority: High Effort: Medium (2-3 days) Dependencies: None Status: Not Started
Problem Statement
Currently, team aliases can only be managed directly via SQL queries in Supabase. When team sync conflicts detect alias conflicts, administrators have no UI to: - View all aliases for a team - Add new aliases - Edit or remove existing aliases - Resolve alias conflicts from the admin portal
This forces manual SQL operations, which is error-prone and requires database access.
Proposed Solution
Build a Team Alias Management interface in the Admin Portal (admin.epgoat.tv) with the following capabilities:
1. View Team Aliases
- Page:
/teams/:id/aliases - Features:
- List all aliases for a team in a table
- Show alias type (nickname, abbreviation, alternate_spelling, historical, etc.)
- Display creation date and who added it
- Sort and filter aliases
- Search across all aliases
2. Add New Alias
- UI: Modal or inline form
- Fields:
- Alias name (required, text input)
- Alias type (required, dropdown: nickname, abbreviation, alternate_spelling, historical, international, other)
- Notes (optional, textarea)
- Validation:
- Check if alias already exists for this team (show warning, allow duplicate)
- Check if alias is used by another team (show error, prevent unless force-override)
- Normalize alias name for comparison
- Action: Insert into
team_aliasestable with audit trail
3. Edit Existing Alias
- UI: Inline edit or modal
- Editable Fields:
- Alias name
- Alias type
- Notes
- Validation: Same as Add New Alias
- Action: Update
team_aliasesrecord with audit trail
4. Delete Alias
- UI: Delete button with confirmation dialog
- Confirmation: "Are you sure you want to delete alias '{alias_name}' for {team_name}?"
- Action: Soft delete (set
deleted_attimestamp) or hard delete - Audit: Log deletion in
team_sync_audit_log
5. Resolve Alias Conflicts from Portal
- Context: When viewing a team sync conflict with
conflict_type = 'alias_conflict' - Page:
/conflicts/:id - Actions:
- Add as Alias: Add the conflicting name as an alias to the existing team
- Ignore: Mark conflict as resolved without adding alias
- Create New Team: Create a separate team with this name
- Manual Review: Mark for manual review later
- Integration: Use
TeamSyncConflictAPI.resolve_conflict()backend API
6. Bulk Import/Export
- Export:
- Button: "Export Team Aliases"
- Format: CSV with columns:
team_id,canonical_name,alias_name,alias_type,notes,created_at - Scope: All aliases or filtered by team/league/sport
- Import:
- Upload CSV file
- Validate: Check for duplicate aliases, missing teams
- Preview: Show what will be added/updated
- Execute: Bulk insert with transaction
- Report: Show success/failure counts and errors
7. Alias Search Across All Teams
- Page:
/aliases - Features:
- Global search input
- Filter by alias type, team, league, sport
- Results table:
alias_name,team_name,league,alias_type,created_at - Click to view team details
- Quick actions: Edit, Delete
Database Schema (Already Exists)
CREATE TABLE team_aliases (
id BIGSERIAL PRIMARY KEY,
team_id BIGINT NOT NULL REFERENCES teams(id) ON DELETE CASCADE,
alias_name TEXT NOT NULL,
alias_type TEXT, -- 'nickname', 'abbreviation', 'alternate_spelling', 'historical', etc.
notes TEXT,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
deleted_at TIMESTAMP -- Soft delete support
);
CREATE INDEX idx_team_aliases_team_id ON team_aliases(team_id);
CREATE INDEX idx_team_aliases_alias_name ON team_aliases(LOWER(alias_name));
API Endpoints (To Be Created)
Backend: Cloudflare Workers Functions
// GET /api/teams/:id/aliases
// Returns: Array of aliases for a team
export interface TeamAlias {
id: number;
team_id: number;
alias_name: string;
alias_type: string;
notes?: string;
created_at: string;
updated_at: string;
}
// POST /api/teams/:id/aliases
// Body: { alias_name, alias_type, notes }
// Returns: Created alias
// PUT /api/aliases/:id
// Body: { alias_name, alias_type, notes }
// Returns: Updated alias
// DELETE /api/aliases/:id
// Returns: Success message
// GET /api/aliases/search?q=Lakers
// Returns: Array of matching aliases with team info
// POST /api/aliases/bulk-import
// Body: { aliases: Array<{team_id, alias_name, alias_type, notes}> }
// Returns: { success_count, error_count, errors: Array }
// POST /api/conflicts/:id/add-alias
// Body: { team_id, alias_name, alias_type, notes }
// Returns: { alias, conflict_resolution }
Frontend Components (To Be Created)
React Components (Admin Portal)
src/components/teams/
├── TeamAliasesTab.tsx // Main aliases view for a team
├── AliasTable.tsx // Table of aliases
├── AddAliasModal.tsx // Modal to add new alias
├── EditAliasModal.tsx // Modal to edit alias
├── DeleteAliasDialog.tsx // Confirmation dialog
└── AliasConflictChecker.tsx // Real-time conflict checking
src/components/aliases/
├── AliasSearchPage.tsx // Global alias search
├── BulkImportModal.tsx // CSV import interface
└── AliasTypeSelect.tsx // Dropdown for alias types
src/components/conflicts/
└── ConflictResolutionActions.tsx // Action buttons for conflicts
User Workflows
Workflow 1: Add Alias from Team Page
- Navigate to team details page
- Click "Aliases" tab
- Click "Add Alias" button
- Enter alias name and type
- System checks for conflicts
- If conflict: Show warning with option to add anyway
- If no conflict: Add immediately
- Show success notification
Workflow 2: Resolve Alias Conflict
- Navigate to Conflicts page
- View conflict with
alias_conflicttype - See existing team and conflicting alias name
- Choose action:
- "Add as Alias" → Opens modal with pre-filled alias name
- "Ignore" → Mark resolved without adding
- "Create New Team" → Opens team creation form
- Confirm action
- Conflict marked as resolved
Workflow 3: Bulk Import Aliases
- Navigate to Aliases page
- Click "Import" button
- Download CSV template
- Fill in CSV with aliases
- Upload CSV file
- Review preview of changes
- Confirm import
- View import results (success/errors)
Security & Validation
Authorization: - Only admins can manage aliases - Check user role before allowing modifications - Log all alias changes in audit table
Validation Rules: - Alias name: 1-100 characters - Alias name cannot be empty or whitespace-only - Alias type: Must be from predefined list - Duplicate check: Warn if alias exists for same team - Conflict check: Error if alias used by different team
Data Integrity: - Use transactions for bulk operations - Validate team_id exists before inserting alias - Normalize alias names for comparison (lowercase, trim) - Prevent circular references
Testing Requirements
Unit Tests: - Alias validation logic - Duplicate detection - Conflict checking - Normalization functions
Integration Tests: - CRUD operations for aliases - Bulk import with various CSV formats - Conflict resolution workflows - Authorization checks
E2E Tests: - Add alias via UI - Edit and delete alias - Resolve conflict by adding alias - Bulk import happy path and error cases
Success Metrics
- Efficiency: Reduce time to manage aliases from 5 min (SQL) to 30 sec (UI)
- Accuracy: Reduce alias errors by 80% with validation
- Usage: Admin uses alias management UI at least weekly
- Conflicts: 90% of alias conflicts resolved from portal (not SQL)
Implementation Plan
Phase 1: Basic CRUD (1 day) - API endpoints for CRUD operations - Basic UI for viewing/adding/editing/deleting aliases - Validation and conflict checking
Phase 2: Conflict Resolution (1 day) - Integrate with conflict resolution UI - Add "Add as Alias" action to conflict page - Test conflict resolution workflow
Phase 3: Advanced Features (0.5 days) - Global alias search - Bulk import/export - Enhanced validation and UX improvements
Phase 4: Testing & Deployment (0.5 days) - Write tests - User acceptance testing - Deploy to production - Document for users
Related Documentation
Open Questions
- Alias Types: Do we need more alias types beyond: nickname, abbreviation, alternate_spelling, historical, international?
- Soft Delete: Should we soft delete aliases or hard delete?
- Approval Workflow: Should alias additions require approval, or apply immediately?
- Historical Tracking: Should we keep history of alias changes?
- Bulk Limits: What's the max number of aliases in a single bulk import?
Notes
- This feature came up during team sync conflict resolution testing
- Currently 0 alias conflicts detected, but want to be prepared
- Manual SQL operations are error-prone and don't scale
- Admin portal should be the single source of truth for team management
Other Planned Features
🟡 Match Override Approval Workflow
Status: Planned Description: Add approval step for match overrides before they go live
🟡 Event Search Filters
Status: Planned Description: Add filters for date range, league, sport in event search
⚪ Bulk Match Override Import
Status: Idea Description: CSV import for match overrides
⚪ Analytics Dashboard
Status: Idea Description: Charts and metrics for team sync health, match overrides, etc.
Last Updated: 2025-11-06 Next Review: 2025-12-01