/* eslint-disable @typescript-eslint/no-explicit-any */
import { ShipmentStatus } from "@/Constant/enums";
import { useRouter } from "next/navigation";
import React from "react";

export interface ShipmentFooterProps {
  step: number;
  handleBackClick: () => void;
  handleNextClick: () => void;
  onClose: () => void;
  shipmentDetails: any;
}

const ShipmentFooter: React.FC<ShipmentFooterProps> = ({
  step,
  handleBackClick,
  handleNextClick,
  onClose,
  shipmentDetails
}) => {
  const router = useRouter();
  const handleClearUrlPrams = () => router.push(`/shipments`)

  return (
    <>
      {step === 1 ? (
        <div className="card-bottom step2-card-bottom my-3 d-flex justify-content-between gap-2">
          {/* {shipmentDetails?.id} */}
          <a
            href="#"
            onClick={(e) => {
              e.preventDefault();
              handleNextClick();
            }}
            className="btn btn-m rounded-m delybell-primary font-700 text-uppercase flex-fill text-center"
          >
          Create Shipment & Continue
          <i className="fa fa-arrow-right-long ms-1" />
          </a>
        </div>
      ) : (
        <>
        {shipmentDetails?.status?.id === ShipmentStatus?.Created ? (
          <div className="card-bottom my-3 d-flex justify-content-between gap-2">
          <button
            onClick={handleBackClick}
            // onClick={onClose}
            className="btn btn-m rounded-m delybell-dark font-700 text-uppercase flex-fill text-center"
          >
            <i className="fa fa-arrow-left-long ms-1" /> Back
          </button>

          <button
              onClick={() => {
                handleClearUrlPrams()
                onClose()
              }}            className="btn btn-m rounded-m bg-green2 font-700 text-uppercase flex-fill text-center"
          >
            <i className="fa fa-check me-1" /> Goto shipments
          </button>
        </div>
        ):(
          <div className="card-bottom my-3 d-flex justify-content-between gap-2">
            <button
              onClick={() => {
                handleClearUrlPrams()
                onClose()
              }}
              className="btn btn-m rounded-m bg-green2 font-700 text-uppercase flex-fill text-center"
            >
              <i className="fa fa-check me-1" /> Goto shipments
            </button>
          </div>
        )}
        </>
      )}
    </>
  );
};

export default ShipmentFooter;
