export const CUSTOM_REPORT_CHARTS = ['Bar', 'Donut', 'Table'] as const;

/** What the report builder may offer: each object lists its groupings, and each grouping the measures the reports API can return. */
export const CUSTOM_REPORT_OPTIONS: Record<string, Record<string, readonly string[]>> = {
  Deals: { 'Funnel step': ['Count'], Owner: ['Won amount', 'Open pipeline amount'], 'Loss reason': ['Count'] },
  Leads: { Source: ['Count', 'Qualified count', 'Converted count'] },
};

export const CUSTOM_REPORT_OBJECTS = Object.keys(CUSTOM_REPORT_OPTIONS);

/** Returns an error message when the object, grouping and measure are not an offered combination, else null. */
export function validateReportShape(object: string, group: string, measure: string): string | null {
  const groups = CUSTOM_REPORT_OPTIONS[object];
  if (!groups) return `Choose a report object: ${CUSTOM_REPORT_OBJECTS.join(' or ')}`;
  const measures = groups[group];
  if (!measures) return `Choose a grouping for ${object}: ${Object.keys(groups).join(', ')}`;
  if (!measures.includes(measure)) return `Choose a measure for ${group}: ${measures.join(', ')}`;
  return null;
}
