From 9fb0fc12b84d08bc8a59a4a290fc5bc6c9745ae7 Mon Sep 17 00:00:00 2001 From: AUTIN Tristan Date: Mon, 12 Jan 2026 16:21:17 +0000 Subject: [PATCH] Ajout de conf front (Nuxt, useApi, tailwind) (!2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/2 Reviewed-by: THOLOT DECHENE Matthieu Co-authored-by: AUTIN Tristan Co-committed-by: AUTIN Tristan --- .idea/ferme.iml | 2 + .idea/php.xml | 2 + .idea/workspace.xml | 287 ++++++++++++++++++++++++++++++++- frontend/app.vue | 4 +- frontend/composables/useApi.ts | 44 +++++ frontend/layouts/default.vue | 38 +++++ frontend/nuxt.config.ts | 5 + frontend/tailwind.config.ts | 22 +++ 8 files changed, 402 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..186e395 --- /dev/null +++ b/frontend/composables/useApi.ts @@ -0,0 +1,44 @@ +import type { FetchOptions } from 'ofetch' +import { $fetch, FetchError } from 'ofetch' + +export type AnyObject = Record + +export type ApiClient = { + get(url: string, query?: AnyObject, options?: FetchOptions<'json'>): Promise + post(url: string, body?: AnyObject, options?: FetchOptions<'json'>): Promise + put(url: string, body?: AnyObject, options?: FetchOptions<'json'>): Promise + patch(url: string, body?: AnyObject, options?: FetchOptions<'json'>): Promise + delete(url: string, query?: AnyObject, options?: FetchOptions<'json'>): Promise +} + +export const useApi = (): ApiClient => { + const config = useRuntimeConfig() + const baseURL = config.public.apiBase ?? '/api' + const client = $fetch.create({ baseURL }) + + const request = ( + method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', + url: string, + options: FetchOptions<'json'> = {} + ) => { + return client(url, { ...options, method }) + } + + return { + get(url: string, query: AnyObject = {}, options: FetchOptions<'json'> = {}) { + return request('GET', url, { ...options, query }) + }, + post(url: string, body: AnyObject = {}, options: FetchOptions<'json'> = {}) { + return request('POST', url, { ...options, body }) + }, + put(url: string, body: AnyObject = {}, options: FetchOptions<'json'> = {}) { + return request('PUT', url, { ...options, body }) + }, + patch(url: string, body: AnyObject = {}, options: FetchOptions<'json'> = {}) { + return request('PATCH', url, { ...options, body }) + }, + delete(url: string, query: AnyObject = {}, options: FetchOptions<'json'> = {}) { + return request('DELETE', url, { ...options, query }) + } + } +} 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' + } + } + } + } +}