<?php

namespace Rtc\PlantShopWC\Admin\Views;

use WP_Post;

class ProductView {


    public function render( WP_Post $product, array $tabs ): void {
        ?>

        <div class="plantshop-wc-tabs-wrapper">

            <ul class="plantshop-wc-tabs">

                    <?php
                    $first = true;
                    foreach ( $tabs as $tab ) {
                        $tab_id = 'plantshop-wc_' . $tab->slug();
                        ?>

                        <li class="<?php echo $first ? 'active' : ''; ?>">
                            <a href="#<?php echo esc_attr( $tab_id ); ?>">
                                <span><?php echo esc_html( $tab->label() ); ?></span>
                            </a>
                        </li>

                        <?php
                        $first = false;
                    }
                    ?>

            </ul>

                    <?php
                    $first = true;
                    foreach ( $tabs as $tab ) {
                        $tab_id    = 'plantshop-wc_' . $tab->slug();
                        $tab_class = 'plantshop-wc-tab-content' . ( $first ? '' : ' hidden' );
                        ?>

                    <div id="<?php echo esc_attr( $tab_id ); ?>" class="<?php echo esc_attr( $tab_class ); ?>">
                        <?php $tab->render( $product ); ?>
                    </div>

                        <?php
                        $first = false;
                    }
                    ?>

        </div>

            <?php
            wp_nonce_field( 'plantshop-wc_product_tabs', 'plantshop-wc_tabs_nonce' );
    }
}
