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

const ProvincesView = () => (
  <EntityRecordViewPage
    singularLabel="Province"
    pluralLabel="Provinces"
    stateKey="provinces"
    recordKey="provinces"
    fetchRecord={fetch}
    listHref="/provinces/provinces-list"
    editHref={(id) => `/provinces/provinces-edit/?id=${id ?? ''}`}
  />
);

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

export default ProvincesView;
