<?php
/**
 * Affiliate Module Settings Schema
 * 
 * Defines the settings schema for the Affiliate module.
 * 
 * @package WooNooW\Modules\Affiliate
 */

namespace WooNooW\Modules\Affiliate;

class AffiliateSettings {
    
    public static function init() {
        // Register settings schema
        add_filter('woonoow/module_settings_schema', [__CLASS__, 'register_schema']);
    }
    
    /**
     * Register affiliate settings schema
     */
    public static function register_schema($schemas) {
        $schemas['affiliate'] = [
            'woonoow_affiliate_default_rate' => [
                'type' => 'number',
                'label' => __('Default Commission Rate (%)', 'woonoow'),
                'description' => __('The default commission rate percentage for affiliates.', 'woonoow'),
                'placeholder' => '10',
                'default' => 10,
                'min' => 0,
                'max' => 100,
            ],
            'woonoow_affiliate_holding_period' => [
                'type' => 'number',
                'label' => __('Holding Period (Days)', 'woonoow'),
                'description' => __('Number of days before a referral becomes eligible for payout (e.g. to account for refunds). Set to 0 for immediate approval on order completion.', 'woonoow'),
                'placeholder' => '14',
                'default' => 14,
                'min' => 0,
            ],
            'woonoow_affiliate_payment_methods' => [
                'type' => 'multiselect',
                'label' => __('Available Payment Methods', 'woonoow'),
                'description' => __('Select which payment methods affiliates can use to receive payouts.', 'woonoow'),
                'options' => [
                    'bank_transfer' => __('Bank Transfer', 'woonoow'),
                    'paypal' => __('PayPal', 'woonoow'),
                    'wise' => __('Wise', 'woonoow'),
                    'skrill' => __('Skrill', 'woonoow'),
                    'payoneer' => __('Payoneer', 'woonoow'),
                    'custom' => __('Custom (Notes)', 'woonoow'),
                ],
                'default' => ['bank_transfer'],
            ],
            'woonoow_affiliate_auto_approve' => [
                'type' => 'toggle',
                'label' => __('Auto-Approve Affiliates', 'woonoow'),
                'description' => __('Automatically approve new affiliate applications.', 'woonoow'),
                'default' => false,
            ],
            'woonoow_affiliate_allow_self_referral' => [
                'type' => 'toggle',
                'label' => __('Allow Self-Referrals', 'woonoow'),
                'description' => __('Allow affiliates to earn commission when their own user account places an order.', 'woonoow'),
                'default' => false,
            ],
        ];
        
        return $schemas;
    }
}
