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

const VendorsView = () => (
  <EntityRecordViewPage
    singularLabel="Vendor"
    pluralLabel="Vendors"
    stateKey="vendors"
    recordKey="vendors"
    fetchRecord={fetch}
    listHref="/vendors/vendors-list"
    editHref={(id) => `/vendors/vendors-edit/?id=${id ?? ''}`}
  />
);

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

export default VendorsView;
