feat: gérer les constructeurs multiples
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { useToast } from './useToast'
|
||||
import { useApi } from './useApi'
|
||||
import { buildConstructeurRequestPayload } from '~/shared/constructeurUtils'
|
||||
|
||||
const machines = ref([])
|
||||
const loading = ref(false)
|
||||
@@ -76,7 +77,7 @@ export function useMachines () {
|
||||
const createMachine = async (machineData) => {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await post('/machines', machineData)
|
||||
const result = await post('/machines', buildConstructeurRequestPayload(machineData))
|
||||
if (result.success) {
|
||||
const createdMachine = normalizeMachineResponse(result.data) ||
|
||||
normalizeMachineResponse(result.data?.machine) ||
|
||||
@@ -105,13 +106,13 @@ export function useMachines () {
|
||||
// Les composants et pièces seront créés automatiquement
|
||||
}
|
||||
|
||||
return await createMachine(machineWithStructure)
|
||||
return await createMachine(buildConstructeurRequestPayload(machineWithStructure))
|
||||
}
|
||||
|
||||
const updateMachineData = async (id, machineData) => {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await patch(`/machines/${id}`, machineData)
|
||||
const result = await patch(`/machines/${id}`, buildConstructeurRequestPayload(machineData))
|
||||
if (result.success) {
|
||||
const updatedMachine = normalizeMachineResponse(result.data) ||
|
||||
normalizeMachineResponse(result.data?.machine) ||
|
||||
|
||||
Reference in New Issue
Block a user