<?php
namespace Bookaro\Controller\Admin\Settings;

defined( 'ABSPATH' ) || exit;

final class RolesTab extends AbstractSettingsTab
{
    public function get_key(): string
    {
        return 'roles';
    }

    public function get_section(): array
    {
        return [
            'id'    => 'bookaro_roles',
            'title' => __( 'Access', 'mybookaro' ),
            'page'  => 'bookaro-booking-settings-roles',
            'desc'  => __( 'Control who can access provider and customer dashboards.', 'mybookaro' ),
        ];
    }

    public function get_fields(): array
    {
        $roles = $this->context( 'roles', [] );

        return [
            [
                'id' => 'heading_access_roles',
                'label' => '',
                'callback' => 'render_heading_field',
                'section' => 'bookaro_roles',
                'page' => 'bookaro-booking-settings-roles',
                'args' => [
                    'title' => __( 'Dashboard roles', 'mybookaro' ),
                    'description' => __( 'Select roles that should manage provider and customer dashboards.', 'mybookaro' ),
                    'field_type' => 'heading',
                ],
            ],
            [
                'id' => 'note_access_roles',
                'label' => '',
                'callback' => 'render_note_field',
                'section' => 'bookaro_roles',
                'page' => 'bookaro-booking-settings-roles',
                'args' => [
                    'title' => __( 'Tip', 'mybookaro' ),
                    'description' => __( 'MyBookaro automatically adds the required capabilities to the selected roles. Ask users to log out and back in after changing roles.', 'mybookaro' ),
                    'variant' => 'info',
                    'field_type' => 'note',
                ],
            ],
            [ 'id'=>'provider_role', 'label'=>__( 'Service Provider Role', 'mybookaro' ), 'callback'=>'render_select_field', 'section'=>'bookaro_roles','page'=>'bookaro-booking-settings-roles','args'=>[ 'options'=>$roles,'default'=>'','tooltip'=>__( 'Role that can access the provider dashboard and manage bookings.', 'mybookaro' ) ] ],
            [ 'id'=>'owner_role', 'label'=>__( 'Customer Role', 'mybookaro' ), 'callback'=>'render_select_field', 'section'=>'bookaro_roles','page'=>'bookaro-booking-settings-roles','args'=>[ 'options'=>$roles,'default'=>'','tooltip'=>__( 'Role that can access the customer dashboard and view bookings.', 'mybookaro' ) ] ],
        ];
    }
}
