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

const PaymentRequestsView = () => (
  <EntityRecordViewPage
    singularLabel="Payment Request"
    pluralLabel="Payment Requests"
    stateKey="payment_requests"
    recordKey="payment_requests"
    fetchRecord={fetch}
    listHref="/payment_requests/payment_requests-list"
    editHref={(id) => `/payment_requests/payment_requests-edit/?id=${id ?? ''}`}
  />
);

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

export default PaymentRequestsView;
