<?php

namespace Modules\Vrc\Http\Controllers\Registers;

use Modules\Vrc\Entities\VrcWorkCenter;

class WorkCenterController extends AbstractRegisterController
{
    protected function schema(): array
    {
        $types = [
            'mechanical' => 'Mechanical', 'body_paint' => 'Body / Paint', 'electrical' => 'Electrical',
            'diagnostics' => 'Diagnostics', 'qc' => 'Quality Control', 'wash' => 'Wash / Detailing', 'other' => 'Other',
        ];

        return [
            'key' => 'work_centers',
            'route' => 'vrc.work-centers',
            'model' => VrcWorkCenter::class,
            'permView' => 'vrc.workflow.view',
            'permManage' => 'vrc.workflow.manage',
            'title' => 'Work Centers',
            'singular' => 'Work Center',
            'modalSize' => 'modal',
            'defaults' => ['is_active' => true],
            'columns' => [
                ['key' => 'name', 'label' => 'Name'],
                ['key' => 'type', 'label' => 'Type', 'map' => $types, 'badge' => array_fill_keys(array_keys($types), 'info')],
                ['key' => 'is_active', 'label' => 'Active', 'map' => [1 => 'Active', 0 => 'Inactive'], 'badge' => [1 => 'success', 0 => 'default'], 'noSort' => true],
            ],
            'fields' => [
                ['name' => 'name', 'label' => 'Name (EN)', 'type' => 'text', 'required' => true, 'col' => 6, 'max' => 191],
                ['name' => 'name_ar', 'label' => 'Name (AR)', 'type' => 'text', 'col' => 6, 'rtl' => true, 'max' => 191],
                ['name' => 'type', 'label' => 'Type', 'type' => 'select', 'options' => $types, 'required' => true, 'col' => 4, 'default' => 'mechanical'],
                ['name' => 'color', 'label' => 'Colour (hex)', 'type' => 'text', 'col' => 4, 'max' => 12],
                ['name' => 'sort_order', 'label' => 'Sort order', 'type' => 'number', 'col' => 4, 'default' => 0],
                ['name' => 'is_active', 'label' => 'Active', 'type' => 'checkbox', 'col' => 12, 'default' => true],
            ],
        ];
    }
}
