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

const InvoicesView = () => (
  <EntityRecordViewPage
    singularLabel="Invoice"
    pluralLabel="Invoices"
    stateKey="invoices"
    recordKey="invoices"
    fetchRecord={fetch}
    listHref="/invoices/invoices-list"
    editHref={(id) => `/invoices/invoices-edit/?id=${id ?? ''}`}
  />
);

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

export default InvoicesView;
