<template>
  <div class="inbox-list">
    <h2 class="panel-title">{{ $t('menu_inbox') }}</h2>
    
    <div v-if="chatStore.inboxResults.length === 0" class="panel-empty">
      <p>Keine ungelesenen Nachrichten.</p>
    </div>
    
    <div
      v-for="item in chatStore.inboxResults"
      :key="item.userName"
      class="inbox-item"
      @click="selectUser(item.userName)"
    >
      <span class="panel-item-name">{{ item.userName }}</span>
      <span class="panel-item-meta">{{ item.unreadCount }} ungelesen</span>
    </div>
  </div>
</template>

<script setup>
import { useChatStore } from '../stores/chat';

const chatStore = useChatStore();

function selectUser(userName) {
  chatStore.requestConversation(userName);
}
</script>

<style scoped>
.panel-title {
  margin-bottom: 14px;
  font-size: 18px;
  color: #18201b;
}

.panel-empty {
  color: #637067;
}

.inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 10px;
}

.panel-item-name {
  font-weight: 600;
  color: #18201b;
}

.panel-item-meta {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: #536159;
}
</style>
