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

const PermissionsView = () => (
  <EntityRecordViewPage
    singularLabel="Permission"
    pluralLabel="Permissions"
    stateKey="permissions"
    recordKey="permissions"
    fetchRecord={fetch}
    listHref="/permissions/permissions-list"
    editHref={(id) => `/permissions/permissions-edit/?id=${id ?? ''}`}
  />
);

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

export default PermissionsView;
