All files / src/utils ticketStatus.ts

51.21% Statements 21/41
42.85% Branches 3/7
100% Functions 1/1
51.21% Lines 21/41

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50  1x               1x 5x 5x 3x 3x 3x 3x 3x 5x           5x 2x 2x 2x 2x 2x 5x           5x           5x           5x 5x  
import type { TicketStatus } from '@/models/ticket';
import i18n from '@/i18n';
 
export interface TicketStatusPresentation {
  label: string;
  tone: 'active' | 'pending' | 'expired' | 'used' | 'canceled';
  description: string;
}
 
export function getTicketStatusPresentation(status: TicketStatus): TicketStatusPresentation {
  switch (status) {
    case 'ACTIVE':
      return {
        label: i18n.t('tickets.status.ACTIVE'),
        tone: 'active',
        description: i18n.t('tickets.status_descriptions.ACTIVE'),
      };
    case 'PENDING':
      return {
        label: i18n.t('tickets.status.PENDING'),
        tone: 'pending',
        description: i18n.t('tickets.status_descriptions.PENDING'),
      };
    case 'USED':
      return {
        label: i18n.t('tickets.status.USED'),
        tone: 'used',
        description: i18n.t('tickets.status_descriptions.USED'),
      };
    case 'EXPIRED':
      return {
        label: i18n.t('tickets.status.EXPIRED'),
        tone: 'expired',
        description: i18n.t('tickets.status_descriptions.EXPIRED'),
      };
    case 'CANCELED':
      return {
        label: i18n.t('tickets.status.CANCELED'),
        tone: 'canceled',
        description: i18n.t('tickets.status_descriptions.CANCELED'),
      };
    default:
      return {
        label: status,
        tone: 'pending',
        description: i18n.t('tickets.status_descriptions.UNKNOWN'),
      };
  }
}