{% set dashboard = viewParams.defaultDashboard %}
{% set welcomeSplashImageUrl = config.welcomeSplashImageUrl ?? hubleto.env().assetsUrl ~ "/images/logo-hubleto-text-horizontal.png" %}

<div class="w-full flex gap-2">
  <div class="grow bg-slate-50 dark:bg-slate-800 p-2 mb-2 flex flex-col md:flex-row gap-2 rounded">
    {% if user.DEFAULT_COMPANY.logo != '' %}
      <div class="flex items-center">
        <img
          src="{{ config.uploadUrl }}/{{ user.DEFAULT_COMPANY.logo }}"
          class="max-h-32 max-w-32 m-8"
        />
      </div>
    {% endif %}
    <div class="m-8 dark:text-white">
      <h1 class="pt-0 m-0 pb-4">
        {{ translate('Welcome') }}, {{ user.first_name ?? user.email }}
      </h1>
      <div class="flex">
        {% if user.photo %}
          <div class="mr-8">
            <img
              src="{{ config.uploadUrl }}/{{ user.photo }}"
              class='max-w-48 max-h-24 rounded-4xl'
            />
          </div>
        {% endif %}
        <div>
          <div>
            <b>{{ user.first_name }} {{ user.last_name }}</b>
            <a href="settings/my-account" class="btn btn-transparent">
              <span class="icon"><i class="fas fa-pencil"></i></span>
            </a>
          </div>
          <div><b>{{ user.DEFAULT_COMPANY.name }}</b></div>
          {% if user.position %} <div class="badge">{{ user.position }}</div> {% endif %}
          <div class="mt-2">{{ user.email }}</div>
        </div>
      </div>
    </div>
  </div>

  {% if hubleto.appManager().isAppInstalled('Hubleto\\App\\Community\\Usage') %}
    {% set recentlyUsed = hubleto.getService('Hubleto\\App\\Community\\Usage\\Logger').getRecentlyUsedAppNamespaces() %}
    {% if recentlyUsed|length > 0 %}
      <div class="mb-2 hidden m:block dark:text-gray-200">
        <div><small>{{ translate('Recently used apps') }}</small></div>
        <div class="list">
          {% for appNamespace in recentlyUsed %}
            {% set manifest = hubleto.appManager().getApp(appNamespace).manifest %}
            <a href="{{ manifest.rootUrlSlug }}" class="btn btn-list-item btn-transparent">
              <span class="icon"><i class="{{ manifest.icon }}"></i></span>
              <span class="text">{{ manifest.nameTranslated }}</span>
            </a>
          {% endfor %}
        </div>
      </div>
    {% endif %}
  {% endif %}
</div>

<div class="mt-2">
  <h1 style="color: {{ dashboard.color }}">{{ dashboard.title }}</h1>
  <hblreact-dashboards-dashboard
    int:id-dashboard='{{ dashboard.id }}'
    string:redirect-url='{{ config.projectUrl }}'
    json:panels='{{ dashboard.PANELS|json_encode|raw }}'
    bool:show-add-new-panel-button='true'
  ></hblreact-dashboards-dashboard>
</div>

<div class="mx-auto pt-20">
  <img src="{{ welcomeSplashImageUrl }}" class="max-w-90 m-auto">
</div>
