// @ts-ignore
import {defineStore} from 'pinia'
// @ts-ignore
import {useCookie} from '#app'

export const useNotificationsStore = defineStore('notifications', {
    state: () => ({
        status: false,
        notifications: []
    }),
    actions: {
        async init() {
            // @ts-ignore
            if(!this.status) {
               await this.check_notifications()
            }
        },
        async check_notifications () {
            const {$api} = useNuxtApp();

            // @ts-ignore
            await $api.post('/user/notification', {}).then((value: { data: { data: null; }; }) => {
                // @ts-ignore
                this.notifications = value.data.data;
            })
        }
    },
})
