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

const OrganizationsView = () => (
  <EntityRecordViewPage
    singularLabel="Organization"
    pluralLabel="Organizations"
    stateKey="organizations"
    recordKey="organizations"
    fetchRecord={fetch}
    listHref="/organizations/organizations-list"
    editHref={(id) => `/organizations/organizations-edit/?id=${id ?? ''}`}
  />
);

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

export default OrganizationsView;
