<?php

namespace Booktics\Shortcode;

/**
 * Customer shortcode class
 */
class Customer_Shortcode {
    /**
     * Constructor for customer shortcode
     *
     * @return  void
     */
    public function __construct() {
        add_shortcode( 'booktics_customer_panel', array( $this, 'render_customer_panel' ) );
    }

    /**
     * Render customer panel
     *
     * @param   array  $attributes
     *
     * @return  string
     */
    public function render_customer_panel( $attributes ) {

        wp_enqueue_style( 'booktics-vendor' );
        wp_enqueue_style( 'booktics-frontend' );

        wp_enqueue_script( 'booktics-packages' );
        wp_enqueue_script( 'booktics-frontend-scripts' );
        
             // Check if user is logged in
             if ( ! is_user_logged_in() ) {
                $login_url = wp_login_url( get_permalink() );
                return '<div class="booktics-login-required">
                            <h3>Customer Portal Access</h3>
                            <p>Please login to access your booking history.</p>
                            <a href="' . esc_url( $login_url ) . '" class="booktics-login-btn">Login</a>
                        </div>';
            }
    
            // Return container for React app
            return '<div id="booktics-customer-dashboard" 
                         data-user-id="' . get_current_user_id() . '">
                    </div>';
    }
}