<script setup lang="ts">
import FormChat from "@/modules/00_support/components/FormChat.vue";
import { useSupportStore } from "@/modules/00_support/store/Main";
import { storeToRefs } from "pinia";
import { onMounted, onUnmounted, ref } from "vue";
const store = useSupportStore();
const { currentIssue } = storeToRefs(store);

onMounted(async () => {
  store.socket.connect();
  if (currentIssue.value) {
    store.socket.emit("join-issue", { issueId: currentIssue.value });
    store.socket.emit("mark-read", { issueId: currentIssue.value });
  }
});

onUnmounted(async () => {
  store.socket.disconnect();
});
</script>

<template>
  <form-chat />
</template>

<style scoped></style>
