<?php

declare(strict_types=1);

namespace Dedi\SyliusTheme\Controller\Styleguide;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class StyleguideController extends AbstractController
{
    public function template(string $templateName)
    {
        return $this->render(sprintf('@SyliusShop/Styleguide/%s', $templateName));
    }

    public function styleguide()
    {
        $form = $this->createFormBuilder(null, [
            'attr' => [
                'novalidate' => true,
            ],
        ])
            ->add('txtName01', TextType::class, [
                'label' => 'Exemple de champ text obligatoire',
                'required' => true,
            ])
            ->add('txtName02', TextType::class, [
                'label' => 'Exemple de champ text',
                'required' => false,
                'data' => 'Exemple de champ rempli',
                'attr' => [
                    'placeholder' => 'Exemple de placeholder',
                ],
            ])
            ->add('txtName03', TextType::class, [
                'label' => 'Exemple de champ text',
                'required' => false,
                'help' => "Exemple de texte d'aide ou d'information",
                'attr' => [
                    'placeholder' => 'Exemple de placeholder',
                ],
            ])
            ->add('txtName04', TextType::class, [
                'disabled' => true,
                'required' => false,
                'label' => 'Exemple de champ text disabled',
                'attr' => [
                    'placeholder' => 'Exemple de placeholder',
                ],
            ])

            ->add('selectName01', ChoiceType::class, [
                'placeholder' => 'Sélectionnez un élément',
                'label' => 'Exemple de champ select',
                'choices' => [
                    'Item 1' => '1',
                    'Item 2' => '2',
                    'Item 3' => '3',
                    'Item 4' => '4',
                    'Item 5' => '5',
                ],
                'invalid_message' => 'Message d\'erreur',
            ])
            ->add('selectName02', ChoiceType::class, [
                'placeholder' => 'Sélectionnez un élément',
                'label' => 'Exemple de champ select disabled',
                'required' => false,
                'disabled' => true,
                'choices' => [
                    'Item 1' => '1',
                    'Item 2' => '2',
                    'Item 3' => '3',
                    'Item 4' => '4',
                    'Item 5' => '5',
                ],
                'invalid_message' => 'Message d\'erreur',
            ])

            ->add('customCheckbox01', ChoiceType::class, [
                'expanded' => true,
                'multiple' => true,
                'label' => 'Exemple de checkbox',
                'choices' => [
                    'Checkbox 01' => '1',
                    'Checkbox 02' => '2',
                ],
                'data' => [
                    'Checkbox 01' => '1',
                ],
                'required' => true,
            ])
            ->add('customCheckbox02', ChoiceType::class, [
                'expanded' => true,
                'multiple' => true,
                'label' => 'Exemple de checkbox disabled',
                'choices' => [
                    'Checkbox disabled 01' => '1',
                    'Checkbox disabled 02' => '2',
                ],
                'data' => [
                    'Checkbox 01' => '1',
                ],
                'required' => false,
                'disabled' => true,
            ])

            ->add('customRadio01', ChoiceType::class, [
                'expanded' => true,
                'multiple' => false,
                'label' => 'Exemple de radio disabled',
                'choices' => [
                    'Radio 01' => '1',
                    'Radio 02' => '2',
                ],
                'data' => '1',
            ])
            ->add('customRadio02', ChoiceType::class, [
                'expanded' => true,
                'multiple' => false,
                'label' => 'Exemple de radio disabled',
                'choices' => [
                    'Radio disabled 01' => '1',
                    'Radio disabled 02' => '2',
                ],
                'data' => '1',
                'required' => false,
                'disabled' => true,
                'placeholder' => false,
            ])

            ->add('customSwitch01', ChoiceType::class, [
                'expanded' => true,
                'multiple' => true,
                'label' => 'Exemple de switch disabled',
                'choices' => [
                    'Switch 01' => '1',
                    'Switch 02' => '2',
                ],
                'data' => [
                    'Switch 01' => '1',
                ],
                'label_attr' => ['class' => 'custom-switch'],
            ])
            ->add('customSwitch02', ChoiceType::class, [
                'expanded' => true,
                'multiple' => true,
                'label' => 'Exemple de switch disabled',
                'choices' => [
                    'Switch disabled 01' => '1',
                    'Switch disabled 02' => '2',
                ],
                'data' => [
                    'Switch 01' => '1',
                ],
                'label_attr' => ['class' => 'custom-switch'],
                'required' => false,
                'disabled' => true,
            ])

            ->add('txtareaName01', TextareaType::class, [
                'label' => 'Exemple de champ textarea',
                'invalid_message' => 'Message d\'erreur',
                'attr' => [
                    'rows' => 4,
                ],
            ])
            ->add('txtareaName02', TextareaType::class, [
                'label' => 'Exemple de champ textarea disabled',
                'invalid_message' => 'Message d\'erreur',
                'attr' => [
                    'rows' => 4,
                ],
                'required' => false,
                'disabled' => true,
            ])

            ->getForm()
        ;

        return $this->render('@DediSyliusTheme/Styleguide/styleguide.html.twig', ['form' => $form->createView()]);
    }
}
