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

const AllocationsView = () => (
  <EntityRecordViewPage
    singularLabel="Allocation"
    pluralLabel="Allocations"
    stateKey="allocations"
    recordKey="allocations"
    fetchRecord={fetch}
    listHref="/allocations/allocations-list"
    editHref={(id) => `/allocations/allocations-edit/?id=${id ?? ''}`}
  />
);

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

export default AllocationsView;
