import PropTypes from 'prop-types'
import {form} from 'tocco-app-extensions'
import EntityBrowserApp from 'tocco-entity-browser/src/main'
import {appContext as appContextPropType} from 'tocco-util'

const UserAvailability = ({allowCreate, reportIds, searchFilters, limit, backendUrl, businessUnit, appContext}) => {
  const modifyFormDefinition = formDefinition => {
    if (!allowCreate) {
      formDefinition = form.removeCreate(formDefinition)
    }

    return formDefinition
  }

  return (
    <EntityBrowserApp
      entityName="Availability"
      formBase="User_availability"
      searchFilters={searchFilters}
      limit={limit}
      modifyFormDefinition={modifyFormDefinition}
      backendUrl={backendUrl}
      businessUnit={businessUnit}
      appContext={appContext}
      reportIds={reportIds}
    />
  )
}

UserAvailability.propTypes = {
  allowCreate: PropTypes.bool,
  reportIds: PropTypes.arrayOf(PropTypes.string).isRequired,
  searchFilters: PropTypes.arrayOf(PropTypes.string),
  limit: PropTypes.number,
  intl: PropTypes.object.isRequired,
  backendUrl: PropTypes.string,
  businessUnit: PropTypes.string,
  appContext: appContextPropType.propTypes.isRequired
}

export default UserAvailability

@@ -219,16 +219,19 @@
 ity = (%7B
+%0A  
 allowCre
@@ -234,16 +234,18 @@
 wCreate,
+%0A 
  reportI
@@ -247,16 +247,18 @@
 portIds,
+%0A 
  searchF
@@ -268,15 +268,19 @@
 ers,
+%0A 
  limit,
+%0A 
  bac
@@ -287,16 +287,18 @@
 kendUrl,
+%0A 
  busines
@@ -303,16 +303,18 @@
 essUnit,
+%0A 
  appCont
@@ -316,16 +316,25 @@
 pContext
+,%0A  intl%0A
 %7D) =%3E %7B%0A
@@ -396,9 +396,8 @@
 if (
-!
 allo
@@ -439,14 +439,11 @@
 orm.
-remove
+add
 Crea
@@ -459,16 +459,22 @@
 finition
+, intl
 )%0A    %7D%0A

use addCreate form modifier