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

const ApprovalsView = () => (
  <EntityRecordViewPage
    singularLabel="Approval"
    pluralLabel="Approvals"
    stateKey="approvals"
    recordKey="approvals"
    fetchRecord={fetch}
    listHref="/approvals/approvals-list"
    editHref={(id) => `/approvals/approvals-edit/?id=${id ?? ''}`}
  />
);

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

export default ApprovalsView;
