Files
tgex-frontend/lib/utils/constants.ts
2025-12-29 10:12:13 +03:00

92 lines
3.1 KiB
TypeScript

// ============================================================================
// Constants
// ============================================================================
export const API_URL =
process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000/api/v1";
export const USE_MOCKS =
process.env.NEXT_PUBLIC_USE_MOCKS?.toLowerCase() === "true" || false;
export const BOT_USERNAME =
process.env.NEXT_PUBLIC_BOT_USERNAME || "your_bot_username";
// Local Storage Keys
export const STORAGE_KEYS = {
ACCESS_TOKEN: "tgex_access_token",
REFRESH_TOKEN: "tgex_refresh_token",
USER: "tgex_user",
SELECTED_WORKSPACE: "tgex_selected_workspace",
SELECTED_PROJECT: "tgex_selected_project",
} as const;
// Error Codes
export const ERROR_CODES = {
UNAUTHORIZED: "UNAUTHORIZED",
FORBIDDEN: "FORBIDDEN",
NOT_FOUND: "NOT_FOUND",
VALIDATION_ERROR: "VALIDATION_ERROR",
INTERNAL_ERROR: "INTERNAL_ERROR",
} as const;
// Date Formats
export const DATE_FORMATS = {
DISPLAY: "dd.MM.yyyy",
DISPLAY_WITH_TIME: "dd.MM.yyyy HH:mm",
API: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
} as const;
// Pagination
export const DEFAULT_PAGE_SIZE = 50;
export const PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
// Routes Builder
export const buildRoute = {
// Dashboard
dashboard: (workspaceId: string) => `/dashboard/${workspaceId}`,
// Projects
projects: (workspaceId: string) => `/dashboard/${workspaceId}/projects`,
// Channels
channels: (workspaceId: string) => `/dashboard/${workspaceId}/channels`,
// Purchase Plan
purchasePlans: (workspaceId: string) => `/dashboard/${workspaceId}/purchase-plans`,
purchasePlan: (workspaceId: string, projectId: string) =>
`/dashboard/${workspaceId}/purchase-plans/${projectId}`,
// Creatives
creatives: (workspaceId: string) => `/dashboard/${workspaceId}/creatives`,
creativeNew: (workspaceId: string) => `/dashboard/${workspaceId}/creatives/new`,
creativeDetail: (workspaceId: string, creativeId: string) =>
`/dashboard/${workspaceId}/creatives/${creativeId}`,
// Placements
placements: (workspaceId: string) => `/dashboard/${workspaceId}/placements`,
placementNew: (workspaceId: string) => `/dashboard/${workspaceId}/placements/new`,
placementDetail: (workspaceId: string, placementId: string) =>
`/dashboard/${workspaceId}/placements/${placementId}`,
// Analytics
analytics: (workspaceId: string) => `/dashboard/${workspaceId}/analytics`,
analyticsSpending: (workspaceId: string) =>
`/dashboard/${workspaceId}/analytics/spending`,
analyticsCreatives: (workspaceId: string) =>
`/dashboard/${workspaceId}/analytics/creatives`,
analyticsChannels: (workspaceId: string) =>
`/dashboard/${workspaceId}/analytics/channels`,
analyticsPlacements: (workspaceId: string) =>
`/dashboard/${workspaceId}/analytics/placements`,
// Settings
settings: (workspaceId: string) => `/dashboard/${workspaceId}/settings`,
members: (workspaceId: string) => `/dashboard/${workspaceId}/settings/members`,
invites: (workspaceId: string) => `/dashboard/${workspaceId}/settings/invites`,
} as const;
// Static routes
export const ROUTES = {
HOME: "/",
LOGIN: "/login",
AUTH_COMPLETE: "/auth/complete",
} as const;