Files
ghatreh_user/src/store/fundStore.ts
T

34 lines
988 B
TypeScript
Raw Normal View History

2026-08-03 11:52:44 +03:30
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'
2025-10-05 09:44:14 +03:30
import { getProductInventory } from '@/api/products'
2026-08-03 11:52:44 +03:30
2025-10-05 09:44:14 +03:30
export const useFundUserStore = defineStore('fund', () => {
2026-08-03 22:36:23 +03:30
/** دارایی‌ها / موجودی محصول (صفحهٔ /fund فعلی) */
2025-10-05 09:44:14 +03:30
const myFunds = ref<TableOutput<Fund> | undefined>(undefined)
2026-08-03 22:36:23 +03:30
/** قلک‌های واقعی (مدل Fund) */
2026-08-03 11:52:44 +03:30
const myPiggyFunds = ref<TableOutput<Fund> | undefined>(undefined)
2025-10-05 09:44:14 +03:30
async function getMyFund() {
try {
2026-08-03 11:52:44 +03:30
myFunds.value = await getProductInventory()
2025-10-05 09:44:14 +03:30
return myFunds.value
} catch (e) {
console.log(e)
}
}
2026-08-03 11:52:44 +03:30
async function getMyPiggyFunds() {
try {
myPiggyFunds.value = await getFundTable()
return myPiggyFunds.value
} catch (e) {
console.log(e)
}
2025-10-05 09:44:14 +03:30
}
2026-08-03 11:52:44 +03:30
return { getMyFund, getMyPiggyFunds, myFunds, myPiggyFunds }
2025-10-05 09:44:14 +03:30
})