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

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

const chatStore = useChatStore();

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

