<template>
  <header class="bg-white shadow h-16 flex items-center justify-between px-6 z-10 relative">
    <div class="flex items-center">
      <img :src="logo" alt="PrimeCare247" class="h-10 w-auto mr-4" />
      <h1 class="text-xl font-semibold text-gray-800 space-x-2">
        <span v-if="authStore.isWorker">Worker Portal</span>
        <span v-else-if="authStore.isClient">Client Portal</span>
        <span v-else-if="authStore.isAdmin">Admin Portal</span>
        <span v-else>HomeCare247</span>
      </h1>
    </div>

    <div class="flex items-center space-x-4">
      <span class="text-gray-700 font-medium">{{ authStore.user?.name }}</span>
      <button @click="handleLogout" class="text-gray-500 hover:text-red-600 font-medium transition-colors">
        Logout
      </button>
    </div>
  </header>
</template>

<script setup>
import { useAuthStore } from '../stores/auth';
import { useRouter } from 'vue-router';
import logo from '../assets/logo.png'; // Make sure this path corresponds to your actual logo location

const authStore = useAuthStore();
const router = useRouter();

const handleLogout = async () => {
  await authStore.logout();
  router.push({ name: 'login' });
};
</script>
