Files
gyoza2/src/store/core/actions.js
mcarquigny a7225eb054 Add shortId handling for QR
Add renumerate script
Add Tasks
2025-06-27 15:35:31 +02:00

44 lines
1.1 KiB
JavaScript

import { pb } from 'src/boot/pocketbase'
export async function loadAppData (store) {
return Promise.all([
pb.collection('stock').getFullList(),
pb.collection('history').getFullList(),
pb.collection('categories').getFullList()
]).then(([stock, history, categories]) => {
return store.commit('setFirebaseState', {
stock,
history,
categories
})
})
}
export function addToCollection (store, data) {
return pb.collection(data.collection).create(data.data)
}
export function removeFromCollection (store, data) {
return pb.collection(data.collection).delete(data.data.id)
}
export function updateItem (store, data) {
return pb.collection(data.collection).update(data.data.id, data.data)
}
export function deleteItem (store, data) {
return pb.collection(data.collection).delete(data.data.id)
}
export function getNextShortId (store) {
return pb.collection('stock').getFirstListItem('short_id>0', {
sort: '-short_id'
}).then(item => {
return item.short_id + 1
})
}
// export function uploadFile (store, file) {
// return Firebase.storage().ref().child(Date.now() + file.name).put(file)
// }