<?php

namespace WeDevs\AppBridge\Integrations\WPProjectManager;

use WeDevs\AppBridge\Core\AbstractSettingsSchema;

class SettingsSchema extends AbstractSettingsSchema {

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

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

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

	// ── WP Project Manager-specific sections ──────────────────────────────────

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

	// ── WP Project Manager-specific fields ────────────────────────────────────

	protected function fields( array $settings ): array {
		return [
			[
				'id'          => 'enable_pm_app',
				'type'        => 'field',
				'variant'     => 'switch',
				'label'       => __( 'Enable Project Manager App', 'app-bridge' ),
				'section_id'  => 'pm_app',
				'value'       => (bool) ( $settings['enable_pm_app'] ?? true ),
				'description' => __( 'Allow project managers to access the mobile app.', 'app-bridge' ),
			],
		];
	}

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

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

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

		return $result;
	}
}
