import i18next from 'i18next';

export const getDurationTime = (
  durationTime?: { hours: number; minutes: number } | null,
): string | undefined => {
  if (!durationTime) return undefined;

  const { hours = 0, minutes = 0 } = durationTime;

  if (!hours && !minutes) return undefined;

  const minuteText = i18next.t('general:minutes_long');
  const hourText = i18next.t('general:hours_short');

  const parts: string[] = [];
  if (hours) parts.push(`${hours} ${hourText}`);
  if (minutes) parts.push(`${minutes} ${minuteText}`);

  return parts.join(' ');
};
