import {defineStore} from "pinia";

export const useGlobalTabs = defineStore("globalTabs",{
    state:()=>({
        tab: "",
        tabs: []
    }),
    actions:{
        addTab(tab){
            let index = this.tabs.findIndex(item => item.name === tab.name)
            console.log("addTab", tab, index)
            if( index === -1 ){
                this.tabs.push(tab)
            } else {
                this.tabs[index] = Object.assign(this.tabs[index],tab)
            }
        }
    }
})
