<script>
import ReservationsForm from '@inside-agenda/components/lib/sub-components/forms/ReservationsForm'

export default {
  name: 'reservations-form',
  extends: ReservationsForm,
  methods: {
    formatData(fields) {
      fields.frequency = this.formatFrequency(fields)

      delete fields.until

      if (this.isEdition && this.recursivityAlreadyStarted) {
        delete fields.start_date
        delete fields.end_date
        delete fields.frequency
      }

      return {
        bundle: this.contentType,
        type: 'node',
        ...(!('information_technologies' in fields) && {
          information_technologies: []
        }),
        ...(!('catering_services' in fields) && {
          catering_services: []
        }),
        ...(fields.start_date && { date: fields.start_date.split(' ')[0] }),
        ...fields
      }
    }
  }
}
</script>
