<?php
/**
 * انبارداری — کامپوننت انبار: فهرست محصولات (AG Grid).
 */
if (!defined('ABSPATH')) {
    exit;
}

if (function_exists('zerti_inventory_should_show_product_editor') && zerti_inventory_should_show_product_editor()) {
    zerti_render_inventory_product_edit();

    return;
}

$wc_ok = class_exists('WooCommerce') && function_exists('wc_get_products');
?>
<?php
zerti_ui_component_open('inventory-warehouse', [
    'class' => 'zerti-component-inventory zerti-inventory-sub-slot',
    'data-zerti-inv-active' => 'warehouse',
    'data-zerti-inv-component' => 'warehouse',
]);
?>
    <?php if (!$wc_ok) : ?>
        <?php zerti_ui_wc_required_notice(__('WooCommerce must be installed and active to view products.', 'zerti')); ?>
    <?php else : ?>
        <div class="zerti-products-panel">
            <div class="zerti-products-wrap">
                <?php
                zerti_ui_toolbar_open(
                    __('Search and export products list', 'zerti'),
                    'zerti-products-grid-toolbar'
                );
                ?>
                    <div class="zerti-products-grid-toolbar-search"></div>
                    <?php do_action('zerti_inventory_toolbar_export'); ?>
                <?php zerti_ui_toolbar_close(); ?>
                <?php
                zerti_ui_ag_grid_region(
                    'zertiProductsGrid',
                    'zerti-products-grid',
                    __('Products table', 'zerti')
                );
                ?>
            </div>
        </div>
    <?php endif; ?>
<?php zerti_ui_component_close(); ?>
