import { Button } from "antd";
import { useTranslation } from "react-i18next";
import { SyncOutlined } from "@ant-design/icons";
import { useNavigate } from "react-router-dom";

export default function JobSyncButton({ job }) {
  const { t } = useTranslation();
  const history = useNavigate();
  const handleClick = () => {
    history(`/manage/available?availableJobId=${job?.available_jobs?.[0]?.id}&clm_no=${job?.clm_no}`);
  };
  if (job?.available_jobs && job?.available_jobs?.length > 0)
    return (
      <Button onClick={handleClick} icon={<SyncOutlined />}>
        {t("jobs.actions.sync")}
      </Button>
    );
  else return null;
}
