import { defineStore } from 'pinia' interface Commune { id: number name: string slug: string description: string is_active: boolean } interface TariffParams { abop: number abos: number recettes: number pmax: number vmax: number } export const useCommuneStore = defineStore('commune', { state: () => ({ communes: [] as Commune[], current: null as Commune | null, params: null as TariffParams | null, loading: false, }), actions: { async fetchCommunes() { this.loading = true try { const api = useApi() this.communes = await api.get('/communes/') } finally { this.loading = false } }, async fetchCommune(slug: string) { const api = useApi() this.current = await api.get(`/communes/${slug}`) }, async fetchParams(slug: string) { const api = useApi() this.params = await api.get(`/communes/${slug}/params`) }, }, })