/**
 * Constants and configuration for careers module
 *
 * Centralized configuration makes it easy to update behavior
 * without touching the core logic
 */

import type { StringTranslations } from "./types";

/**
 * Default fallback values for missing translations
 * Used when a job listing doesn't have all translations filled in
 */
export const DEFAULT_TRANSLATIONS = {
  location: {
    en: "Remote",
    ar: "عن بُعد",
  } as StringTranslations,

  salaryRange: {
    en: "Competitive salary",
    ar: "راتب تنافسي",
  } as StringTranslations,

  applicationInstructions: {
    en: "Apply via our careers portal",
    ar: "قدّم عبر بوابة التوظيف",
  } as StringTranslations,
};

/**
 * Table name for job listings
 */
export const JOBS_TABLE_NAME = "jobs" as const;

/**
 * Query configuration
 */
export const QUERY_CONFIG = {
  /**
   * Maximum number of jobs to fetch per request
   * Set to reasonable limit to prevent performance issues
   */
  maxJobsPerQuery: 100,

  /**
   * Default sort order for job listings
   */
  defaultSortField: "opening_at" as const,
  defaultSortDirection: "desc" as const,

  /**
   * Cache duration for ISR (Incremental Static Regeneration)
   * Jobs page will be regenerated every hour
   */
  revalidateSeconds: 3600, // 1 hour
} as const;

/**
 * All columns to select from the jobs table
 * Keeping this centralized makes it easier to update when schema changes
 */
export const JOB_SELECT_COLUMNS = `
  id,
  slug,
  title_translations,
  department,
  department_label,
  location_translations,
  contract_type,
  contract_type_label,
  level,
  level_label,
  compensation_translations,
  benefits,
  skills,
  requirements,
  responsibilities,
  nice_to_have,
  workday_expectations,
  application_instructions,
  status,
  opening_at,
  closing_at,
  created_at
` as const;

/**
 * Error messages
 * Centralized for consistency and easy updates
 */
export const ERROR_MESSAGES = {
  databaseNotConfigured:
    "Database client is not configured. Returning empty jobs list.",
  fetchFailed: "Failed to fetch jobs from database:",
  tableNotFound: "Jobs table not found in database schema",
} as const;

/**
 * Log prefixes for consistent logging
 */
export const LOG_PREFIX = {
  info: "[Careers]",
  warn: "[Careers][Warning]",
  error: "[Careers][Error]",
} as const;
