import type { FC } from "react";
import { computeTransferMinutes, formatMinutesAsDuration } from "./computeTransferTime.js";

export interface TransferTimeProps {
  arrivalUtc: string;
  departureUtc: string;
}

export const TransferTime: FC<TransferTimeProps> = ({ arrivalUtc, departureUtc }) => {
  const minutes = computeTransferMinutes(arrivalUtc, departureUtc);
  if (minutes === null) return null;

  return (
    <span className="transfer-time" data-testid="transfer-time">
      {formatMinutesAsDuration(minutes)}
    </span>
  );
};
