<%
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton 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 Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>

<%= form_for @user, url: update_user_path, method: :patch do |f|  %>
  <%= hidden_field_tag :setting, "account" %>
  <div class="form-group">
    <div class="row">
      <div class="col-6">
        <%= f.label t("settings.account.fullname"), class: "form-label" %>
        <div class="input-icon">
          <%= f.text_field :name, class: "form-control #{form_is_invalid?(@user, :name)}", placeholder: t("settings.account.fullname") %>
        </div>
      </div>

      <div class="col-6">
        <%= f.label t("email"), class: "form-label" %>
        <div class="input-icon">
          <%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", placeholder: t("email"), readonly: !current_user.greenlight_account? %>
        </div>
      </div>
    </div>
    <br>
    <%= f.label t("settings.account.provider"), class: "form-label" %>
    <%= f.text_field :provider, class: "form-control", readonly: "" %>

    <%= f.label t("settings.account.image"), class: "form-label mt-5" %>
    <div class="row">
      <div class="col-2">
        <% if current_user.image.blank? %>
          <span class="avatar avatar-xxl mr-5 mt-2"><%= current_user.name.first %></span>
        <% else %>
          <span class="avatar avatar-xxl mr-5 mt-2" style="background-image: url(<%= current_user.image %>)"></span>
        <% end %>
      </div>
      <div class="col-10 mt-5">
        <%= f.text_field :image, class: "form-control #{form_is_invalid?(@user, :image)}", placeholder: t("settings.account.image_url") %>
      </div>
    </div>
  </div>
  <div class="card-footer">
    <%= f.submit t("update"), class: "btn btn-primary float-right" %>
  </div>
<% end %>
