import React, { ReactElement } from 'react';
import LayoutAuthenticated from '../../layouts/Authenticated';
import { fetch } from '../../stores/requisitions/requisitionsSlice';
import EntityRecordViewPage from '../../components/EntityPage/EntityRecordViewPage';

const RequisitionsView = () => (
  <EntityRecordViewPage
    singularLabel="Requisition"
    pluralLabel="Requisitions"
    stateKey="requisitions"
    recordKey="requisitions"
    fetchRecord={fetch}
    listHref="/requisitions/requisitions-list"
    editHref={(id) => `/requisitions/requisitions-edit/?id=${id ?? ''}`}
  />
);

RequisitionsView.getLayout = function getLayout(page: ReactElement) {
  return <LayoutAuthenticated permission={'READ_REQUISITIONS'}>{page}</LayoutAuthenticated>;
};

export default RequisitionsView;
