<?php

namespace WeDevs\AppBridge\Integrations\WPERP;

use WeDevs\AppBridge\Core\AbstractSettingsSchema;

class SettingsSchema extends AbstractSettingsSchema {

	protected function slug(): string {
		return 'wperp';
	}

	protected function button_colors_section(): array {
		return [];
	}

	protected function button_color_fields( array $settings ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
		return [];
	}

	// ── Push Notifications removed for WP ERP ─────────────────────────────────
	// WP ERP already ships its own OneSignal push configuration in the HRM
	// module (erp_integration_settings_erp-push-notification). Suppress the
	// duplicate App Bridge Push Notifications page/section/fields here so the
	// WP ERP plugin remains the single source of truth.

	protected function push_notifications_page(): array {
		return [];
	}

	protected function notification_provider_section(): array {
		return [];
	}

	protected function notification_provider_fields( array $settings ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
		return [];
	}

	// ── WP ERP-specific sections ──────────────────────────────────────────────

	protected function sections(): array {
		return [
			[
				'id'      => 'erp_app',
				'type'    => 'section',
				'label'   => __( 'ERP App', 'app-bridge' ),
				'page_id' => $this->general_page_id(),
			],
		];
	}

	// ── WP ERP-specific fields ────────────────────────────────────────────────

	protected function fields( array $settings ): array {
		return [
			[
				'id'          => 'enable_erp_app',
				'type'        => 'field',
				'variant'     => 'switch',
				'label'       => __( 'Enable ERP App', 'app-bridge' ),
				'section_id'  => 'erp_app',
				'value'       => (bool) ( $settings['enable_erp_app'] ?? true ),
				'description' => __( 'Allow HR/ERP users to access the mobile app.', 'app-bridge' ),
			],
		];
	}

	// ── Sanitization ──────────────────────────────────────────────────────────

	protected function sanitize( array $data ): array {
		$result = parent::sanitize_common( $data );

		if ( isset( $data['erp_app'] ) ) {
			$result['enable_erp_app'] = (bool) ( $data['erp_app']['enable_erp_app'] ?? true );
		}

		return $result;
	}
}
