{% extends "layouts/app.twig" %}

{% block title %}{{ lang.add }} {{ lang.user }}{% endblock %}

{% block content %}
    <div class="page-wrapper">
        <div class="page-content">

            <!--breadcrumb-->
            <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
                <div class="breadcrumb-title pe-3"><a href="{{route('user.index')}}" class="text-dark">{{ lang.users }}</a></div>
                <div class="ps-3">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb mb-0 p-0">
                            <li class="breadcrumb-item active" aria-current="page">{{ lang.add }} {{ lang.user }}</li>
                        </ol>
                    </nav>
                </div>
                <div class="ms-auto">
                    <div class="btn-group btn-group-sm">
                        <a class="btn btn-primary btn-sm" href="{{route('user.index')}}"><i class="bi bi-reply font16"></i> {{ lang.go_back }}</a>
                    </div>
                </div>
            </div>
            <!--end breadcrumb-->

            <div class="row">
                <div class="col-xl-7 mx-auto">
                    <div class="card border shadow-none">
                        <div class="card-body p-5">
                            <form class="row g-3" method="post" action="{{ route('user.store') }}">
                                {{ csrf.field | raw }}
                                <div class="col-md-12">
                                    <label for="name" class="form-label">{{ lang.user_name }}</label>
                                    <input type="text" class="form-control {{ errors.name ? ' is-invalid' : '' }}" id="name" name="name">
                                    {% if errors.name %}
                                        <div class="invalid-feedback">{{ errors.name | first }}</div>
                                    {% endif %}
                                </div>
                                <div class="col-md-12">
                                    <label for="username" class="form-label">{{ lang.user_username }}</label>
                                    <input type="text" class="form-control {{ errors.username ? ' is-invalid' : '' }}" id="username" name="username">
                                    {% if errors.username %}
                                        <div class="invalid-feedback">{{ errors.username | first }}</div>
                                    {% endif %}
                                </div>
                                <div class="col-md-12">
                                    <label for="email" class="form-label">{{ lang.user_email }}</label>
                                    <input type="email" class="form-control {{ errors.email ? ' is-invalid' : '' }}" id="email" name="email">
                                    {% if errors.name %}
                                        <div class="invalid-feedback">{{ errors.email | first }}</div>
                                    {% endif %}
                                </div>
                                <div class="col-md-12">
                                    <label for="role" class="form-label">{{ lang.roles }}</label>
                                    <select class="form-select mb-3" name="role" aria-label="Select">
                                        <option value="{{ role.super_admin }}">{{ lang.role_super_admin }}</option>
                                        <option value="{{ role.admin }}">{{ lang.role_admin }}</option>
                                        <option value="{{ role.users }}">{{ lang.role_user }}</option>
                                    </select>
                                </div>
                                <div class="col-md-12">
                                    <div class="input-group mb-3">
                                        <label for="password" class="form-label d-none">{{ lang.user_password }}</label>
                                        <input type="password" name="password" placeholder="{{ lang.user_password }}" id="password" class="form-control {{ errors.password ? ' is-invalid' : '' }}" />
                                        <span class="input-group-text"><a href="javascript:;" class="text-dark" onclick="showPassword()">Show</a></span>
                                        {% if errors.password %}
                                            <div class="invalid-feedback">{{ errors.password | first }}</div>
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="col-12">
                                    <button type="submit" class="btn btn-primary px-5">{{ lang.create }}</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block innerjs %}
    <script>
        function showPassword() {
            var x = document.getElementById("password");
            if (x.type === "password") {
                x.type = "text";
            } else {
                x.type = "password";
            }
        }
    </script>
{% endblock %}
