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

const BeneficiariesView = () => (
  <EntityRecordViewPage
    singularLabel="Beneficiary"
    pluralLabel="Beneficiaries"
    stateKey="beneficiaries"
    recordKey="beneficiaries"
    fetchRecord={fetch}
    listHref="/beneficiaries/beneficiaries-list"
    editHref={(id) => `/beneficiaries/beneficiaries-edit/?id=${id ?? ''}`}
  />
);

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

export default BeneficiariesView;
