From 889e8d6a090b94293b7cfaf23f1e6d10b33066e9 Mon Sep 17 00:00:00 2001 From: AUTIN Tristan Date: Mon, 12 Jan 2026 11:58:46 +0100 Subject: [PATCH] =?UTF-8?q?feat=20:=20Ajout=20d'un=20layout=20default.vue?= =?UTF-8?q?=20+=20Ajout=20de=20la=20couleur=20primary=20dans=20la=20conf?= =?UTF-8?q?=20tailwind.config.ts=20+Ajout=20d'un=20composable=20pour=20g?= =?UTF-8?q?=C3=A9rer=20les=20appels=20API=20(GET,=20POST)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/ferme.iml | 2 + .idea/php.xml | 2 + .idea/workspace.xml | 287 ++++++++++++++++++++++++++++++++- frontend/app.vue | 4 +- frontend/composables/useApi.ts | 42 +++++ frontend/layouts/default.vue | 38 +++++ frontend/nuxt.config.ts | 5 + frontend/tailwind.config.ts | 22 +++ 8 files changed, 400 insertions(+), 2 deletions(-) create mode 100644 frontend/composables/useApi.ts create mode 100644 frontend/layouts/default.vue create mode 100644 frontend/tailwind.config.ts diff --git a/.idea/ferme.iml b/.idea/ferme.iml index 63cff5a..0e3bfb4 100644 --- a/.idea/ferme.iml +++ b/.idea/ferme.iml @@ -137,6 +137,8 @@ + + diff --git a/.idea/php.xml b/.idea/php.xml index 216185d..322587f 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -143,6 +143,8 @@ + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1af07c1..5e62f92 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,6 +1,291 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $PROJECT_DIR$/composer.json + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "customColor": "", + "associatedIndex": 5 +} + + + + + + + + + + + + + + + + + + + 1767956826164 + + + + + + + + + + + + + file://$PROJECT_DIR$/src/State/ReceptionWeighingProvider.php + 28 + + + + \ No newline at end of file diff --git a/frontend/app.vue b/frontend/app.vue index 4a62f0f..f8eacfa 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -1,3 +1,5 @@ diff --git a/frontend/composables/useApi.ts b/frontend/composables/useApi.ts new file mode 100644 index 0000000..a9abd61 --- /dev/null +++ b/frontend/composables/useApi.ts @@ -0,0 +1,42 @@ +import type { FetchOptions } from 'ofetch' +import { $fetch, FetchError } from 'ofetch' + +export type ApiClient = { + get(path: string, options?: FetchOptions<'json'>): Promise + post(path: string, body?: unknown, options?: FetchOptions<'json'>): Promise +} + +export const useApi = (): ApiClient => { + const config = useRuntimeConfig() + const baseURL = config.public.apiBase ?? '/api' + const client = $fetch.create({ baseURL }) + + return { + get(path: string, options?: FetchOptions<'json'>) { + return client(path, { ...options, method: 'GET' }) + }, + post(path: string, body?: unknown, options?: FetchOptions<'json'>) { + return client(path, { ...options, method: 'POST', body }) + } + } +} + +export const getApiStatus = (error: unknown): number | null => { + if (error && typeof error === 'object') { + if (error instanceof FetchError) { + return error.status ?? error.response?.status ?? null + } + + const maybeResponse = (error as { response?: { status?: number } }).response + if (typeof maybeResponse?.status === 'number') { + return maybeResponse.status + } + + const maybeStatus = (error as { status?: number }).status + if (typeof maybeStatus === 'number') { + return maybeStatus + } + } + + return null +} diff --git a/frontend/layouts/default.vue b/frontend/layouts/default.vue new file mode 100644 index 0000000..2b33892 --- /dev/null +++ b/frontend/layouts/default.vue @@ -0,0 +1,38 @@ + diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index a8e3e7a..4fc53d1 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -3,6 +3,11 @@ export default defineNuxtConfig({ devtools: { enabled: true }, ssr: false, modules: ['@nuxtjs/tailwindcss'], + runtimeConfig: { + public: { + apiBase: process.env.NUXT_PUBLIC_API_BASE + } + }, typescript: { strict: true } diff --git a/frontend/tailwind.config.ts b/frontend/tailwind.config.ts new file mode 100644 index 0000000..c5beb37 --- /dev/null +++ b/frontend/tailwind.config.ts @@ -0,0 +1,22 @@ +import type { Config } from 'tailwindcss' + +export default >{ + theme: { + extend: { + colors: { + primary: { + 50: '#f6f9ea', + 100: '#eaf2cf', + 200: '#d6e3a4', + 300: '#c1d47a', + 400: '#afc85a', + 500: '#9ebb43', + 600: '#7e9735', + 700: '#607228', + 800: '#414d1a', + 900: '#24290d' + } + } + } + } +}