<?php

namespace App\Handlers;

use App\Filters\ProductCategory;
use App\Filters\ProductPrice;
use Symfony\Component\HttpFoundation\JsonResponse;

class FiltersHandler
{
    public function getFiltersForMainPage(): JsonResponse
    {
        $filters = [
            'operand' => 'AND',
            'rules' => [
                ProductPrice::NAME => [
                    'criteria' => [
                        'product_price' => [
                            'type' => 'number',
                            'params' => [
                                'operator' => 'between',
                                'value' => [
                                    'from' => 0,
                                    'to' => null,
                                ],
                            ],
                        ],
                    ],
                ],

                ProductCategory::NAME => [
                    'criteria' => [
                        'product_category_id' => [
                            'type' => 'product_category',
                            'params' => [
                                'operator' => 'contains',
                                'value' => null,
                            ],
                        ],
                    ]
                ],
            ],
        ];

        return new JsonResponse([
            'data' => $filters,
        ]);
    }
}
