<?php

namespace SugarCalendarBookings\Support\Admin\PageLayouts;

use SugarCalendarBookings\Support\Admin\AbstractPage;

/**
 * General layout for admin pages.
 *
 * @since 1.0.0
 */
class GeneralLayout implements LayoutInterface {

	/**
	 * Display page.
	 *
	 * @since 1.0.0
	 *
	 * @param AbstractPage $page The page instance.
	 */
	public function display( AbstractPage $page ) {

		?>
		<div class="wrap sugar-calendar-bookings-admin-wrap">
			<?php if ( $page->should_show_subheader() ) : ?>
				<div class="sugar-calendar-bookings-admin-subheader">
					<h4><?php echo esc_html( $page->get_title() ); ?></h4>

					<div class="sugar-calendar-bookings-admin-subheader-actions-left">
						<?php
						/**
						 * Fires on the admin page subheader left actions.
						 *
						 * @since 1.0.0
						 *
						 * @param AbstractPage $page The page instance.
						 */
						do_action( 'sugar_calendar_bookings_admin_page_subheader_actions_left', $page ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
						?>
					</div>
					<div class="sugar-calendar-bookings-admin-subheader-actions-right">
						<?php
						/**
						 * Fires on the admin page subheader right actions.
						 *
						 * @since 1.0.0
						 *
						 * @param AbstractPage $page The page instance.
						 */
						do_action( 'sugar_calendar_bookings_admin_page_subheader_actions_right', $page ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
						?>
					</div>
				</div>
			<?php endif; ?>
			<div class="sugar-calendar-bookings-admin-content">
				<h1 class="screen-reader-text"><?php echo esc_html( $page->get_title() ); ?></h1>
				<?php $page->display_content(); ?>
			</div>
		</div>
		<?php
	}
}
