{% extends 'base.html' %}

{% block content %}

    <!-- Template taken from https://www.bootdey.com/snippets/view/profile-with-data-and-skills#html -->

    {% if not user.profile.imported_yt_playlists %}
              <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
                  <symbol id="check-circle-fill" fill="currentColor" viewBox="0 0 16 16">
                    <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
                  </symbol>
                  <symbol id="info-fill" fill="currentColor" viewBox="0 0 16 16">
                    <path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
                  </symbol>
                  <symbol id="exclamation-triangle-fill" fill="currentColor" viewBox="0 0 16 16">
                    <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
                  </symbol>
              </svg>

                <div class="alert alert-primary d-flex align-items-center" role="alert">
                  <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Info:"><use xlink:href="#info-fill"/></svg>
                  <div>
                      You have not imported your YouTube playlists yet!
                      <a class="btn btn-success btn-sm" href="{% url 'import_user_yt_playlists' %}">Import</a>
                  </div>
                </div>
              {% endif %}

      <div class="row g-5">
        <div class="col-md-3 mb-3 d-flex justify-content-start">
          <h1><span style="border-bottom: 3px #a35a5a dashed;">User Settings</span></h1>
          <div class="card bg-dark text-white visually-hidden">
            <div class="card-body">

            <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Pick a picture:</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <img src="https://robohash.org/{{ user.username }}.png?set=set1" alt="{{ user.username }}" class="border border-3 {% if user.profile.robohash_set == 1 %}border-primary{% endif %} rounded-circle" width="65">
                    <input class="form-check-input visually-hidden" type="radio" name="profilePicRadio" id="flexRadioDefault1">

                    <img src="https://robohash.org/{{ user.username }}.png?set=set2" alt="{{ user.username }}" class="border border-3 {% if user.profile.robohash_set == 2 %}border-primary{% endif %} rounded-circle" width="65">
                    <input class="form-check-input visually-hidden" type="radio" name="profilePicRadio" id="flexRadioDefault2">

                    <img src="https://robohash.org/{{ user.username }}.png?set=set3" alt="{{ user.username }}" class="border border-3 {% if user.profile.robohash_set == 3 %}border-primary{% endif %} rounded-circle" width="65">
                    <input class="form-check-input visually-hidden" type="radio" name="profilePicRadio" id="flexRadioDefault3">

                    <img src="https://robohash.org/{{ user.username }}.png?set=set4" alt="{{ user.username }}" class="border border-3 {% if user.profile.robohash_set == 4 %}border-primary{% endif %} rounded-circle" width="65">
                    <input class="form-check-input visually-hidden" type="radio" name="profilePicRadio" id="flexRadioDefault4">
                </div>
            </div>
            <hr>
              <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Summary</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <textarea class="form-control form-text" id="summary">{{ user.profile.user_summary }}</textarea>
                </div>
              </div>
            <hr>
              <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Location</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <input type="text" class="form-control" id="location" value="{{ user.profile.user_location }}">
                </div>
              </div>
            <hr>
                    <a href="{% url 'update_settings' %}" class="btn btn-success">Update</a>

            </div>
          </div>

        </div>
        <div class="col-md-9">

          <div class="card bg-dark text-white mb-3">
            <div class="card-body">
                <form action="{% url 'update_settings' %}" method="post">
                    {% csrf_token %}
                        <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Username</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <input type="text" class="form-control" name="username" id="username" value="{{ user.username }}">

                </div>
              </div>
              <hr>
              <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Full Name</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <input type="text" class="form-control" id="fullname" value="{{ user.get_full_name }}" disabled>
                </div>
              </div>
              <hr>
              <div class="row">
                <div class="col-sm-3">
                  <h6 class="mb-0">Email</h6>
                </div>
                <div class="col-sm-9 text-white-50">
                    <input type="email" class="form-control" id="email" aria-describedby="emailHelp" value="{{ user.email }}" disabled>
                    <div id="emailHelp" class="form-text">This is the google account you logged in with.</div>
                </div>
              </div>
              <hr>

                <div class="row">
                    <div class="col-sm-3">
                        <h6 class="mb-0">Global Preferences</h6>
                    </div>
                    <div class="col-sm-9 text-white">
                        <div class="mb-3 form-check form-switch">
                        <input class="form-check-input" name="open search in new tab" type="checkbox" id="openSearchCheckDefault" {% if user.profile.open_search_new_tab %} checked {% endif %}>
                        <label class="form-check-label" for="openSearchCheckDefault">Open Search in new tab</label>
                        </div>


                        <div class="mb-3 form-check form-switch">
                        <input class="form-check-input" name="enable gradient bg" type="checkbox" id="gradient-bg" {% if user.profile.enable_gradient_bg  %}checked{% endif %}>
                        <label class="form-check-label" for="gradient-bg">Use a gradient background</label>
                        </div>

                        <div class="mb-3 form-check form-switch">
                        <input class="form-check-input" name="hide videos" type="checkbox" id="hide-videos" {% if user.profile.hide_unavailable_videos %}checked{% endif %}>
                        <label class="form-check-label" for="hide-videos">Hide deleted/private videos</label>
                        </div>

                        <div class="mb-3 form-check form-switch">
                        <input class="form-check-input" name="confirm before deleting" type="checkbox" id="confirm-before-delete" {% if user.profile.confirm_before_deleting  %}checked{% endif %}>
                        <label class="form-check-label" for="confirm-before-delete">Confirm before deleting</label>
                        </div>

                    </div>
                </div>
                <hr>

              <div class="row">
                <div class="col-sm-12">

                    <button type="submit" class="btn btn-success me-1">Save</button>
                    <a class="btn btn-outline-danger" href="{% url 'delete_account' %}">Delete UnTube account</a>

                </div>
              </div>
                </form>



            </div>
          </div>

                  <div class="card mt-3 bg-dark ">

    <ul class="list-group list-group-flush">
      <li class="list-group-item bg-dark d-flex justify-content-between align-items-center flex-wrap">
        <h6 class="mb-0 text-white">Access Token</h6>
        <span class="text-white-50">{{ user.profile.access_token }}</span>
      </li>
      <li class="list-group-item bg-dark d-flex justify-content-between align-items-center flex-wrap">
        <h6 class="mb-0 text-white">
        Refresh Token</h6>
        <span class="text-white-50">{{ user.profile.refresh_token }}</span>
      </li>
      <li class="list-group-item bg-dark d-flex justify-content-between align-items-center flex-wrap">
        <h6 class="mb-0 text-white">Expires At</h6>
        <span class="text-white-50">{{ user.profile.expires_at }}</span>
      </li>
    </ul>
  </div>


        </div>
      </div>

{% endblock %}