<template>
  <div class="chat-container">
    <header class="header">
      <h1>SingleChat</h1>
    </header>
    
    <MenuBar />
    
    <div class="horizontal-box">
      <UserList />
      
      <div class="content">
        <div class="partners-view">
          <h2>Partner</h2>
          <div v-if="!chatStore.isLoggedIn" class="back-link">
            <router-link to="/">Zurück zur Hauptseite</router-link>
          </div>
          <ul class="partners-list">
            <li v-for="partner in partners" :key="partner.url">
              <a :href="partner.url" target="_blank" rel="noopener noreferrer">
                {{ partner['Page Name'] }}
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    
    <ImprintContainer />
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
import MenuBar from '../components/MenuBar.vue';
import UserList from '../components/UserList.vue';
import ImprintContainer from '../components/ImprintContainer.vue';
import { useChatStore } from '../stores/chat';

const router = useRouter();
const chatStore = useChatStore();
const partners = ref([]);

onMounted(async () => {
  try {
    const response = await axios.get('/api/partners');
    partners.value = response.data;
  } catch (error) {
    console.error('Fehler beim Laden der Partner:', error);
  }
});
</script>

