import type { TFunction } from "i18next";

export type ScheduleValidationError = {
  truckRowId: number;
  messageKey: string;
  messageParams?: Record<string, string | number>;
};

export function formatScheduleValidationError(
  t: TFunction<"shop">,
  error: ScheduleValidationError,
): string {
  return t(error.messageKey, (error.messageParams ?? {}) as Record<string, string>);
}

export function formatScheduleValidationErrors(
  t: TFunction<"shop">,
  errors: ScheduleValidationError[],
): string {
  return errors.map((e) => formatScheduleValidationError(t, e)).join("\n");
}
