Merge remote-tracking branch 'origin/master'
This commit is contained in:
34
ui/src/stores/OrderProductionItemStore.js
Normal file
34
ui/src/stores/OrderProductionItemStore.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// src/stores/OrderProductionItemStore.js
|
||||
import { defineStore } from 'pinia'
|
||||
import api from 'src/services/api'
|
||||
|
||||
export const useOrderProductionItemStore = defineStore('orderproductionitems', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
loading: false,
|
||||
error: null
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchItems (orderHeaderID) {
|
||||
if (!orderHeaderID) {
|
||||
this.items = []
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
this.error = null
|
||||
|
||||
try {
|
||||
const res = await api.get(`/orders/production-items/${encodeURIComponent(orderHeaderID)}`)
|
||||
const data = res?.data
|
||||
this.items = Array.isArray(data) ? data : []
|
||||
} catch (err) {
|
||||
this.items = []
|
||||
this.error = err?.response?.data || err?.message || 'Liste alınamadı'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user