import { useSearchParams } from "react-router-dom";
import LetterViewer from "../common/letterViewer";
import { useLocation } from "react-router-dom";
const ViewOutgoingRecord = () => {
  const [searchParams] = useSearchParams();
  const location = useLocation();
  const view = searchParams.get("view") || "";
  const page = searchParams.get("page") || ""; // default to 'self'
  const { backurl: back, type } = location.state || {};
  let backurl =
    view === "parent"
      ? `/record-management/userRecords/?page=${page}&view=parent`
      : `/record-management/userRecords?page=${page}`;
  backurl = back || backurl;
  return (
    <LetterViewer
      backurl={backurl}
      type={type || "userRecord"}
      shouldFetchInstance={false}
      actions="UserRecordsActions"
    />
  );
};

export default ViewOutgoingRecord;
