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:
@@ -1,9 +1,21 @@
|
||||
<template>
|
||||
<div class="min-h-screen flex items-center justify-center">
|
||||
<h1 class="text-3xl font-bold">Nuxt OK ✅</h1>
|
||||
<div class="">
|
||||
<h1 class="text-3xl font-bold">Liste des receptions</h1>
|
||||
<ul>
|
||||
<li v-for="reception in receptionList" :key="reception.id">
|
||||
<NuxtLink :to="`/reception/${reception.id}`">Réception numéro {{ reception.id}}</NuxtLink>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type {ReceptionData} from "~/services/dto/reception-data";
|
||||
import {getReceptionList} from "~/services/reception";
|
||||
|
||||
const receptionList = ref<ReceptionData[]>()
|
||||
|
||||
onMounted(async () => {
|
||||
receptionList.value = await getReceptionList()
|
||||
})
|
||||
</script>
|
||||
|
||||
42
frontend/pages/reception/[[id]].vue
Normal file
42
frontend/pages/reception/[[id]].vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<div v-if="errorMessage" class="text-red-600">{{ errorMessage }}</div>
|
||||
<div v-if="isLoading" class="text-neutral-600">Chargement...</div>
|
||||
<div v-else>
|
||||
<ReceptionForm v-if="storeReception?.currentStep === 0"/>
|
||||
<ReceptionWeight v-if="storeReception?.currentStep === 1"/>
|
||||
<div v-if="storeReception?.currentStep === 2">Décharger</div>
|
||||
<ReceptionWeight v-if="storeReception?.currentStep === 3"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { createReception, getReception } from '~/services/reception'
|
||||
import type { ReceptionData } from '~/services/dto/reception-data'
|
||||
import { useReceptionStore } from '~/stores/reception'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const isLoading = ref<boolean>(false)
|
||||
const errorMessage = ref<string | null>(null)
|
||||
const receptionStore = useReceptionStore()
|
||||
const { current: storeReception } = storeToRefs(receptionStore)
|
||||
|
||||
onMounted(async () => {
|
||||
isLoading.value = true
|
||||
const raw = route.params.id
|
||||
const idStr = Array.isArray(raw) ? raw[0] : raw
|
||||
const id = idStr ? Number(idStr) : null
|
||||
|
||||
try {
|
||||
const result = id === null ? await createReception() : await getReception(id)
|
||||
if (result) {
|
||||
receptionStore.setCurrent(result as ReceptionData)
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage.value = error.error ?? 'Erreur inconnue.'
|
||||
}
|
||||
isLoading.value = false
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user