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

const RisksView = () => (
  <EntityRecordViewPage
    singularLabel="Risk"
    pluralLabel="Risks"
    stateKey="risks"
    recordKey="risks"
    fetchRecord={fetch}
    listHref="/risks/risks-list"
    editHref={(id) => `/risks/risks-edit/?id=${id ?? ''}`}
  />
);

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

export default RisksView;
