From b5af7f13b6f994032c6c6af9c7fb74d27c013a1d Mon Sep 17 00:00:00 2001 From: matthieu Date: Mon, 12 Jan 2026 13:03:41 +0100 Subject: [PATCH] wip(frontend) : api calls + skeleton fetch --- app/app.vue | 2 +- app/composables/useApi.js | 10 ++++++++++ app/pages/machine/[id].vue | 2 +- app/pages/type/[id].vue | 8 ++++++++ app/shared/constructeurUtils.ts | 4 +++- nuxt.config.ts | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/app.vue b/app/app.vue index e0dea99..329f5ac 100644 --- a/app/app.vue +++ b/app/app.vue @@ -30,7 +30,7 @@ : 'text-base-content hover:bg-primary/10 hover:text-primary' " > - Vue d'ensemblee + Vue d'ensemble
  • diff --git a/app/composables/useApi.js b/app/composables/useApi.js index b1a4233..14d4ec2 100644 --- a/app/composables/useApi.js +++ b/app/composables/useApi.js @@ -24,6 +24,10 @@ export function useApi () { const response = await fetch(url, { ...defaultOptions, ...options, + headers: { + ...defaultOptions.headers, + ...options.headers + }, signal: controller.signal }) @@ -70,6 +74,9 @@ export function useApi () { const post = async (endpoint, data) => { return apiCall(endpoint, { method: 'POST', + headers: { + 'Content-Type': 'application/ld+json' + }, body: JSON.stringify(data) }) } @@ -77,6 +84,9 @@ export function useApi () { const patch = async (endpoint, data) => { return apiCall(endpoint, { method: 'PATCH', + headers: { + 'Content-Type': 'application/merge-patch+json' + }, body: JSON.stringify(data) }) } diff --git a/app/pages/machine/[id].vue b/app/pages/machine/[id].vue index f1e00dd..b177531 100644 --- a/app/pages/machine/[id].vue +++ b/app/pages/machine/[id].vue @@ -3921,7 +3921,7 @@ const applyMachineLinks = (source) => { const loadMachineData = async () => { loading.value = true try { - const machineResult = await get(`/machines/${machineId}`) + const machineResult = await get(`/machines/${machineId}/skeleton`) if (!machineResult.success) { console.error('Machine non trouvée:', machineId, machineResult.error) diff --git a/app/pages/type/[id].vue b/app/pages/type/[id].vue index 5566943..cdaf9b5 100644 --- a/app/pages/type/[id].vue +++ b/app/pages/type/[id].vue @@ -187,6 +187,14 @@ onMounted(async () => { const typeId = route.params.id console.log('=== TYPE DETAIL PAGE LOADING ===') console.log('Loading type with ID:', typeId) + console.log('Full route params:', route.params) + + if (!typeId) { + console.error('No type ID provided in route') + showError('Aucun identifiant de type fourni') + loading.value = false + return + } const result = await getMachineTypeById(typeId) console.log('API Result:', result) diff --git a/app/shared/constructeurUtils.ts b/app/shared/constructeurUtils.ts index 31030d7..0ebc386 100644 --- a/app/shared/constructeurUtils.ts +++ b/app/shared/constructeurUtils.ts @@ -60,7 +60,9 @@ export const uniqueConstructeurIds = (...sources: unknown[]): string[] => { if (value.constructeur) { explore(value.constructeur); } - if (typeof value.id === 'string') { + // Only extract ID if this looks like a constructeur object (has @type or recognizable fields) + // Don't extract ID from component/piece/product objects that happen to be passed in + if (typeof value.id === 'string' && !value.name && !value.typeComposant && !value.typePiece && !value.typeProduct) { pushId(value.id); } return; diff --git a/nuxt.config.ts b/nuxt.config.ts index 964c43d..33fcb7b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,6 +1,7 @@ import tailwindcss from '@tailwindcss/vite' export default defineNuxtConfig({ compatibilityDate: '2025-07-15', + ssr: false, // Désactive le SSR pour un mode SPA pur (Client-Side Rendering uniquement) devtools: { enabled: true }, devServer: { port: 3001