<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <title>VAG - Dienstkleidung</title>
    <!-- CSS files -->
    <link href="<%= domain %>/dist/css/tabler.min.css?1684106062" rel="stylesheet"/>
    <link href="<%= domain %>/dist/css/tabler-flags.min.css?1684106062" rel="stylesheet"/>
    <link href="<%= domain %>/dist/css/tabler-payments.min.css?1684106062" rel="stylesheet"/>
    <link href="<%= domain %>/dist/css/tabler-vendors.min.css?1684106062" rel="stylesheet"/>
    <style>
      @import url('https://rsms.me/inter/inter.css');
      :root {
      	--tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
      }
      body {
      	font-feature-settings: "cv03", "cv04", "cv11";
      }
    </style>
  </head>
  <body >
    <script src="/appjs/format.js"></script>
    <div class="page">
      <!-- Navbar -->
      <header class="navbar navbar-expand-md d-print-none" >
        <div class="container-xl">
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-menu" aria-controls="navbar-menu" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <h1 class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
            <a href="/dashboard">
              <img src="/dist/logo-transparent.png" width="110" height="32" alt="EBG" class="navbar-brand-image">
              <div data-translate="Dashboard.Header.Pagename">
            </a>
          </h1>
          <div class="navbar-nav flex-row order-md-last">
            <div class="nav-item d-none d-md-flex me-3">
              <div class="btn-list">
                <!-- Download SVG icon from http://tabler-icons.io/i/heart -->
                <svg  xmlns="http://www.w3.org/2000/svg"  width="24"  height="24"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-coins"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 14c0 1.657 2.686 3 6 3s6 -1.343 6 -3s-2.686 -3 -6 -3s-6 1.343 -6 3z" /><path d="M9 14v4c0 1.656 2.686 3 6 3s6 -1.344 6 -3v-4" /><path d="M3 6c0 1.072 1.144 2.062 3 2.598s4.144 .536 6 0c1.856 -.536 3 -1.526 3 -2.598c0 -1.072 -1.144 -2.062 -3 -2.598s-4.144 -.536 -6 0c-1.856 .536 -3 1.526 -3 2.598z" /><path d="M3 6v10c0 .888 .772 1.45 2 2" /><path d="M3 11c0 .888 .772 1.45 2 2" /></svg>
                <div id="UserCreditamount"></div>
              </div>
            </div>
            <div class="d-none d-md-flex">
              <a onclick="toggleColor('dark')" class="nav-link px-0 hide-theme-dark" style="cursor: pointer;" data-translate-title="Dashboard.Header.Buttons.ToggleColor.Dark" title="" data-bs-toggle="tooltip"
		   data-bs-placement="bottom">
                <!-- Download SVG icon from http://tabler-icons.io/i/moon -->
                <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" /></svg>
              </a>
              <a onclick="toggleColor('light')" class="nav-link px-0 hide-theme-light" style="cursor: pointer;" data-translate-title="Dashboard.Header.Buttons.ToggleColor.Light" title="" data-bs-toggle="tooltip"
		   data-bs-placement="bottom">
                <!-- Download SVG icon from http://tabler-icons.io/i/sun -->
                <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" /><path d="M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7" /></svg>
              </a>
              <div class="nav-item dropdown d-none d-md-flex me-3">
                <a data-translate-title="Dashboard.Header.Buttons.ShoppingCart" class="nav-link px-0" data-bs-toggle="dropdown" tabindex="-1" aria-label="Show notifications">
                  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-shopping-cart">
                    <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
                    <path d="M6 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"/>
                    <path d="M17 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"/>
                    <path d="M17 17h-11v-14h-2"/>
                    <path d="M6 5l14 1l-1 7h-13"/>
                  </svg>
                  
                </a>
                <div class="dropdown-menu dropdown-menu-arrow dropdown-menu-end" style="width: 400px;">
                  <div class="card">
                    <div class="card-header">
                      <h3 class="card-title" data-translate="Dashboard.Header.Buttons.ShoppingCart"></h3>
                    </div>
                    <div class="list-group list-group-flush list-group-hoverable">
                      <div class="list-group-item">
                        <div class="row align-items-center">
                          <a href="/cart" class="col text-truncate">
                            <span class="text-body d-block" id="CartHeaderElementAmount"></span>
                            <div class="d-block text-muted text-truncate mt-n1">
                              <span id="CartHeaderElementCost"></span>
                            </div>
                          </a>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>              
            </div>
            <div class="nav-item dropdown">
              <a class="nav-link d-flex lh-1 text-reset p-0" data-bs-toggle="dropdown" aria-label="Open user menu">
                <span class="avatar avatar-sm" id="Dashboard.Profile.AvatarIcon" style="background-image: url()"></span>
                <div class="d-none d-xl-block ps-2">
                  <div id="Dashboard.Profile.Username"></div>
                  <div class="mt-1 small text-muted" id="Dashboard.Profile.User_Group"></div>
                </div>
              </a>
              <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow" id="Dashboard.ProfileDropdown">
              </div>
            </div>
          </div>
        </div>
      </header>
      <header class="navbar-expand-md">
        <div class="collapse navbar-collapse" id="navbar-menu">
          <div class="navbar">
            <div class="container-xl">
              <ul class="navbar-nav" id="Dashboard.Navbar.Elements">
              </ul>
            </div>
          </div>
        </div>
      </header>
      <div class="page-wrapper">
        <!-- Page header -->
        <div class="page-header d-print-none">
          <div class="container-xl">
            <div class="row g-2 align-items-center">
              <div class="col">
                <h2 class="page-title" data-translate="Settings.Main.SettingsName"></h2>
              </div>
            </div>
          </div>
        </div>
        <!-- Page body -->
        <div class="page-body">
          <div class="container-xl">
            <div class="card">
              <div class="row g-0">
                <div class="col-3 d-none d-md-block border-end">
                  <div class="card-body">
                    <div class="list-group list-group-transparent">
                      <a href="/settings-account" class="list-group-item list-group-item-action d-flex align-items-center active" data-translate="Settings.Side.Account"></a>
                      <a href="/settings-misc" class="list-group-item list-group-item-action d-flex align-items-center" data-translate="Settings.Side.Misc"></a>
                    </div>
                  </div>
                </div>
                <div class="col d-flex flex-column">
                  <div class="card-body">
                    <h2 class="mb-4" data-translate="Settings.Main.SettingsName"></h2>
                    <h3 class="card-title" data-translate="Settings.Main.ProfileHeadline"></h3>
                    <div class="row align-items-center">
                      <div class="col-auto"><span class="avatar avatar-xl" id="Settings.Profile.AvatarIcon" style="background-image: url()"></span></div>
                      <div class="col-auto"><a class="btn" data-translate="Settings.Profile.SetAvatarIcon"></a></div>
                      <div class="col-auto"><a data-bs-toggle="modal" data-bs-target="#modal-danger-delete-avatar" class="btn btn-ghost-danger" data-translate="Settings.Profile.DeleteAvatarIcon" id="DelAvatarIcon"></a></div>
                    </div>
                    <h3 class="card-title mt-4" data-translate="Settings.Main.AccountHeadline"></h3>
                    <div class="row g-3">
                      <div class="col-md">
                        <div class="form-label" data-translate="Settings.Main.Username"></div>
                        <input type="text" class="form-control" value="" onchange="handleInputChange(this.id)" id="SettingsUsername">
                      </div>
                      <div class="col-md">
                        <div class="form-label" data-translate="Settings.Main.Email"></div>
                        <input type="text" class="form-control" value="" onchange="handleInputChange(this.id)" id="SettingsEmail">
                      </div>
                    </div>
                    <br>
                    <div class="row g-3">
                      <div class="col-md">
                        <div class="form-label" data-translate="Settings.Main.FirstName"></div>
                        <input type="text" class="form-control" value="" onchange="handleInputChange(this.id)" id="SettingsFirstName">
                      </div>
                      <div class="col-md">
                        <div class="form-label" data-translate="Settings.Main.LastName"></div>
                        <input type="text" class="form-control" value="" onchange="handleInputChange(this.id)" id="SettingsLastName">
                      </div>
                    </div>
                    <br>
                    <h3 class="card-title mt-4" data-translate="Settings.Main.PasswordHeadline"></h3>
                    <div>
                      <div class="row g-2">
                        <div class="col-auto">
                          <div class="form-label" data-translate="Settings.Main.PasswordOld"></div>
                          <div class="input-group input-group-flat">
                            <input
                              id="SettingsPasswordOLD"
                              type="password"
                              class="form-control"
                              data-translate-placeholder="Login.Placeholder.Password"
                              placeholder=""
                              autocomplete="off" />
                            <span class="input-group-text">
                              <a
                                id="passwordToggle_old"
                                class="link-secondary"
                                title="Show password"
                                data-bs-toggle="tooltip"
                                ><!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                                <svg
                                  xmlns="http://www.w3.org/2000/svg"
                                  class="icon"
                                  width="24"
                                  height="24"
                                  viewBox="0 0 24 24"
                                  stroke-width="2"
                                  stroke="currentColor"
                                  fill="none"
                                  stroke-linecap="round"
                                  stroke-linejoin="round">
                                  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                                  <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
                                  <path
                                    d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
                                </svg>
                              </a>
                            </span>
                          </div>
                        </div>
                        <div class="col-auto">
                          <div class="form-label" data-translate="Settings.Main.PasswordRepeat"></div>
                          <div class="input-group input-group-flat">
                            <input
                              id="SettingsPasswordOLD_R"
                              type="password"
                              class="form-control"
                              data-translate-placeholder="Login.Placeholder.Password"
                              placeholder=""
                              autocomplete="off" />
                            <span class="input-group-text">
                              <a
                                id="passwordToggle_old_r"
                                class="link-secondary"
                                title="Show password"
                                data-bs-toggle="tooltip"
                                ><!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                                <svg
                                  xmlns="http://www.w3.org/2000/svg"
                                  class="icon"
                                  width="24"
                                  height="24"
                                  viewBox="0 0 24 24"
                                  stroke-width="2"
                                  stroke="currentColor"
                                  fill="none"
                                  stroke-linecap="round"
                                  stroke-linejoin="round">
                                  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                                  <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
                                  <path
                                    d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
                                </svg>
                              </a>
                            </span>
                          </div>
                        </div>
                        <div class="row g-2">
                          <div class="col-auto">
                            <div class="form-label" data-translate="Settings.Main.PasswordNew"></div>
                            <div class="input-group input-group-flat">
                              <input
                                id="SettingsPasswordNEW"
                                type="password"
                                class="form-control"
                                data-translate-placeholder="Login.Placeholder.Password"
                                placeholder=""
                                autocomplete="off" />
                              <span class="input-group-text">
                                <a
                                  id="passwordToggle_new"
                                  class="link-secondary"
                                  title="Show password"
                                  data-bs-toggle="tooltip"
                                  ><!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                                  <svg
                                    xmlns="http://www.w3.org/2000/svg"
                                    class="icon"
                                    width="24"
                                    height="24"
                                    viewBox="0 0 24 24"
                                    stroke-width="2"
                                    stroke="currentColor"
                                    fill="none"
                                    stroke-linecap="round"
                                    stroke-linejoin="round">
                                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                                    <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
                                    <path
                                      d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
                                  </svg>
                                </a>
                              </span>
                            </div>
                          </div>
                        </div>
                        <div>
                          <div class="col-auto">
                            <a class="btn" data-translate="Settings.Main.Button.SetPassword" id="SettingsPasswordSubmit"></a>
                            <div id="SettingsPasswordSubmitError"></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <footer class="footer footer-transparent d-print-none">
          <div class="container-xl">
            <div class="row text-center align-items-center flex-row-reverse">
              <div class="col-lg-auto ms-lg-auto">
                <ul class="list-inline list-inline-dots mb-0">
                  <li class="list-inline-item"><a href="<%= domain %>/legal/legal#imprint" data-translate="Dashboard.Footer.Links.Imprint" class="link-secondary" rel="noopener"></a></li>
                  <li class="list-inline-item"><a href="<%= domain %>/legal/legal#privacy" data-translate="Dashboard.Footer.Links.Privacy" class="link-secondary"></a></li>
                  <li class="list-inline-item"><a href="<%= domain %>/legal/guidelines" data-translate="Dashboard.Footer.Links.Guidelines" class="link-secondary" rel="noopener"></a></li>
                </ul>
              </div>
              <div class="col-12 col-lg-auto mt-3 mt-lg-0">
                <ul class="list-inline list-inline-dots mb-0">
                  <li class="list-inline-item">
                    Copyright &copy; <%= new Date().getFullYear() %>
                    <a href="https://ebg.pw" class="link-secondary">EBG</a>.
                    All rights reserved.
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </footer>
      </div>
    </div>
    <div class="modal modal-blur fade" id="modal-danger-delete-avatar" tabindex="-1" role="dialog" aria-hidden="true">
      <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
        <div class="modal-content">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          <div class="modal-status bg-danger"></div>
          <div class="modal-body text-center py-4">
            <!-- Download SVG icon from http://tabler-icons.io/i/alert-triangle -->
            <svg xmlns="http://www.w3.org/2000/svg" class="icon mb-2 text-danger icon-lg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z" /><path d="M12 9v4" /><path d="M12 17h.01" /></svg>
            <h3>Are you sure?</h3>
            <div class="text-muted">Do you really want to remove your avatar? What you've done cannot be undone.</div>
          </div>
          <div class="modal-footer">
            <div class="w-100">
              <div class="row">
                <div class="col"><a href="#" class="btn w-100" data-bs-dismiss="modal">
                    Cancel
                  </a></div>
                <div class="col"><a href="#" class="btn btn-danger w-100" data-bs-dismiss="modal">
                    Delete
                  </a></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Libs JS -->
    <!-- Tabler Core -->
    <script src="<%= domain %>/appjs/permission.js"></script>
    <script src="<%= domain %>/appjs/translate.js"></script>
    <script src="<%= domain %>/dist/js/tabler.min.js?1684106062" defer></script>
    <script src="<%= domain %>/dist/js/demo.min.js?1684106062" defer></script>
    <script src="<%= domain %>/dist/js/i18next.min.js?1684106062"></script>
    <script src="<%= domain %>/appjs/layout.js"></script>
    <script>
      // When passwordToggle is clicked, toggle the type of password field (id login_password) (VanillaJS)
      document.getElementById("passwordToggle_old").addEventListener("click", function() {
        const passwordField = document.getElementById("SettingsPasswordOLD");
        if (passwordField.type === "password") {
          passwordField.type = "text";
        } else {
          passwordField.type = "password";
        }
      });

      document.getElementById("passwordToggle_old_r").addEventListener("click", function() {
        const passwordField = document.getElementById("SettingsPasswordOLD_R");
        if (passwordField.type === "password") {
          passwordField.type = "text";
        } else {
          passwordField.type = "password";
        }
      });

      document.getElementById("passwordToggle_new").addEventListener("click", function() {
        const passwordField = document.getElementById("SettingsPasswordNEW");
        if (passwordField.type === "password") {
          passwordField.type = "text";
        } else {
          passwordField.type = "password";
        }
      });

      // Handle set password (VanillaJS)
      document.getElementById("SettingsPasswordSubmit").addEventListener("click", async () => {
        const old_password = document.getElementById("SettingsPasswordOLD").value;
        const old_password_r = document.getElementById("SettingsPasswordOLD_R").value;
        const new_password = document.getElementById("SettingsPasswordNEW").value;

        if(!new_password) {
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Error.Password.Empty"));
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
          return;
        }

        if(old_password != old_password_r) {
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Error.Password.NotEqual"));
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
          return;
        }

        const response = await fetch("/api/v1/user/setpassword", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + localStorage.getItem("token")
          },
          body: JSON.stringify({
            old_password: old_password,
            new_password: new_password
          })
        });

        if(response.status == 200) {
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-success");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Success.Password"));
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-success");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
        } else if(response.status == 401 || response.status == 403 || response.status == 400) {
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Error.Password.Wrong"));
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
        } else if(response.status == 409) { 
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Error.Password.NoPassword"));
          document.getElementById("SettingsPasswordSubmitError").innerHTML = i18next.t("Settings.Main.ExplainNoPassword");
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
        } else {
          document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
          updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Error.Password.Unknown"));
          setTimeout(function() {
            document.getElementById("SettingsPasswordSubmit").classList.toggle("btn-danger");
            updateElementText(document.getElementById("SettingsPasswordSubmit"), i18next.t("Settings.Main.Button.SetPassword"));
          }, 3000);
        }
      });

      // Handle changes to all imput fields (VanillaJS)

      const apiEndpoints = {
        "SettingsUsername": {
          "endpoint": "/api/v1/user/username",
          "method": "POST",
          "field": "username",
          "value": "raw"
        },
        "SettingsEmail": {
          "endpoint": "/api/v1/user/email",
          "method": "POST",
          "field": "email",
          "value": "raw"
        },
        "SettingsFirstName": {
          "endpoint": "/api/v1/user/firstname",
          "method": "POST",
          "field": "first_name",
          "value": "raw"
        },
        "SettingsLastName": {
          "endpoint": "/api/v1/user/lastname",
          "method": "POST",
          "field": "last_name",
          "value": "raw"
        },
      };

      const handleInputChange = async (id) => {
        const inputElement = document.getElementById(id);
        let value_send;

        if(apiEndpoints[id].value == "raw") {
          value_send = inputElement.value;
        } else if(apiEndpoints[id].value == "bool") {
          value_send = inputElement.checked;
        }

        const response = await fetch(apiEndpoints[id].endpoint, {
          method: apiEndpoints[id].method,
          headers: {
            "Content-Type": "application/json",

            "Authorization": "Bearer " + localStorage.getItem("token")
          },
          body: JSON.stringify({
            [apiEndpoints[id].field]: value_send
          })
        });

        if (response.ok) {
          inputElement.classList.remove("is-invalid");
          inputElement.classList.add("is-valid");

          setTimeout(() => {
            inputElement.classList.remove("is-valid");
          }, 3000);
        } else {
          inputElement.classList.add("is-invalid");
        }
      }

      // Auto-fill user data (VanillaJS)
      document.addEventListener("DOMContentLoaded", async () => {
        const response = await fetch("/api/v1/user", {
          method: "GET",
          headers: {
            "Content-Type": "application/json",

            "Authorization": "Bearer " + localStorage.getItem("token")
          }
        });

        if(response.status == 200) {
          const data = await response.json();

          document.getElementById("SettingsUsername").value = data.username;
          document.getElementById("SettingsEmail").value = data.email;
          document.getElementById("SettingsFirstName").value = data.first_name;
          document.getElementById("SettingsLastName").value = data.last_name;
          document.getElementById("SettingsBio").value = data.bio;
          document.getElementById("SettingsPrivacy").checked = !data.public;
        }
      });
    </script>
  </body>
</html>