big refactor

This commit is contained in:
2026-04-29 16:25:11 -05:00
parent 6c411ce2b6
commit 8265fb689a
156 changed files with 15845 additions and 50373 deletions

View File

@@ -1,9 +1,108 @@
<script setup lang="ts">
import { TIER_LABELS, QUEUE_LABELS, type RoutingTier, type RoutedQueue, type RoutingRule } from '~/data/mock-support'
usePageTitle('Support Routing')
const { state, toggleRule, updateRule } = useSupportTickets()
type RoutingTier = 'tier1_auto' | 'tier2_rule' | 'tier3_open'
type RoutedQueue = 'collections' | 'claims' | 'sales' | 'renewals' | 'operations' | 'open_pool'
interface RoutingRule {
id: string
name: string
condition: string
tier: RoutingTier
targetQueue: RoutedQueue
enabled: boolean
}
interface SupportState {
routingRules: RoutingRule[]
}
const STORAGE_KEY = 'policy-ui.support-routing'
function loadState(): SupportState {
if (import.meta.client) {
const stored = localStorage.getItem(STORAGE_KEY)
if (stored) {
try {
return JSON.parse(stored)
} catch {
return defaultState()
}
}
}
return defaultState()
}
function defaultState(): SupportState {
return {
routingRules: [
{
id: '1',
name: 'Existing customer with LOB',
condition: 'Customer exists and has LOB in message',
tier: 'tier1_auto',
targetQueue: 'operations',
enabled: true
},
{
id: '2',
name: 'Web form submission',
condition: 'Form submission with customer data',
tier: 'tier1_auto',
targetQueue: 'sales',
enabled: true
},
{
id: '3',
name: 'Payment inquiry',
condition: 'Keywords: pago, factura, cobro, payment',
tier: 'tier2_rule',
targetQueue: 'collections',
enabled: true
},
{
id: '4',
name: 'Claim inquiry',
condition: 'Keywords: siniestro, reclamo, claim, accident',
tier: 'tier2_rule',
targetQueue: 'claims',
enabled: true
},
{
id: '5',
name: 'Renewal inquiry',
condition: 'Keywords: renovación, renewal, vence',
tier: 'tier2_rule',
targetQueue: 'renewals',
enabled: true
},
]
}
}
const state = ref<SupportState>(loadState())
function saveState() {
if (import.meta.client) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state.value))
}
}
function toggleRule(id: string) {
const rule = state.value.routingRules.find(r => r.id === id)
if (rule) {
rule.enabled = !rule.enabled
saveState()
}
}
function updateRule(id: string, updates: Partial<RoutingRule>) {
const idx = state.value.routingRules.findIndex(r => r.id === id)
if (idx !== -1) {
state.value.routingRules[idx] = { ...state.value.routingRules[idx], ...updates }
saveState()
}
}
type TierTab = 'tier1' | 'tier2' | 'tier3'
const activeTier = ref<TierTab>('tier1')
@@ -26,12 +125,21 @@ const queueOptions: { label: string; value: RoutedQueue }[] = [
{ label: 'Pool Abierto', value: 'open_pool' },
]
// Tier 3 settings (mock)
const QUEUE_LABELS: Record<RoutedQueue, string> = {
collections: 'Cobros',
claims: 'Siniestros',
sales: 'Ventas',
renewals: 'Renovaciones',
operations: 'Operaciones',
open_pool: 'Pool Abierto',
}
const tier3DefaultAssignee = ref('Round-robin')
const tier3EscalationHours = ref(4)
const toast = useToast()
function handleSave() {
saveState()
toast.add({ title: 'Configuración guardada', color: 'green' })
}
</script>