<?php

namespace App\Http\Requests\Quote;

use App\Models\Quote\Quote;
use Illuminate\Foundation\Http\FormRequest;

class QuoteCalculateRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'product_category' => 'nullable|in:'.Quote::CATEGORY_SCREEN.','.Quote::CATEGORY_STEEL,

            // 입력값 (직접 또는 inputs 객체로)
            'inputs' => 'nullable|array',

            // 공통 입력
            'W0' => 'nullable|numeric|min:0',
            'H0' => 'nullable|numeric|min:0',
            'QTY' => 'nullable|integer|min:1',
            'inputs.W0' => 'nullable|numeric|min:0',
            'inputs.H0' => 'nullable|numeric|min:0',
            'inputs.QTY' => 'nullable|integer|min:1',

            // 스크린 제품 입력
            'INSTALL_TYPE' => 'nullable|in:wall,ceiling,floor',
            'MOTOR_TYPE' => 'nullable|in:standard,heavy',
            'CONTROL_TYPE' => 'nullable|in:switch,remote,smart',
            'CHAIN_SIDE' => 'nullable|in:left,right',
            'inputs.INSTALL_TYPE' => 'nullable|in:wall,ceiling,floor',
            'inputs.MOTOR_TYPE' => 'nullable|in:standard,heavy',
            'inputs.CONTROL_TYPE' => 'nullable|in:switch,remote,smart',
            'inputs.CHAIN_SIDE' => 'nullable|in:left,right',

            // 철재 제품 입력
            'MATERIAL' => 'nullable|in:ss304,ss316,galvanized',
            'THICKNESS' => 'nullable|numeric|min:0.1|max:50',
            'FINISH' => 'nullable|in:hairline,mirror,matte',
            'WELDING' => 'nullable|in:tig,mig,spot',
            'inputs.MATERIAL' => 'nullable|in:ss304,ss316,galvanized',
            'inputs.THICKNESS' => 'nullable|numeric|min:0.1|max:50',
            'inputs.FINISH' => 'nullable|in:hairline,mirror,matte',
            'inputs.WELDING' => 'nullable|in:tig,mig,spot',
        ];
    }
}
