<?php

namespace App\Http\Requests\NotificationSetting;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        // React 구조 검증:
        // {
        //   "notice": { "enabled": true, "notice": { "enabled": true, "email": false }, ... },
        //   "schedule": { "enabled": false, ... },
        //   ...
        // }
        return [
            'notice' => ['sometimes', 'array'],
            'notice.enabled' => ['sometimes', 'boolean'],
            'notice.notice' => ['sometimes', 'array'],
            'notice.notice.enabled' => ['sometimes', 'boolean'],
            'notice.notice.email' => ['sometimes', 'boolean'],
            'notice.event' => ['sometimes', 'array'],
            'notice.event.enabled' => ['sometimes', 'boolean'],
            'notice.event.email' => ['sometimes', 'boolean'],

            'schedule' => ['sometimes', 'array'],
            'schedule.enabled' => ['sometimes', 'boolean'],
            'schedule.vatReport' => ['sometimes', 'array'],
            'schedule.vatReport.enabled' => ['sometimes', 'boolean'],
            'schedule.vatReport.email' => ['sometimes', 'boolean'],
            'schedule.incomeTaxReport' => ['sometimes', 'array'],
            'schedule.incomeTaxReport.enabled' => ['sometimes', 'boolean'],
            'schedule.incomeTaxReport.email' => ['sometimes', 'boolean'],

            'vendor' => ['sometimes', 'array'],
            'vendor.enabled' => ['sometimes', 'boolean'],
            'vendor.newVendor' => ['sometimes', 'array'],
            'vendor.newVendor.enabled' => ['sometimes', 'boolean'],
            'vendor.newVendor.email' => ['sometimes', 'boolean'],
            'vendor.creditRating' => ['sometimes', 'array'],
            'vendor.creditRating.enabled' => ['sometimes', 'boolean'],
            'vendor.creditRating.email' => ['sometimes', 'boolean'],

            'attendance' => ['sometimes', 'array'],
            'attendance.enabled' => ['sometimes', 'boolean'],
            'attendance.annualLeave' => ['sometimes', 'array'],
            'attendance.annualLeave.enabled' => ['sometimes', 'boolean'],
            'attendance.annualLeave.email' => ['sometimes', 'boolean'],
            'attendance.clockIn' => ['sometimes', 'array'],
            'attendance.clockIn.enabled' => ['sometimes', 'boolean'],
            'attendance.clockIn.email' => ['sometimes', 'boolean'],
            'attendance.late' => ['sometimes', 'array'],
            'attendance.late.enabled' => ['sometimes', 'boolean'],
            'attendance.late.email' => ['sometimes', 'boolean'],
            'attendance.absent' => ['sometimes', 'array'],
            'attendance.absent.enabled' => ['sometimes', 'boolean'],
            'attendance.absent.email' => ['sometimes', 'boolean'],

            'order' => ['sometimes', 'array'],
            'order.enabled' => ['sometimes', 'boolean'],
            'order.salesOrder' => ['sometimes', 'array'],
            'order.salesOrder.enabled' => ['sometimes', 'boolean'],
            'order.salesOrder.email' => ['sometimes', 'boolean'],
            'order.purchaseOrder' => ['sometimes', 'array'],
            'order.purchaseOrder.enabled' => ['sometimes', 'boolean'],
            'order.purchaseOrder.email' => ['sometimes', 'boolean'],

            'approval' => ['sometimes', 'array'],
            'approval.enabled' => ['sometimes', 'boolean'],
            'approval.approvalRequest' => ['sometimes', 'array'],
            'approval.approvalRequest.enabled' => ['sometimes', 'boolean'],
            'approval.approvalRequest.email' => ['sometimes', 'boolean'],
            'approval.draftApproved' => ['sometimes', 'array'],
            'approval.draftApproved.enabled' => ['sometimes', 'boolean'],
            'approval.draftApproved.email' => ['sometimes', 'boolean'],
            'approval.draftRejected' => ['sometimes', 'array'],
            'approval.draftRejected.enabled' => ['sometimes', 'boolean'],
            'approval.draftRejected.email' => ['sometimes', 'boolean'],
            'approval.draftCompleted' => ['sometimes', 'array'],
            'approval.draftCompleted.enabled' => ['sometimes', 'boolean'],
            'approval.draftCompleted.email' => ['sometimes', 'boolean'],

            'production' => ['sometimes', 'array'],
            'production.enabled' => ['sometimes', 'boolean'],
            'production.safetyStock' => ['sometimes', 'array'],
            'production.safetyStock.enabled' => ['sometimes', 'boolean'],
            'production.safetyStock.email' => ['sometimes', 'boolean'],
            'production.productionComplete' => ['sometimes', 'array'],
            'production.productionComplete.enabled' => ['sometimes', 'boolean'],
            'production.productionComplete.email' => ['sometimes', 'boolean'],
        ];
    }
}
