All files / src/constants notification.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 8/8

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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68          5x           5x           5x               5x           5x                 5x                     12x                 5x              
/**
 * Notification constants
 */
 
// API Endpoints
export const API_ENDPOINTS = {
  BADGE_COUNTS: '/notifications/badge-counts',
  NOTIFICATIONS: '/notifications',
};
 
// Notification Types
export const NOTIFICATION_TYPES = {
  TRADE: 'trade',
  TRANSACTION: 'transaction',
} as const;
 
// Default notification counts when API fails or data is missing
export const DEFAULT_NOTIFICATION_COUNTS = {
  trade: 0,
  transaction: 0,
  total: 0,
  lastUpdated: '',
};
 
// React Query settings
export const QUERY_KEYS = {
  NOTIFICATION_COUNTS: 'notificationCounts',
  NOTIFICATIONS: 'notifications',
};
 
// Hook settings
export const NOTIFICATION_SETTINGS = {
  DEFAULT_REFRESH_INTERVAL: 30000, // 30 seconds
  DEFAULT_AUTO_REFRESH: true,
  STALE_TIME: 0, // Always consider data stale to ensure fresh data
  MAX_RETRY_DELAY: 30000, // Maximum retry delay in milliseconds
  RETRY_BASE_DELAY: 1000, // Base retry delay in milliseconds
};
 
// Log messages for better consistency and potential localization
export const LOG_MESSAGES = {
  // Fetch notification counts
  FETCHING_COUNTS: 'Fetching notification counts from API...',
  COUNTS_RESPONSE: 'Notification counts API response:',
 
  // Fetch notifications
  FETCHING_NOTIFICATIONS: 'Fetching notifications from API...',
  NOTIFICATIONS_RESPONSE: 'Notifications API response:',
 
  // Update notifications
  UPDATING_NOTIFICATION: (id: number, count: number) =>
    `Updating notification ${id} with count ${count}...`,
  UPDATE_RESPONSE: 'Update notification API response:',
 
  // Reset notifications
  RESETTING_COUNTS: 'Resetting all notification counts...',
  RESET_SUCCESS: 'All notification counts reset successfully',
};
 
// Error messages
export const ERROR_MESSAGES = {
  FETCH_COUNTS: 'Error fetching notification counts:',
  FETCH_NOTIFICATIONS: 'Error fetching notifications:',
  UPDATE_NOTIFICATION: 'Error updating notification:',
  RESET_COUNTS: 'Error resetting notification counts:',
  RESET_FAILED: 'Some updates failed during reset',
};