import { defineStore } from 'pinia'
import { ref } from 'vue'
import { setCache } from '@/utils'
import { applyBindInfoListApi } from '@/api'
import type { BindApplyItemType } from '@/pages/mine/interface'
import db from '@/utils/db'
export const bindApplyStore = defineStore('bindApplyStore', () => {
  const bindApplyList = ref<BindApplyItemType[]>()
  // 未处理的绑定申请列表
  const getApplyBindInfoList = async () => {
    try {
      const { data } = await applyBindInfoListApi()
      bindApplyList.value = data
      if (bindApplyList.value.length === 0) {
        db.set('applyBindMsg', false)
      } else {
        db.set('applyBindMsg', true)
      }
    } catch (err) {
      console.log(err)
    }
  }
  return {
    bindApplyList,
    getApplyBindInfoList,
  }
})
