avant codex
This commit is contained in:
5
frontend/src/api/lunar.js
Normal file
5
frontend/src/api/lunar.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import client from './client';
|
||||
export const lunarApi = {
|
||||
getMonth: (month) => client.get('/api/lunar', { params: { month } }).then(r => r.data),
|
||||
getDictons: (mois) => client.get('/api/dictons', { params: { mois } }).then(r => r.data),
|
||||
};
|
||||
27
frontend/src/api/lunar.ts
Normal file
27
frontend/src/api/lunar.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import client from './client'
|
||||
|
||||
export interface LunarDay {
|
||||
date: string
|
||||
phase: string
|
||||
illumination: number
|
||||
croissante_decroissante: string
|
||||
montante_descendante: string
|
||||
signe: string
|
||||
type_jour: string
|
||||
perigee: boolean
|
||||
apogee: boolean
|
||||
noeud_lunaire: boolean
|
||||
}
|
||||
|
||||
export interface Dicton {
|
||||
id: number
|
||||
mois: number
|
||||
jour?: number
|
||||
texte: string
|
||||
region?: string
|
||||
}
|
||||
|
||||
export const lunarApi = {
|
||||
getMonth: (month: string) => client.get<LunarDay[]>('/api/lunar', { params: { month } }).then(r => r.data),
|
||||
getDictons: (mois: number) => client.get<Dicton[]>('/api/dictons', { params: { mois } }).then(r => r.data),
|
||||
}
|
||||
4
frontend/src/api/meteo.js
Normal file
4
frontend/src/api/meteo.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import client from './client';
|
||||
export const meteoApi = {
|
||||
getForecast: (days = 14) => client.get('/api/meteo', { params: { days } }).then(r => r.data),
|
||||
};
|
||||
16
frontend/src/api/meteo.ts
Normal file
16
frontend/src/api/meteo.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import client from './client'
|
||||
|
||||
export interface MeteoDay {
|
||||
date: string
|
||||
t_max?: number
|
||||
t_min?: number
|
||||
pluie_mm: number
|
||||
vent_kmh: number
|
||||
code: number
|
||||
label: string
|
||||
icone: string
|
||||
}
|
||||
|
||||
export const meteoApi = {
|
||||
getForecast: (days = 14) => client.get<{ days: MeteoDay[] }>('/api/meteo', { params: { days } }).then(r => r.data),
|
||||
}
|
||||
8
frontend/src/api/plants.js
Normal file
8
frontend/src/api/plants.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import client from './client';
|
||||
export const plantsApi = {
|
||||
list: (categorie) => client.get('/api/plants', { params: categorie ? { categorie } : {} }).then(r => r.data),
|
||||
get: (id) => client.get(`/api/plants/${id}`).then(r => r.data),
|
||||
create: (p) => client.post('/api/plants', p).then(r => r.data),
|
||||
update: (id, p) => client.put(`/api/plants/${id}`, p).then(r => r.data),
|
||||
delete: (id) => client.delete(`/api/plants/${id}`),
|
||||
};
|
||||
33
frontend/src/api/plants.ts
Normal file
33
frontend/src/api/plants.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import client from './client'
|
||||
|
||||
export interface Plant {
|
||||
id?: number
|
||||
nom_commun: string
|
||||
nom_botanique?: string
|
||||
variete?: string
|
||||
famille?: string
|
||||
categorie?: string // potager|fleur|arbre|arbuste
|
||||
tags?: string
|
||||
type_plante?: string
|
||||
besoin_eau?: string
|
||||
besoin_soleil?: string
|
||||
espacement_cm?: number
|
||||
temp_min_c?: number
|
||||
hauteur_cm?: number
|
||||
plantation_mois?: string
|
||||
recolte_mois?: string
|
||||
semis_interieur_mois?: string
|
||||
semis_exterieur_mois?: string
|
||||
maladies_courantes?: string
|
||||
astuces_culture?: string
|
||||
url_reference?: string
|
||||
notes?: string
|
||||
}
|
||||
|
||||
export const plantsApi = {
|
||||
list: (categorie?: string) => client.get<Plant[]>('/api/plants', { params: categorie ? { categorie } : {} }).then(r => r.data),
|
||||
get: (id: number) => client.get<Plant>(`/api/plants/${id}`).then(r => r.data),
|
||||
create: (p: Partial<Plant>) => client.post<Plant>('/api/plants', p).then(r => r.data),
|
||||
update: (id: number, p: Partial<Plant>) => client.put<Plant>(`/api/plants/${id}`, p).then(r => r.data),
|
||||
delete: (id: number) => client.delete(`/api/plants/${id}`),
|
||||
}
|
||||
6
frontend/src/api/recoltes.js
Normal file
6
frontend/src/api/recoltes.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import client from './client';
|
||||
export const recoltesApi = {
|
||||
list: (plantingId) => client.get(`/api/plantings/${plantingId}/recoltes`).then(r => r.data),
|
||||
create: (plantingId, data) => client.post(`/api/plantings/${plantingId}/recoltes`, data).then(r => r.data),
|
||||
delete: (id) => client.delete(`/api/recoltes/${id}`),
|
||||
};
|
||||
21
frontend/src/api/recoltes.ts
Normal file
21
frontend/src/api/recoltes.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import client from './client'
|
||||
|
||||
export interface Recolte {
|
||||
id?: number
|
||||
plantation_id?: number
|
||||
quantite: number
|
||||
unite: string // kg|g|unites|litres|bottes
|
||||
date_recolte: string
|
||||
notes?: string
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
export const recoltesApi = {
|
||||
list: (plantingId: number) =>
|
||||
client.get<Recolte[]>(`/api/plantings/${plantingId}/recoltes`).then(r => r.data),
|
||||
|
||||
create: (plantingId: number, data: Omit<Recolte, 'id' | 'plantation_id' | 'created_at'>) =>
|
||||
client.post<Recolte>(`/api/plantings/${plantingId}/recoltes`, data).then(r => r.data),
|
||||
|
||||
delete: (id: number) => client.delete(`/api/recoltes/${id}`),
|
||||
}
|
||||
8
frontend/src/api/tools.js
Normal file
8
frontend/src/api/tools.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import client from './client';
|
||||
export const toolsApi = {
|
||||
list: () => client.get('/api/tools').then(r => r.data),
|
||||
get: (id) => client.get(`/api/tools/${id}`).then(r => r.data),
|
||||
create: (t) => client.post('/api/tools', t).then(r => r.data),
|
||||
update: (id, t) => client.put(`/api/tools/${id}`, t).then(r => r.data),
|
||||
delete: (id) => client.delete(`/api/tools/${id}`),
|
||||
};
|
||||
17
frontend/src/api/tools.ts
Normal file
17
frontend/src/api/tools.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import client from './client'
|
||||
|
||||
export interface Tool {
|
||||
id?: number
|
||||
nom: string
|
||||
description?: string
|
||||
categorie?: string
|
||||
photo_url?: string
|
||||
}
|
||||
|
||||
export const toolsApi = {
|
||||
list: () => client.get<Tool[]>('/api/tools').then(r => r.data),
|
||||
get: (id: number) => client.get<Tool>(`/api/tools/${id}`).then(r => r.data),
|
||||
create: (t: Partial<Tool>) => client.post<Tool>('/api/tools', t).then(r => r.data),
|
||||
update: (id: number, t: Partial<Tool>) => client.put<Tool>(`/api/tools/${id}`, t).then(r => r.data),
|
||||
delete: (id: number) => client.delete(`/api/tools/${id}`),
|
||||
}
|
||||
Reference in New Issue
Block a user