Skip to content

feat(ticketing): complete V2 ticketing system rebuild#112

Open
TristanHourtoulle wants to merge 37 commits intodevfrom
feature/tri-93
Open

feat(ticketing): complete V2 ticketing system rebuild#112
TristanHourtoulle wants to merge 37 commits intodevfrom
feature/tri-93

Conversation

@TristanHourtoulle
Copy link
Member

Summary

Complete rebuild of the ticketing system (V2) from scratch. Replaces the old monolithic ticketing code with a clean architecture: typed service layer, domain hooks, modular UI components, admin dashboard, and comprehensive unit tests.

Type of Change

  • Feature
  • Refactoring

Changes Overview

Foundation

  • Delete all existing ticketing code and start fresh
  • New TypeScript types, Zod validation schemas, and file upload utilities (lib/types/ticket.ts, lib/schemas/ticket.ts, lib/utils/file-upload.ts)
  • New constants with French translations for status, type, urgency labels (lib/constants/ticket.ts)
  • Ticket helper utilities: date formatting, badge colors, status transitions, unread detection (lib/utils/ticket-helpers.ts)

Service Layer

  • useTicketService() hook with 14 typed methods returning ApiResult<T> (services/ticket.ts)
  • Toast translations for all ticket operations (lib/toast.ts)

Domain Hooks

  • useTicket() — single ticket detail: fetch, messages, polling with Page Visibility API, reopen, optimistic updates (hooks/useTicket.ts)
  • useTicketList() — user ticket listing: filters, pagination, URL sync, debounced search (hooks/useTicketList.ts)
  • useTicketConfig() — dynamic config fetching with active filter and sort (hooks/useTicketConfig.ts)
  • useAdminTickets() — admin dashboard state: filters, sorting, selection, bulk ops (hooks/useAdminTickets.ts)
  • useDraftPersistence() — localStorage draft auto-save for ticket creation form (hooks/useDraftPersistence.ts)

User Pages

  • /support — ticket list with filters, search, pagination, unread indicators
  • /support/new — ticket creation form with React Hook Form + Zod, type card grid, file dropzone, draft persistence
  • /tickets/[id] — two-column conversation layout with message polling, sidebar, mobile Sheet

Admin Pages

  • /admin/tickets — admin dashboard with stats bar, data table, bulk actions, quick row updates

UI Components (16 components)

  • Message components: message-thread, message-bubble (4 variants), message-input
  • Ticket components: ticket-card, ticket-header, ticket-sidebar (with admin controls), status-badge
  • Form components: file-dropzone, type-card-grid, ticket-filters, ticket-pagination
  • Display components: ticket-empty-state, ticket-card-skeleton, ticket-stats-bar, attachment-preview
  • Admin components: admin-ticket-table, admin-stats-bar, admin-ticket-filters, admin-bulk-toolbar

Unit Tests (47+ new tests across 12 files)

  • Zod schema validation (25 tests)
  • MessageBubble component rendering (14 tests)
  • File upload utilities including compression edge cases (19 tests)
  • Ticket helpers, service methods, hooks, and UI components

Technical Details

Files Changed: ~67 files
Main Areas:

  • hooks/ — 5 new domain hooks
  • components/ticket/ — 16 new UI components + 4 admin components
  • services/ticket.ts — complete service rewrite with ApiResult<T> pattern
  • lib/ — types, schemas, constants, utilities
  • tests/unit/ — 12 test files

Testing

  • All 47+ new unit tests pass (npx vitest run)
  • TypeScript compiles without errors (npx tsc --noEmit)
  • No regressions in existing tests

Breaking Changes

  • Old ticketing routes and components are fully replaced
  • Old useTicket hook replaced with new implementation (different API surface)

Deployment Notes

  • Backend must have the new ticketing endpoints deployed (TRI-88, TRI-89, TRI-90)
  • Run ticket config seed (TRI-89) before first use

Remove all frontend ticketing code (types, services, hooks, components,
pages, tests, docs) and clean up references in navigation, toasts, and
role permissions. This clears the way for the TICKETING-V2 rebuild.

Closes TRI-85
…tilities for V2

Lay the frontend foundations for the ticketing V2 system:
- Types and interfaces aligned with backend MongoDB schemas
- Zod validation schemas for ticket and message creation forms
- File utilities for validation, image compression, and Base64 conversion
…ons for V2

Implements the full service layer with CRUD operations, admin endpoints,
config hook for ticket metadata, and French toast translations.
…dependencies

- Add JSDoc to useTicketConfig and useTicketService custom hooks
- Add axios status/statusText logging in logError per service-logging standard
- Use useRef for ticketService to stabilize fetchConfigs/refetch references
…file upload

- tests/unit/services/ticket.test.ts: 12 tests for all service methods
- tests/unit/hooks/useTicketConfig.test.ts: 7 tests for config fetching, filtering, refetch
- tests/unit/lib/file-upload.test.ts: 12 tests for validation, compression, base64 conversion
Create 7 components for the ticket conversation UI (TRI-97):
- AttachmentPreview: image thumbnail with lightbox, document card with download
- MessageBubble: 4 visual styles (own/admin/internal/system)
- MessageThread: scrollable list with date separators, auto-scroll, internal filtering
- MessageInput: auto-resize textarea, file attachments, admin visibility toggle
- TicketHeader: back link, reference copy, status/priority badges, reopen button
- TicketSidebar: metadata, timestamps, collapsible status history
- Barrel index.ts for all ticket component exports
…layout

Create /tickets/[id] page (TRI-96) with:
- Ticket fetch by reference/ID + message polling every 20s
- Two-column layout: conversation left, metadata sidebar right
- Mobile responsive: sidebar collapses to Sheet drawer
- Description block with attachment thumbnails
- Loading skeletons and not-found empty state
- Reopen action with toast feedback
…page

Extract ticket creation form from modal into a full page with:
- Back button, card-wrapped form, cancel/submit buttons
- Navigate from /support to /support/new instead of opening dialog
- Remove skeleton flickering on search by tracking initial load state
…ency color coding

- Replace Radix Select with Popover+Command combobox for all 4 filters
- Redesign search bar with visible icon, focus ring, and clear button
- Add URGENCY_COLORS mapping (gray/amber/orange/red) for ticket cards
…bility

- Add scrollbar-gutter: stable on html to prevent shift when Radix locks scroll
- Remove height constraint on Select viewport that caused layout issues
- Increase search icon opacity in CommandInput from 50 to 70
…ce for V2

Includes modified hooks, schemas, file upload utils, and service layer
needed by the new ticketing UI components and pages.
…lities

Tests for FileDropzone, StatusBadge, TicketCard, TicketEmptyState,
TicketStatsBar, TypeCardGrid, and useDraftPersistence hook.
Adds FileDropzone, StatusBadge, TicketCardSkeleton, TicketEmptyState,
TicketStatsBar, and TypeCardGrid components used across support pages.
… admin controls

Implements TRI-100 (shared helpers) and TRI-99 (admin sidebar controls).
Adds PopulatedUser/AdminUser types, getAdminUsers service, admin toasts,
and editable status/priority/assignee/tags controls in the ticket sidebar.
Replace inline date formatting, permission checks, and populated field
resolvers with imports from lib/utils/ticket-helpers.
…filters, and updatedAt sort

- New TicketPagination component with page numbers, jump-to-page, configurable page size (10/20/50)
- Support page: all filters (type, category, urgency) now sent to backend instead of client-side filtering
- Both pages: state synced to URL search params (page, limit, filters, sort) for bookmarkable/shareable URLs
- Default sort changed from createdAt to updatedAt (most recently updated first)
- Smooth scroll-to-top on page/filter/sort changes
- Blue-600 gradient theme matching site design
@TristanHourtoulle TristanHourtoulle added enhancement Style / UI-UX improvements feature New feature labels Mar 2, 2026
@TristanHourtoulle TristanHourtoulle self-assigned this Mar 2, 2026
…ities

Strengthen Record types with union keys (TicketStatus, TicketType, etc.),
move filter interfaces and defaults into lib/constants/ticket.ts, and
extract pagination helpers into a dedicated utility module.
Move message submission from MessageInput into useTicket hook, extract
admin ticket controls from sidebar into dedicated component, and update
all pages/components to use centralized filter constants and pagination.
Replace form.watch subscription with useRef-based debounce to prevent
stale closure issues and ensure proper cleanup on unmount.
Cast unknown status/type values in tests to match strengthened union
types and fix expected API payloads for updateTicket and bulkUpdate.
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 74.38% 723 / 972
🔵 Statements 74.59% 778 / 1043
🔵 Functions 62.6% 154 / 246
🔵 Branches 68.51% 359 / 524
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
components/ticket/file-dropzone.tsx 40.81% 32.14% 72.22% 38.63% 53-79, 88-109
components/ticket/message-bubble.tsx 100% 100% 100% 100%
components/ticket/status-badge.tsx 100% 100% 100% 100%
components/ticket/ticket-card.tsx 100% 83.33% 100% 100%
components/ticket/ticket-empty-state.tsx 100% 100% 100% 100%
components/ticket/ticket-stats-bar.tsx 100% 81.81% 100% 100%
components/ticket/type-card-grid.tsx 100% 76.19% 100% 100%
hooks/useDraftPersistence.ts 77.27% 62.5% 71.42% 86.48% 25, 32, 35, 60, 63-69
hooks/useTicketConfig.ts 97.61% 90.9% 100% 100% 80
lib/toast.ts 18.62% 8.33% 1.61% 18.62% 91, 97, 106, 117-152, 304-357, 363-372, 376-382, 386-391, 396-399, 404-407, 411-418, 423-464
lib/constants/ticket.ts 100% 100% 100% 100%
lib/schemas/ticket.ts 100% 100% 100% 100%
lib/utils/file-upload.ts 94.11% 90.9% 87.5% 95.83% 80, 98, 101
lib/utils/ticket-helpers.ts 100% 100% 100% 100%
services/ticket.ts 60.16% 47.91% 66.66% 57% 68, 86-91, 145-146, 157-158, 165-173, 189-190, 198-207, 214-223, 238-239, 255-256, 263-272, 281-294, 315-316, 321-328
Generated in workflow #13 for commit 0a65428 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Style / UI-UX improvements feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant