import ExternalIncomingRecords from "@/record-management/components/userIncoming/externalIncomingRecords/externalIncomingRecords";
import ExternalIncomingRecordsV2 from "@/record-management/components/userIncoming/externalIncomingRecords/externalIncomingRecordsV2";
import { useAuthUser } from "@/shared/hooks/useAuthUser";
import { useUnitConfiguration } from "@/shared/hooks/useUnitConfiguration";

const ExternalIncomingRecordsPage = () => {
  const { userDetails } = useAuthUser();

  const unitId = userDetails?.employee?.[0]?.unitId ?? "";
  const { data: unitConfigData } = useUnitConfiguration(unitId, {
    enabled: !!unitId,
  });
  const canIncomingAssignmentsBeSeparated =
    unitConfigData?.data?.items?.[0]?.canIncomingAssignmentsBeSeparated;

  return canIncomingAssignmentsBeSeparated ? (
    <ExternalIncomingRecords />
  ) : (
    <ExternalIncomingRecordsV2 />
  );
};

export default ExternalIncomingRecordsPage;
