<?php
/**
 * File: Ecre_Frontend.php
 *
 * The Ecre_Frontend class file for Wooecho Rewards.
 * This file handles the Ecre_Frontend functionality of the plugin.
 *
 * @package ECRE
 * @since   1.0.0
 */

namespace ECRE;

if ( ! class_exists( 'Ecre_Frontend' ) ) {
	/**
	 * Ecre_Frontend handler class for Wooecho Rewards.
	 *
	 * @since 1.0.0
	 */
	class Ecre_Frontend {
		/**
		 * Initializes the class with the provided settings and components based on the user's pro status.
		 *
		 * This constructor sets up the referral program, product page tabs, and coupon tracking components
		 * depending on the user's professional (pro) status and the specified configuration settings.
		 *
		 * @param bool  $is_pro            Indicates whether the user has a professional (pro) account.
		 *                                 If true, additional features are enabled.
		 * @param array $erce_settings     An array of settings used to configure the referral program
		 *                                 and related components.
		 * @param array $default_settings  An array of default settings used as fallbacks when specific
		 *                                 configurations are not provided.
		 *
		 * @since 1.0.0
		 */
		public function __construct( $is_pro, $erce_settings, $default_settings ) {
			$enable_referral_program             = isset( $erce_settings['enableReferralProgram'] ) ? $erce_settings['enableReferralProgram'] : false;
			$enable_referral_tab_on_product_page = isset( $erce_settings['enableTabOnWooCommerceProduct'] ) ? $erce_settings['enableTabOnWooCommerceProduct'] : false;

			if ( $enable_referral_program ) {
				new Frontend\Ecre_MyAccount_Menu( $is_pro, $erce_settings, $default_settings );
				if ( $enable_referral_tab_on_product_page ) {
					new Frontend\Ecre_Single_Product_Tab( $is_pro, $erce_settings, $default_settings );
				}
			}

			if ( ! $is_pro ) {
				new Frontend\Ecre_Coupon_Tracking( $erce_settings );
			}
		}
	}
}
