Constants.ts

Application-wide constants and configuration values.

Configuration

The constants file contains shared values used throughout the application, including API endpoints, navigation items, and configuration settings.

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
// API Endpoints
export const API_ENDPOINTS = {
  BANK: '/api/bank',
  TRANSACTIONS: '/api/transactions',
  USER: '/api/user',
  PLAID: '/api/plaid',
  DWOLLA: '/api/dwolla',
} as const

// Navigation
export const NAV_ITEMS = [
  {
    title: 'Dashboard',
    path: '/dashboard',
    icon: 'Home',
  },
  {
    title: 'Transactions',
    path: '/transactions',
    icon: 'Receipt',
  },
  // ...more items
] as const

// Chart Colors
export const CHART_COLORS = {
  primary: '#39A36A',
  secondary: '#2970FF',
  accent: '#F59E0B',
  // ...more colors
} as const

// Transaction Categories
export const TRANSACTION_CATEGORIES = [
  'Food & Dining',
  'Shopping',
  'Transportation',
  'Bills & Utilities',
  // ...more categories
] as const

Usage

Import and use constants in your components:

1
2
3
4
5
6
7
8
9
10
11
12
13
import { API_ENDPOINTS, CHART_COLORS } from '@/constants'

// Using API endpoints
const response = await fetch(API_ENDPOINTS.TRANSACTIONS)

// Using chart colors
const chartConfig = {
  backgroundColor: [
    CHART_COLORS.primary,
    CHART_COLORS.secondary,
    CHART_COLORS.accent,
  ]
}

Benefits

  • Centralized configuration management
  • Type safety with TypeScript
  • Easy updates and maintenance
  • Consistent values across components
  • Better code organization