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

const DepartmentsView = () => (
  <EntityRecordViewPage
    singularLabel="Department"
    pluralLabel="Departments"
    stateKey="departments"
    recordKey="departments"
    fetchRecord={fetch}
    listHref="/departments/departments-list"
    editHref={(id) => `/departments/departments-edit/?id=${id ?? ''}`}
  />
);

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

export default DepartmentsView;
