import type { CalculatorDef } from '$lib/data/calculators';

type RateConfig = Pick<CalculatorDef, 'type' | 'factor' | 'offset' | 'labels'>;

export const getConversionRateText = (config: RateConfig): string | null => {
  if (config.type !== 'standard' || !config.factor) {
    return null;
  }

  const { in1, in2 } = config.labels;
  if (!in1 || !in2) {
    return null;
  }

  return `1 ${in1} = ${config.factor}${config.offset ? ` + ${config.offset}` : ''} ${in2}`;
};
