refactor: standardize task and recurrence type strings to lowercase across components and services
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { apiClient } from '../client'
|
||||
import type { ApiResponse } from '../types'
|
||||
|
||||
// Task types
|
||||
export type TaskType = 'CREDIT_RECHARGE' | 'PLAY_SOUND' | 'PLAY_PLAYLIST'
|
||||
// Task types (backend expects lowercase)
|
||||
export type TaskType = 'credit_recharge' | 'play_sound' | 'play_playlist'
|
||||
|
||||
export type TaskStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED'
|
||||
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
|
||||
|
||||
export type RecurrenceType = 'NONE' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY' | 'CRON'
|
||||
export type RecurrenceType = 'none' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'cron'
|
||||
|
||||
// Task interfaces
|
||||
export interface ScheduledTask {
|
||||
@@ -134,11 +134,11 @@ export const schedulersService = {
|
||||
// Utility functions
|
||||
export function getTaskTypeLabel(taskType: TaskType): string {
|
||||
switch (taskType) {
|
||||
case 'CREDIT_RECHARGE':
|
||||
case 'credit_recharge':
|
||||
return 'Credit Recharge'
|
||||
case 'PLAY_SOUND':
|
||||
case 'play_sound':
|
||||
return 'Play Sound'
|
||||
case 'PLAY_PLAYLIST':
|
||||
case 'play_playlist':
|
||||
return 'Play Playlist'
|
||||
default:
|
||||
return taskType
|
||||
@@ -147,15 +147,15 @@ export function getTaskTypeLabel(taskType: TaskType): string {
|
||||
|
||||
export function getTaskStatusLabel(status: TaskStatus): string {
|
||||
switch (status) {
|
||||
case 'PENDING':
|
||||
case 'pending':
|
||||
return 'Pending'
|
||||
case 'RUNNING':
|
||||
case 'running':
|
||||
return 'Running'
|
||||
case 'COMPLETED':
|
||||
case 'completed':
|
||||
return 'Completed'
|
||||
case 'FAILED':
|
||||
case 'failed':
|
||||
return 'Failed'
|
||||
case 'CANCELLED':
|
||||
case 'cancelled':
|
||||
return 'Cancelled'
|
||||
default:
|
||||
return status
|
||||
@@ -164,19 +164,19 @@ export function getTaskStatusLabel(status: TaskStatus): string {
|
||||
|
||||
export function getRecurrenceTypeLabel(recurrenceType: RecurrenceType): string {
|
||||
switch (recurrenceType) {
|
||||
case 'NONE':
|
||||
case 'none':
|
||||
return 'None'
|
||||
case 'HOURLY':
|
||||
case 'hourly':
|
||||
return 'Hourly'
|
||||
case 'DAILY':
|
||||
case 'daily':
|
||||
return 'Daily'
|
||||
case 'WEEKLY':
|
||||
case 'weekly':
|
||||
return 'Weekly'
|
||||
case 'MONTHLY':
|
||||
case 'monthly':
|
||||
return 'Monthly'
|
||||
case 'YEARLY':
|
||||
case 'yearly':
|
||||
return 'Yearly'
|
||||
case 'CRON':
|
||||
case 'cron':
|
||||
return 'Custom'
|
||||
default:
|
||||
return recurrenceType
|
||||
@@ -185,15 +185,15 @@ export function getRecurrenceTypeLabel(recurrenceType: RecurrenceType): string {
|
||||
|
||||
export function getTaskStatusVariant(status: TaskStatus): 'default' | 'secondary' | 'destructive' | 'outline' {
|
||||
switch (status) {
|
||||
case 'PENDING':
|
||||
case 'pending':
|
||||
return 'outline'
|
||||
case 'RUNNING':
|
||||
case 'running':
|
||||
return 'default'
|
||||
case 'COMPLETED':
|
||||
case 'completed':
|
||||
return 'secondary'
|
||||
case 'FAILED':
|
||||
case 'failed':
|
||||
return 'destructive'
|
||||
case 'CANCELLED':
|
||||
case 'cancelled':
|
||||
return 'outline'
|
||||
default:
|
||||
return 'default'
|
||||
|
||||
Reference in New Issue
Block a user