<?php
/**
 * Displays affiliate notices.
 *
 * @package SWPTLS
 */

// If direct access than exit the file.
defined( 'ABSPATH' ) || exit;
$purple_thumbs_up = ECRE_ASSETS . '/icons/purple-thumbs-up.svg';
?>

<div class="ecre-influencer-banner">
			
	<div class="banner-content" data-value="hide_notice">
		<span class="ecre-influencer-close"></span>
		<div class="ecre-influencer-image">
			<img class="ecre-image-icon" src="<?php echo esc_url( $purple_thumbs_up ); ?>" alt="">
		</div>
		<div class="ecre-influencer-wrapper">
			<h3><?php esc_html_e( 'Hey! Enjoying the EchoRewards plugin? 😍 Join our ', 'echo-rewards' ); ?>
			<span><?php printf( '<a style="text-decoration:none; color:#7C3AED; font-family:inherit; cursor: pointer;" href="%s" target="_blank">%s</a>', esc_url( 'https://cutt.ly/Xews2hjQ' ), esc_html__( 'Influencer Program ', 'echo-rewards' ) ); ?></span>
			<?php esc_html_e( 'to make money from your social media content. You can also check our', 'echo-rewards' ); ?>
			<span><?php printf( '<a style="text-decoration:none; color:#7C3AED; font-family:inherit; cursor:pointer;" href="%s" target="_blank">%s</a>', esc_url( 'https://cutt.ly/4ews2tou' ), esc_html__( 'Affiliate Program ', 'echo-rewards' ) ); ?></span> 
			<?php esc_html_e( 'to get a ', 'echo-rewards' ); ?>
			<span style="font-weight:600; font-size:20px; color: #1f2937"><?php esc_html_e( '25% commission ', 'echo-rewards' ); ?></span>
			<?php esc_html_e( 'on every sale!', 'echo-rewards' ); ?>
		
		</h3>
			<div class="link-wrapper">
				<a href="<?php echo esc_url( 'https://cutt.ly/4ews2tou' ); ?>" target="_blank" class="affiliate-button"><?php esc_html_e( 'Affiliate Program', 'echo-rewards' ); ?></a>
				<a href="<?php echo esc_url( 'https://cutt.ly/Xews2hjQ' ); ?>" target="_blank" class="influencer-button" style=""><?php esc_html_e( 'Influencer Program', 'echo-rewards' ); ?> <span></span></a>
			</div>
		</div>
	</div>
	
</div>

<script>
jQuery(document).ready(function($) {
	$(document).on('click', '.ecre-influencer-close', (e) => {
		e.preventDefault();

		let target = $(e.currentTarget);
		let dataValue = 'hide_notice';

		$.ajax({
			type: "POST",
			url: "<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>", // phpcs:ignore
			data: {
				action: 'ecre_notice_action',
				nonce: '<?php echo esc_attr( wp_create_nonce( 'ecre_notices_nonce' ) ); ?>',
				info: {
					// type: 'reminder', // use for review notice
					type: 'hide_notice',
					value: dataValue
				},
				actionType: 'affiliate_notice'
			},
			success: response => {
				if (response.data.response_type === 'success') {
					$('.ecre-influencer-banner').slideUp();
				}
			}
		});
	})
});
</script>
