<template>
  <template v-if="userStore.initialized">
	  <template v-if="userStore.isLoggedIn()">
	    <nuxt-link class="d-flex align-items-center" href="/profile">
		      <profile-user-avatar sm />

	        <div class="tp-header-login-content-5">
		        <p :title="userStore?.user?.name" class="text-wrap">
              <span>{{ $t('Hello') }}</span>
              <br>
              {{ cutString(userStore?.user?.name, 15) }}
            </p>
	        </div>
	    </nuxt-link>
	  </template>
	  <template v-else>
		  <header-login-btn />
	  </template>
  </template>
  <template v-else>
	  <header-login-btn />
  </template>
</template>

<script lang="ts" setup>

// const {$auth} = useNuxtApp()
// const icon = computed(() => $auth.session.value?.email ? 'i-heroicons-lock-open' : 'i-heroicons-lock-closed')


import {useUserStore} from '@/pinia/useUserStore'
import {cutString} from "../../utils/cutString";

const userStore = useUserStore()
const data = ref({})

// const login = async () => {
// 	await userStore.login({
// 		username: 'admin',
// 		password: '123456'
// 	} as IUserFormValues)
// }

const logout = async () => {
  await userStore.logout()
}
</script>
