* feat: Add routing trace presenters Add domain-specific presenters (SalesforceRoutingTracePresenter, RoutingFormTracePresenter) that format trace steps into human-readable strings, and a core RoutingTracePresenter that delegates to them based on step domain. Includes unit tests for all presenters. Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat: Add findByBookingUid to RoutingTraceRepository Add method to look up a routing trace by booking UID, needed by the routing trace presenter tRPC endpoint. Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat: Add getRoutingTrace tRPC endpoint Expose routing trace data for a booking via viewer.bookings.getRoutingTrace. Tries the permanent RoutingTrace first (round robin bookings), then falls back to PendingRoutingTrace via the booking's form response relation. Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat: Add routing trace side sheet to booking list item Add a route icon button on booking list items that came from routing forms. Clicking it opens a side sheet displaying the full routing trace as human-readable steps. Adds RoutingTraceSheet component, store state, and translation key. Co-Authored-By: Claude Opus 4.5 <[email protected]> * refactor: Move routing trace action to dropdown menu Move the routing trace button from a standalone icon on the booking list item into the actions dropdown menu alongside "Report wrong assignment". The RoutingTraceSheet is now rendered from BookingActionsDropdown. Co-Authored-By: Claude Opus 4.5 <[email protected]> * fix: Improve routing trace UI and handle unnamed routes - Redesign RoutingTraceSheet with vertical timeline layout, domain badges, skeleton loading state, and millisecond timestamps - Use Salesforce app-store icon for Salesforce steps - Fall back to "Unnamed route" when route name is missing or matches route ID - Fix dropdown menu icon to git-merge (valid icon, unique in menu) Co-Authored-By: Claude Opus 4.5 <[email protected]> * test: Add tests for getRoutingTrace handler and findByBookingUid repository method Co-Authored-By: [email protected] <[email protected]> * Abstract functions * Fix build error * Add permission check * fix: Update getRoutingTrace tests to include ctx and mock BookingAccessService Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import type { RoutingStep } from "../repositories/RoutingTraceRepository.interface";
|
|
|
|
export class RoutingFormTracePresenter {
|
|
static present(step: RoutingStep): string {
|
|
const d = step.data;
|
|
const routeName = d.routeName && d.routeName !== d.routeId ? d.routeName : "Unnamed route";
|
|
switch (step.step) {
|
|
case "route_matched":
|
|
return `Route matched: "${routeName}" (ID: ${d.routeId})`;
|
|
case "fallback_route_used":
|
|
return `Fallback route used: "${routeName}" (ID: ${d.routeId})`;
|
|
case "attribute-logic-evaluated": {
|
|
const parts: string[] = [];
|
|
parts.push(`Route: "${routeName}"`);
|
|
if (d.routeIsFallback) parts.push("(fallback)");
|
|
if (d.attributeRoutingDetails && Array.isArray(d.attributeRoutingDetails)) {
|
|
const details = (d.attributeRoutingDetails as Array<{ attributeName: string; attributeValue: string }>)
|
|
.map((a) => `${a.attributeName}=${a.attributeValue}`)
|
|
.join(", ");
|
|
parts.push(`Attributes: [${details}]`);
|
|
}
|
|
return `Attribute logic evaluated: ${parts.join(" ")}`;
|
|
}
|
|
case "attribute_fallback_used":
|
|
return `Attribute fallback used: "${routeName}"`;
|
|
default:
|
|
return `Routing Form: ${step.step}`;
|
|
}
|
|
}
|
|
}
|