import { Space, Tag } from "antd";
import React from "react";
import { Link } from "react-router-dom";

export default function JobsRelatedRos({ jobid, job, disabled }) {
  if (!(job && job.vehicle && job.vehicle.jobs)) return null;
  return (
    <Space wrap>
      {job.vehicle.jobs
        .filter((j) => j.id !== job.id)
        .map((j) => (
          <Tag key={j.id}>
            {disabled ? (
              <>{`${j.ro_number || "N/A"}${j.clm_no ? ` | ${j.clm_no}` : ""}${j.status ? ` | ${j.status}` : ""}`}</>
            ) : (
              <Link to={`/manage/jobs/${j?.id}`}>{`${j.ro_number || "N/A"}${
                j.clm_no ? ` | ${j.clm_no}` : ""
              }${j.status ? ` | ${j.status}` : ""}`}</Link>
            )}
          </Tag>
        ))}
    </Space>
  );
}
