import InternalIncomingRecords from "@/record-management/components/userIncoming/internalIncomingRecords/internalIncomingRecords";
import InternalIncomingRecordsV2 from "@/record-management/components/userIncoming/internalIncomingRecords/internalIncomingRecordsV2";
import { useAuthUser } from "@/record-management/hooks/useAuthUser";
import { useUnitConfiguration } from "@/shared/hooks/useUnitConfiguration";

const InternalIncomingRecordsPage = () => {
  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 ? (
    <InternalIncomingRecords />
  ) : (
    <InternalIncomingRecordsV2 />
  );
};

export default InternalIncomingRecordsPage;
