feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)
This commit is contained in:
36
frontend/components/reception/reception-form.vue
Normal file
36
frontend/components/reception/reception-form.vue
Normal file
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<h1>Formulaire</h1>
|
||||
<button
|
||||
@click="validate"
|
||||
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||
>Valider
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useReceptionStore } from '~/stores/reception'
|
||||
|
||||
const receptionStore = useReceptionStore()
|
||||
const isLoading = ref<boolean>(false)
|
||||
const errorMessage = ref<string | null>(null)
|
||||
|
||||
async function validate() {
|
||||
if (!receptionStore.current) {
|
||||
errorMessage.value = 'Réception introuvable.'
|
||||
return
|
||||
}
|
||||
|
||||
isLoading.value = true
|
||||
try {
|
||||
const nextStep = receptionStore.current.currentStep + 1
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
currentStep: nextStep
|
||||
})
|
||||
} catch (error) {
|
||||
errorMessage.value = error.error ?? 'Erreur inconnue.'
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
41
frontend/components/reception/reception-weight.vue
Normal file
41
frontend/components/reception/reception-weight.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div v-if="weightData">
|
||||
<p>{{ weightData.weight }} kg</p>
|
||||
<p>DSD : {{ weightData.dsd }}</p>
|
||||
</div>
|
||||
<button
|
||||
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||
@click="getReceptionWeight"
|
||||
>Peser</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getWeight } from '~/services/reception'
|
||||
import type { WeightData } from '~/services/dto/weight-data'
|
||||
import { useReceptionStore } from '~/stores/reception'
|
||||
|
||||
const isLoading = ref(false)
|
||||
const weightData = ref<WeightData | null>(null)
|
||||
const errorMessage = ref<string | null>(null)
|
||||
const receptionStore = useReceptionStore()
|
||||
|
||||
async function getReceptionWeight() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
weightData.value = await getWeight()
|
||||
|
||||
if (receptionStore.current) {
|
||||
const nextStep = receptionStore.current.currentStep + 1
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
dsd: weightData.value?.dsd ?? null,
|
||||
weight: weightData.value?.weight ?? null,
|
||||
currentStep: nextStep
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage.value = error.error
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user