Worked on commands, notifications
This commit is contained in:
28
src/components/utilities/Notifications.vue
Normal file
28
src/components/utilities/Notifications.vue
Normal file
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<div class="notifications">
|
||||
<Modal v-for="notification in notifications.getNotifications" :key="notification.id" :isModalOpen="true" @modal:close="closeNotification(notification.id)">
|
||||
<template #modal-body>
|
||||
<p>{{ notification.message }}</p>
|
||||
</template>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useNotificationStore } from '@/stores/notifications'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
|
||||
const notifications = useNotificationStore();
|
||||
const socket = useSocketStore();
|
||||
|
||||
if (socket.getConnection) {
|
||||
socket.getConnection.on('notification', (data: any) => {
|
||||
notifications.addNotification(data);
|
||||
});
|
||||
}
|
||||
|
||||
function closeNotification(id: string) {
|
||||
notifications.removeNotification(id);
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user