diff --git a/nuxt.config.ts b/nuxt.config.ts index f91f43a..7c38360 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -14,9 +14,10 @@ export default defineNuxtConfig({ redisUrl: process.env.REDIS_URL || 'redis://127.0.0.1:6379', resendApiKey: process.env.RESEND_API_KEY, emailJules: process.env.EMAIL_JULES || 'jules@trans-former.fr', - codevTableId: '', // NUXT_CODEV_TABLE_ID - codevPassword: 'merci', // NUXT_CODEV_PASSWORD - défaut "merci", overridable - codevBaseId: '', // NUXT_CODEV_BASE_ID - base NocoDB (ex: pipilvsi7dibo80) + codevTableId: '', // NUXT_CODEV_TABLE_ID + codevPassword: 'merci', // NUXT_CODEV_PASSWORD - défaut "merci", overridable + codevBaseId: '', // NUXT_CODEV_BASE_ID - base NocoDB (ex: pipilvsi7dibo80) + codevAdminPassword: 'admin2026', // NUXT_CODEV_ADMIN_PASSWORD }, // Leaflet ne fonctionne pas en SSR — forcer le rendu côté client diff --git a/pages/codev/carto.vue b/pages/codev/carto.vue index 3529ddf..4b1bb02 100644 --- a/pages/codev/carto.vue +++ b/pages/codev/carto.vue @@ -61,15 +61,6 @@ Alliance besoins partages - + @@ -145,7 +140,7 @@ import { computeMatches } from '~/utils/codev/matching' useHead({ title: 'Carto - Co-developpement' }) -const { data, pending } = await useFetch<{ list: CodevFiche[] }>('/api/codev/fiches') +const { data, pending, refresh } = await useFetch<{ list: CodevFiche[] }>('/api/codev/fiches') const fiches = computed(() => data.value?.list ?? []) const matches = ref([]) @@ -155,6 +150,15 @@ const tab = ref<'carto' | 'annuaire'>('carto') const selectedFiche = ref(null) const isMobileView = typeof window !== 'undefined' ? window.innerWidth < 600 : false +const isAdmin = ref(false) + +onMounted(async () => { + try { + const r = await $fetch<{ admin: boolean }>('/api/codev/me') + isAdmin.value = r.admin + } catch { isAdmin.value = false } +}) + const MODE_LABELS: Record = { solution: 'Solution', alliance: 'Alliance', @@ -177,6 +181,12 @@ function onSelectFiche(id: number) { navigateTo(`/codev/fiche?id=${id}`) } } + +async function deleteFiche(id: number) { + if (!confirm('Supprimer la fiche ?')) return + await $fetch(`/api/codev/fiches/${id}`, { method: 'DELETE' }) + await refresh() +}