Files
techxcar/frontend/src/lib/workOrderStatus.ts
T

49 lines
1.7 KiB
TypeScript

import type { WorkOrder } from '@/lib/types'
export const WORK_ORDER_STATUS_LABEL: Record<WorkOrder['status'], string> = {
quote: 'Orçamento',
in_progress: 'Iniciar Trabalho',
completed: 'Concluir OT',
invoiced: 'Faturado',
cancelled: 'Cancelada',
}
const LIGHT_STATUS_BADGE: Record<WorkOrder['status'], string> = {
quote: 'border-[var(--ui-warning)] bg-[var(--ui-warning)] text-[var(--ui-warning-text)]',
in_progress: 'border-indigo-400 bg-indigo-100 text-slate-800',
completed: 'border-emerald-400 bg-emerald-100 text-slate-800',
invoiced: 'border-teal-400 bg-teal-100 text-slate-800',
cancelled: 'border-[var(--ui-danger)] bg-[var(--ui-danger)] text-[var(--ui-danger-text)]',
}
export function workOrderStatusBadgeClass(status: WorkOrder['status']) {
return `border ${LIGHT_STATUS_BADGE[status]}`
}
export type WorkOrderPhase = 'draft' | 'active' | 'done' | 'cancelled'
export const WORK_ORDER_PHASE_LABEL: Record<WorkOrderPhase, string> = {
draft: 'Orçamento',
active: 'Iniciar Trabalho',
done: 'Concluir OT',
cancelled: 'Cancelada',
}
const PHASE_BADGE: Record<WorkOrderPhase, string> = {
draft: 'border-amber-300 bg-amber-100 text-amber-900',
active: 'border-blue-300 bg-blue-100 text-blue-900',
done: 'border-emerald-300 bg-emerald-100 text-emerald-900',
cancelled: 'border-[var(--ui-danger)] bg-[var(--ui-danger)] text-[var(--ui-danger-text)]',
}
export function getWorkOrderPhase(status: WorkOrder['status']): WorkOrderPhase {
if (status === 'cancelled') return 'cancelled'
if (status === 'quote') return 'draft'
if (status === 'in_progress') return 'active'
return 'done'
}
export function workOrderPhaseBadgeClass(phase: WorkOrderPhase) {
return `border ${PHASE_BADGE[phase]}`
}