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

const ProgramsView = () => (
  <EntityRecordViewPage
    singularLabel="Program"
    pluralLabel="Programs"
    stateKey="programs"
    recordKey="programs"
    fetchRecord={fetch}
    listHref="/programs/programs-list"
    editHref={(id) => `/programs/programs-edit/?id=${id ?? ''}`}
  />
);

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

export default ProgramsView;
