/**
 * Route segment constants — use these in React Router path configs
 * and as the building blocks for full-path helpers below.
 */
export const SPORTS_POOL_PATHS = {
  ROOT: 'sports-pool',
  MOBILE_ROOT: 'sports-pool-mobile',
  COMPETITIONS: 'competitions',
  PODIUM: 'podium',
} as const;

/** Default desktop routes (used for sidebar links, permission guards, etc.) */
export const sportsPoolRoutes = {
  base: () => `/${SPORTS_POOL_PATHS.ROOT}`,
  competitions: () =>
    `${sportsPoolRoutes.base()}/${SPORTS_POOL_PATHS.COMPETITIONS}`,
  competition: (competitionId: number | string) =>
    `${sportsPoolRoutes.base()}/${SPORTS_POOL_PATHS.COMPETITIONS}/${competitionId}`,
  fixture: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/fixture`,
  predictions: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/predictions`,
  results: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/results`,
  ranking: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/ranking`,
  prizes: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/prizes`,
  rules: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/rules`,
  podium: (competitionId: number | string) =>
    `${sportsPoolRoutes.competition(competitionId)}/${SPORTS_POOL_PATHS.PODIUM}`,
};

/**
 * Build route helpers scoped to a given base path.
 * For mobile the base will be e.g. `/${SPORTS_POOL_PATHS.MOBILE_ROOT}/<token>`.
 */
export const getSportsPoolRoutes = (base: string) => {
  const competitions = `${base}/${SPORTS_POOL_PATHS.COMPETITIONS}`;
  return {
    base: () => base,
    competitions: () => competitions,
    competition: (competitionId: number | string) =>
      `${competitions}/${competitionId}`,
    fixture: (competitionId: number | string) =>
      `${competitions}/${competitionId}/fixture`,
    predictions: (competitionId: number | string) =>
      `${competitions}/${competitionId}/predictions`,
    results: (competitionId: number | string) =>
      `${competitions}/${competitionId}/results`,
    ranking: (competitionId: number | string) =>
      `${competitions}/${competitionId}/ranking`,
    prizes: (competitionId: number | string) =>
      `${competitions}/${competitionId}/prizes`,
    rules: (competitionId: number | string) =>
      `${competitions}/${competitionId}/rules`,
    podium: (competitionId: number | string) =>
      `${competitions}/${competitionId}/${SPORTS_POOL_PATHS.PODIUM}`,
  };
};
