@extends('template.'.config('settings.template').'.content.master')@section('content')

<div class="admin-header">
    <div class="admin-header" style="margin-bottom:0px !important;">
        <div class="container">
            <div class="col">
                <h1><i class="fal fa-user"></i> Profile</h1>
            </div>
        </div>
    </div>

<section>
    <div class="container">
        <div class="row">
            <div class="col-12 col-lg-6 offset-lg-3">
            <form action="{{route('dashboard.profile')}}" method="post" enctype="multipart/form-data">
                @csrf

                <div class="row">
                    <div class="col-12 col-md-4">
                        <a style="cursor:pointer;" onclick="clickImgContent();">
                        <img src="{{ \Auth::user()->gravatar() }}" class="rounded-circle mx-auto d-block img-fluid border" id="img-content-fluid" title="" width="120">
                        </a>

                        @if ($user->image)
                            <a style="margin-left: 22px;padding-top:10px;display:block;" href="{{ route('dashboard.profile.removeImage') }}">Remove Image</a>
                        @endif

                        <br>

                    </div>
                    <div class="col-12 col-md-8">
                        <div class="form-group">
                            <label for="exampleFormControlInputName">Name</label>
                            <input type="text" class="form-control" id="exampleFormControlInputName" value="{{ $user->name }}" placeholder="Name" name='name' required="required">
                        </div>
                    </div>
                </div>

                <br>


                <div class="form-group">
                    <label for="exampleFormControlInputDesc">About me</label>
                    <input type="text" class="form-control" id="exampleFormControlInputDesc" value="{{ $user->description }}" placeholder="Description" name='description' required="required">
                </div>

                <br>
                <br>
                <h5>Social Links</h5>

                <div class="row">

                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="exampleFormControlInputWebsite"> <i class="fal fa-globe"></i> Website</label>
                            <input type="text" class="form-control" id="exampleFormControlInputWebsite" value="{{ isset($user->social_networks['site']) ? $user->social_networks['site'] : '' }}" placeholder="Website" name='social_networks[site]'>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="exampleFormControlInputFacebook"> <i class="fab fa-facebook"></i> Facebook</label>
                            <input type="text" class="form-control" id="exampleFormControlInputFacebook" value="{{ isset($user->social_networks['facebook']) ? $user->social_networks['facebook'] : '' }}" placeholder="Facebook" name='social_networks[facebook]'>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="exampleFormControlInputTwitter"> <i class="fab fa-twitter"></i> Twitter</label>
                            <input type="text" class="form-control" id="exampleFormControlInputTwitter" value="{{ isset($user->social_networks['twitter']) ? $user->social_networks['twitter'] : '' }}" placeholder="Twitter" name='social_networks[twitter]'>
                        </div>
                    </div>
                </div>

                <div class="form-group" style="display: none;">
                    <label for="imageEdit">Image Profile</label>
                    <input type="file" id="imageEdit" accept='image/*' name="image" class="form-control">
                </div>

                <button type="submit" class="btn btn-primary float-right" style="margin-top:10px;">
                    <i class="fal fa-save"></i>
                    Save
                </button>
            </form>
            </div>

        </div>
    </div>
</section>

</div>

<script>
    function clickImgContent()
    {
        document.getElementById('imageEdit').click();
    }

    document.getElementById('imageEdit').addEventListener('change', readURL, true);

    function readURL(){
        var file = document.getElementById("imageEdit").files[0];
        var reader = new FileReader();
        reader.onloadend = function(){
            document.getElementById('img-content-fluid').setAttribute("src", reader.result);
            //document.getElementById('clock').style.backgroundImage = "url(" + reader.result + ")";
        }
        if(file){
            reader.readAsDataURL(file);
        }else{
        }
    }
</script>
@stop
