import { useParams, useSearchParams } from "react-router-dom";
import LetterViewer from "../../common/letterViewer";

const RecordOfficerIncomingViewer = () => {
  const { type } = useParams();
  const [searchParams] = useSearchParams();
  const pageIndex = searchParams.get("page") || 1;
  const backURL =
    type === "draft"
      ? `/record-management/recordOfficer/incoming/?page=${pageIndex}`
      : type === "externalNonSmart"
        ? `/record-management/recordOfficer/incomingNonSmartExternal/?page=${pageIndex}`
        : `/record-management/recordOfficer/incomingHistory/?page=${pageIndex}`;
  return (
    <LetterViewer
      backurl={backURL}
      type="incoming"
      shouldFetchInstance={false}
      actions="IncomingRecordDetailActions"
    />
  );
};

export default RecordOfficerIncomingViewer;
