Files
ghatreh_user/src/store/fundStore.ts
T
2026-08-03 22:36:23 +03:30

34 lines
988 B
TypeScript

import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getFundTable } from '@/api/fund'
import type { Fund } from '@/models/fund'
import type { TableOutput } from '@/models/table'
import { getProductInventory } from '@/api/products'
export const useFundUserStore = defineStore('fund', () => {
/** دارایی‌ها / موجودی محصول (صفحهٔ /fund فعلی) */
const myFunds = ref<TableOutput<Fund> | undefined>(undefined)
/** قلک‌های واقعی (مدل Fund) */
const myPiggyFunds = ref<TableOutput<Fund> | undefined>(undefined)
async function getMyFund() {
try {
myFunds.value = await getProductInventory()
return myFunds.value
} catch (e) {
console.log(e)
}
}
async function getMyPiggyFunds() {
try {
myPiggyFunds.value = await getFundTable()
return myPiggyFunds.value
} catch (e) {
console.log(e)
}
}
return { getMyFund, getMyPiggyFunds, myFunds, myPiggyFunds }
})