<!--
Copyright (C) 2022 Echedey López Romero <elr@disroot.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row mb-3">
        <h1 class="col-12 mb-0 text-center">Category edition</h1>
    </div>
    @if ($errors->any())
    <div class = "row mb-3">
        <div class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto alert alert-danger">
            <div class="container">
                <div class="row mb-2">
                    <span class="col-12 text-center"><strong>Whoops!</strong> There were some problems with your input.</span>
                </div>
                <div class="row">
                    <ul class="col-12 mb-0">
                        @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    </div>
    @endif
    <div class="row">
        <form class="col-xl-6 col-lg-8 col-md-10 col-12 mx-auto" action="{{ route('categories.update', $category->id) }}" method="POST">
            @csrf
            @method('PUT')
            <div class="container">
                <div class="row mb-3">
                    <div class="col-12">
                        <label class="form-label" for="name">Name</label>
                        <input class="form-control" type="text" id="name" name="name" value="{{ old('name') ? old('name') : $category->name }}"/>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-12">
                        <label class="form-label" for="description">Description</label>
                        <textarea class="form-control" rows="3" id="description" name="description">{{ old('description') ? old('description') : $category->description }}</textarea>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-6 col-12 mb-lg-0 mb-2">
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">Modify</button>
                        </div>
                    </div>
                    <div class="col-lg-6 col-12">
                        <div class="d-grid gap-2">
                            <button type="reset" class="btn btn-danger">Reset</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
