<?php

namespace Rtc\PlantShopWC\Admin\Views;

class ProductListView {


    public function render( array $modules ): void {
        wp_nonce_field( 'plantshop_wc_quick_edit', 'plantshop_wc_quick_edit_nonce' );

        wp_nonce_field( 'plantshop-wc_product_list', 'plantshop-wc_list_nonce' );

        ?>
        <fieldset class="inline-edit-group">
            <div class="inline-edit-col">
                <?php
                foreach ( $modules as $m ) {
                    $slug = $m->slug();
                    ?>
                    <div class="plantshop-wc-qe-group" data-module="<?php echo esc_attr( $slug ); ?>">
                        <?php
                        foreach ( $m->vars() as [$var, $label] ) {
                            ?>
                            <label class="alignleft" style="display: block; margin-bottom: 6px; width: 100%;">
                                <span class="title">
                                <?php
                                    echo esc_html( $label );
                                ?>
                                </span>
                                <span class="input-text-wrap">
                            <?php
                            if ( $var !== 'plot_description' ) {
                                ?>

                            <input type="text" class="<?php echo esc_attr( $var ); ?>" name="<?php echo esc_attr( 'plantshop-wc[' . $slug . '][' . $var . ']' ); ?>" value="">

                                <?php
                            } else {
                                ?>

                            <textarea type="text" maxlength="150" class="<?php echo esc_attr( $var ); ?> half medium" name="<?php echo esc_attr( 'plantshop-wc[' . $slug . '][' . $var . ']' ); ?>"></textarea>

                                <?php
                            }
                            ?>
                        </span>
                            </label>
                            <br class="clear">
                            <?php
                        }
                        ?>
                    </div>
                    <?php
                }
                ?>
            </div>
        </fieldset>
        <?php
    }
}
