<?php
/**
 * Listing submit details page template.
 *
 * @package HivePress\Templates
 */

namespace HivePress\Templates;

use HivePress\Helpers as hp;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Listing submission page (listing details step).
 */
class Listing_Submit_Details_Page extends Listing_Submit_Page {

	/**
	 * Class initializer.
	 *
	 * @param array $meta Class meta values.
	 */
	public static function init( $meta = [] ) {
		$meta = hp\merge_arrays(
			[
				'label' => hivepress()->translator->get_string( 'add_listing' ) . ' (' . hivepress()->translator->get_string( 'details' ) . ')',
			],
			$meta
		);

		parent::init( $meta );
	}

	/**
	 * Class constructor.
	 *
	 * @param array $args Template arguments.
	 */
	public function __construct( $args = [] ) {
		$args = hp\merge_trees(
			[
				'blocks' => [
					'page_content' => [
						'blocks' => [
							'listing_submit_form' => [
								'type'   => 'form',
								'form'   => 'listing_submit',
								'_label' => hivepress()->translator->get_string( 'form' ),
								'_order' => 10,

								'footer' => [
									'form_actions' => [
										'type'       => 'container',
										'optional'   => true,
										'blocks'     => [],
										'_order'     => 10,

										'attributes' => [
											'class' => [ 'hp-form__actions' ],
										],
									],
								],
							],
						],
					],
				],
			],
			$args
		);

		parent::__construct( $args );
	}
}
