<?php
namespace OxygenApp\Views\Helpers;

if ( ! defined( 'ABSPATH' ) ) exit;

class Forms {

    static function renderInputText(array $data = []): void {

        $label = $data['label'] ?? '';
        $id = $data['id'] ?? uniqid('_id_');
        $info = $data['info'] ?? false;
        $placeholder = $data['placeholder'] ?? '';
        $id = $id === '' ? uniqid('input_') : $id;
        $name = $data['name'] ?? '';
        $value = $data['value'] ?? '';
        ?>
        <div class="mb-3">
            <div class="input-group">
                <label for="<?php echo esc_attr($id) ?>" class="form-label skp-lang-input-label"><?php echo esc_html($label) ?></label>
                <input type="text" name="<?php echo esc_attr($name) ?>" style="width: 100%"  
                class="form-control skp-lang-input" 
                id="<?php echo esc_attr($id) ?>" 
                value="<?php echo esc_attr($value) ?>" 
                placeholder="<?php echo esc_attr($placeholder) ?>">
            </div>
            <?php if ($info): ?>
                <div class="form-text" id="basic-addon4"><?php echo esc_html($info) ?></div>
            <?php endif; ?>
        </div>
        <?php
    }

    static function renderCheckbox(array $data): void {
        $label = $data['label'] ?? '';
        $id = $data['id'] ?? uniqid('_id_');
        $name = $data['name'] ?? '';
        $value = $data['value'] ?? '';
        $checked = $data['checked'] ?? null;
        ?>
        <div class="mb-3">
            <input class="skp-lang-input" type="checkbox" id="<?php echo esc_attr($id) ?>" name="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($value) ?>" <?php echo $checked ? esc_attr('checked') : '' ?>>
            <label class="skp-lang-input-label" for="<?php echo esc_attr($id) ?>"> <?php echo esc_html($label) ?></label><br>
        </div>
        <?php
    }
}