/**
 * 文件用途：商户模块状态管理
 */

import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useMerchantStore = defineStore('merchantStore', () => {
  const currentMerchant = ref<Api.Merchant.MerchantDetail | null>(null)
  const listFilters = ref<Partial<Api.Merchant.MerchantListParams>>({})

  const setCurrentMerchant = (merchant: Api.Merchant.MerchantDetail | null) => {
    currentMerchant.value = merchant
  }

  const setListFilters = (filters: Partial<Api.Merchant.MerchantListParams>) => {
    listFilters.value = { ...listFilters.value, ...filters }
  }

  const resetListFilters = () => {
    listFilters.value = {}
  }

  return {
    currentMerchant,
    listFilters,
    setCurrentMerchant,
    setListFilters,
    resetListFilters
  }
})
