add network
This commit is contained in:
31
src/stores/transactions-store.ts
Normal file
31
src/stores/transactions-store.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref} from "vue";
|
||||
import {Transaction} from "@/models/transaction";
|
||||
import {TransactionService} from "@/services/transactions-service";
|
||||
|
||||
const transactionsService = TransactionService
|
||||
|
||||
export const useTransactionStore = defineStore('transactions', () => {
|
||||
const transactions = ref<Transaction[]>([])
|
||||
const isLoading = ref(false)
|
||||
|
||||
const fetchTransactions = async (spaceId: number) => {
|
||||
isLoading.value = true
|
||||
try {
|
||||
transactions.value = await transactionsService.getTransactions(spaceId)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const addTransaction = (transaction: Transaction) => {
|
||||
transactions.value.push(transaction)
|
||||
}
|
||||
|
||||
return {
|
||||
transactions,
|
||||
isLoading,
|
||||
fetchTransactions,
|
||||
addTransaction
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user