Changed Backend to Supabase
This commit is contained in:
@@ -3,10 +3,13 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
const {find,create} = useStrapi4()
|
||||
const spaces = (await find('spaces',{populate: "*"})).data
|
||||
const products = (await find('products',{populate: "*"})).data
|
||||
const movements = (await find('movements',{populate: "*"})).data
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const spaces = (await supabase.from("spaces").select()).data
|
||||
const movements = (await supabase.from("movements").select()).data
|
||||
const products = (await supabase.from("products").select()).data
|
||||
|
||||
|
||||
|
||||
const searchinput = ref("")
|
||||
const mode = ref("")
|
||||
@@ -21,10 +24,26 @@ const inventoryChangeData = ref({
|
||||
|
||||
const createMovement = async () => {
|
||||
if(mode.value === 'incoming'){
|
||||
await create('movements', inventoryChangeData.value)
|
||||
//await create('movements', inventoryChangeData.value)
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("movements")
|
||||
.insert([inventoryChangeData.value])
|
||||
.select()
|
||||
|
||||
console.log(error)
|
||||
|
||||
|
||||
} else if (mode.value === 'outgoing'){
|
||||
inventoryChangeData.value.quantity *= -1
|
||||
await create('movements', inventoryChangeData.value)
|
||||
//await create('movements', inventoryChangeData.value)
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("movements")
|
||||
.insert([inventoryChangeData.value])
|
||||
.select()
|
||||
|
||||
console.log(error)
|
||||
} else if (mode.value === 'change'){}
|
||||
|
||||
inventoryChangeData.value = {
|
||||
@@ -39,7 +58,7 @@ function checkArticle(productId) {
|
||||
return products.filter(product => product.id === Number(productId)).length > 0;
|
||||
}
|
||||
function checkSpaceId(spaceId) {
|
||||
return spaces.filter(space => space.attributes.spaceNumber === spaceId).length > 0;
|
||||
return spaces.filter(space => space.id === spaceId).length > 0;
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -75,12 +94,14 @@ function checkSpaceId(spaceId) {
|
||||
<UFormGroup
|
||||
label="Lagerplatz:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
variant="outline"
|
||||
:color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'"
|
||||
placeholder="Barcode / Suche"
|
||||
v-model="inventoryChangeData.spaceId"
|
||||
><!--.map(space => {return {id: space.id, name: space.spaceNumber}}-->
|
||||
<USelectMenu
|
||||
:options="spaces"
|
||||
searchable
|
||||
option-attribute="spaceNumber"
|
||||
:color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.spaceId"
|
||||
value-attribute="id"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user