constants.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { type StatusBadgeProps } from '@/components/status-badge'
  2. // ============================================================================
  3. // API Key Status Configuration
  4. // label values are i18n keys; use t(config.label) in components (e.g. StatusBadge)
  5. // ============================================================================
  6. export const API_KEY_STATUS = {
  7. ENABLED: 1,
  8. DISABLED: 2,
  9. EXPIRED: 3,
  10. EXHAUSTED: 4,
  11. } as const
  12. export const API_KEY_STATUSES: Record<
  13. number,
  14. Pick<StatusBadgeProps, 'variant' | 'showDot'> & {
  15. label: string
  16. value: number
  17. }
  18. > = {
  19. [API_KEY_STATUS.ENABLED]: {
  20. label: 'Enabled',
  21. variant: 'success',
  22. value: API_KEY_STATUS.ENABLED,
  23. showDot: true,
  24. },
  25. [API_KEY_STATUS.DISABLED]: {
  26. label: 'Disabled',
  27. variant: 'neutral',
  28. value: API_KEY_STATUS.DISABLED,
  29. showDot: true,
  30. },
  31. [API_KEY_STATUS.EXPIRED]: {
  32. label: 'Expired',
  33. variant: 'warning',
  34. value: API_KEY_STATUS.EXPIRED,
  35. showDot: true,
  36. },
  37. [API_KEY_STATUS.EXHAUSTED]: {
  38. label: 'Exhausted',
  39. variant: 'danger',
  40. value: API_KEY_STATUS.EXHAUSTED,
  41. showDot: true,
  42. },
  43. } as const
  44. export const API_KEY_STATUS_OPTIONS = Object.values(API_KEY_STATUSES).map(
  45. (config) => ({
  46. label: config.label,
  47. value: String(config.value),
  48. })
  49. )
  50. // ============================================================================
  51. // Default Values
  52. // ============================================================================
  53. export const DEFAULT_GROUP = '' as const
  54. // ============================================================================
  55. // Error Messages (i18n keys: use t(ERROR_MESSAGES.xxx) when displaying)
  56. // ============================================================================
  57. export const ERROR_MESSAGES = {
  58. UNEXPECTED: 'An unexpected error occurred',
  59. LOAD_FAILED: 'Failed to load API keys',
  60. SEARCH_FAILED: 'Failed to search API keys',
  61. CREATE_FAILED: 'Failed to create API key',
  62. UPDATE_FAILED: 'Failed to update API key',
  63. DELETE_FAILED: 'Failed to delete API key',
  64. BATCH_DELETE_FAILED: 'Failed to delete API keys',
  65. STATUS_UPDATE_FAILED: 'Failed to update API key status',
  66. } as const
  67. // ============================================================================
  68. // Success Messages (i18n keys: use t(SUCCESS_MESSAGES.xxx) when displaying)
  69. // ============================================================================
  70. export const SUCCESS_MESSAGES = {
  71. API_KEY_CREATED: 'API Key created successfully',
  72. API_KEY_UPDATED: 'API Key updated successfully',
  73. API_KEY_DELETED: 'API Key deleted successfully',
  74. API_KEY_ENABLED: 'API Key enabled successfully',
  75. API_KEY_DISABLED: 'API Key disabled successfully',
  76. } as const