import { trainDataType } from "./trainPositionTextArray";

type getTrainDelayStatus = (
  current: trainDataType,
  Station_JP: string
) => string | number;
export const getTrainDelayStatus: getTrainDelayStatus = (
  current,
  Station_JP
) => {
  if (!current) return "";
  const delay = current.delay;
  switch (true) {
    case delay === "入線":
      if (current.Pos === Station_JP) {
        return "当駅始発";
      } else {
        return "発車前";
      }
    case Number.isNaN(delay):
      return delay;
    case delay === 0:
      return "定刻通り";
    default:
      return delay + "分遅れ";
  }
};
