<?php
/** Divi Builder module class. */
if ( ! defined( 'ABSPATH' ) || ! class_exists( 'ET_Builder_Module' ) ) {
	return;
}
class YATOON_Divi_Module extends ET_Builder_Module {
	public $slug       = 'yatoon_booking';
	public $vb_support = 'on';

	public function init() {
		$this->name = esc_html__( 'Yatoon Booking', 'yatoon-booking-system' );
	}

	public function get_fields() {
		$options = array();
		foreach ( YATOON_Builder_Integrations::surfaces() as $key => $surface ) {
			$options[ $key ] = $surface['label'];
		}
		return array(
			'surface'     => array( 'label' => esc_html__( 'Surface', 'yatoon-booking-system' ), 'type' => 'select', 'options' => $options, 'default' => 'booking' ),
			'location_id' => array( 'label' => esc_html__( 'Location ID', 'yatoon-booking-system' ), 'type' => 'text' ),
			'service_id'  => array( 'label' => esc_html__( 'Service ID', 'yatoon-booking-system' ), 'type' => 'text' ),
			'staff_id'    => array( 'label' => esc_html__( 'Staff ID', 'yatoon-booking-system' ), 'type' => 'text' ),
		);
	}

	public function render( $attrs, $content, $render_slug ) {
		return YATOON_Builder_Integrations::render_surface( $this->props['surface'] ?? 'booking', $this->props );
	}
}
