<?php

namespace apexl\Io\modules\userDisplay\forms;

use apexl\Io\includes\System;
use apexl\Io\modules\formbuilder\entities\formEntity;
use apexl\Io\modules\formbuilder\includes\inputField;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class filters
{
    public function userFilter(Request $request, Response $response)
    {
        $form = new formEntity();
        $form->addClass('filter-form');
        $form->setMethod('post');
        $form->setActionUrl('#');
        $form->setSubmitText('Search');
        $form->includeClearButton()->setClearButtonText('Reset filters');

        $form->addFieldToGroup((new inputField('email'))->setLabel('Email')->setInputType('email'), 'user_filters');
        $form->addFieldToGroup((new inputField('first_name'))->setLabel('First Name'), 'user_filters');
        $form->addFieldToGroup((new inputField('last_name'))->setLabel('Last Name'), 'user_filters');

        return $this->json($response, $form->getBuiltFormArray());
    }
}
