import { defineStore } from 'pinia'
import { store } from '@/store'
import type { CompanyInfo, CompanyState } from './helper'
import { fetchGetCompany } from '@/api'

export const useCompanyStore = defineStore('company-store', {
    state: (): CompanyState => {
        return {
            company: {
                id: 0,
                name: '走马AI',
                assistantName: '走马AI助手'
                // logo: 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png'
            }
        }
    },

    getters: {},

    actions: {
        setCompanyInfo(company: Partial<CompanyInfo>) {
            this.company = { ...this.company, ...company }
        },
        async getCompanyInfo() {
            await fetchGetCompany().then((res: any) => {
                this.setCompanyInfo(res)
            })
        }
    }
})
