fix(codev): boundaries D3 + matching rebuildLinks + couleurs + bulles toggle + FAB +
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- En-tête -->
|
||||
<div class="fiche-header">
|
||||
<h1>Ma fiche</h1>
|
||||
<h1>{{ isEdit ? 'Modifier ma fiche' : 'Ma fiche' }}</h1>
|
||||
<p class="fiche-lead">3 lignes pour te présenter. Le reste se passe entre nous.</p>
|
||||
</div>
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
<!-- Bouton -->
|
||||
<button type="submit" class="submit-btn" :disabled="loading">
|
||||
{{ loading ? 'Envoi en cours...' : 'Ajouter ma fiche' }}
|
||||
{{ isEdit ? (loading ? 'Modification...' : 'Enregistrer les modifications') : (loading ? 'Envoi en cours...' : 'Ajouter ma fiche') }}
|
||||
</button>
|
||||
|
||||
</form>
|
||||
@@ -115,12 +115,29 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const route = useRoute()
|
||||
const editId = computed(() => route.query.id ? Number(route.query.id) : null)
|
||||
const isEdit = computed(() => editId.value !== null)
|
||||
|
||||
const form = ref({ nom: '', besoin: '', offre: '', hashtagsRaw: '' })
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
const activeTip = ref<'besoin' | 'offre' | null>(null)
|
||||
|
||||
useHead({ title: 'Ma fiche — Co-développement' })
|
||||
useHead({ title: computed(() => isEdit.value ? 'Modifier ma fiche — Co-développement' : 'Ma fiche — Co-développement') })
|
||||
|
||||
onMounted(async () => {
|
||||
if (!isEdit.value) return
|
||||
try {
|
||||
const fiche = await $fetch<any>(`/api/codev/fiches/${editId.value}`)
|
||||
form.value.nom = fiche.nom
|
||||
form.value.besoin = fiche.besoin
|
||||
form.value.offre = fiche.offre
|
||||
form.value.hashtagsRaw = fiche.hashtags.join(', ')
|
||||
} catch {
|
||||
error.value = 'Impossible de charger la fiche, elle a peut-etre ete supprimee.'
|
||||
}
|
||||
})
|
||||
|
||||
function toggleTip(field: 'besoin' | 'offre') {
|
||||
activeTip.value = activeTip.value === field ? null : field
|
||||
@@ -136,15 +153,18 @@ async function submit() {
|
||||
.filter(Boolean)
|
||||
.slice(0, 3)
|
||||
|
||||
await $fetch('/api/codev/fiches', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
nom: form.value.nom,
|
||||
besoin: form.value.besoin,
|
||||
offre: form.value.offre,
|
||||
hashtags,
|
||||
},
|
||||
})
|
||||
const payload = {
|
||||
nom: form.value.nom,
|
||||
besoin: form.value.besoin,
|
||||
offre: form.value.offre,
|
||||
hashtags,
|
||||
}
|
||||
|
||||
if (isEdit.value) {
|
||||
await $fetch(`/api/codev/fiches/${editId.value}`, { method: 'PATCH', body: payload })
|
||||
} else {
|
||||
await $fetch('/api/codev/fiches', { method: 'POST', body: payload })
|
||||
}
|
||||
await navigateTo('/codev/carto')
|
||||
} catch (e: any) {
|
||||
error.value = e?.data?.message || e?.statusMessage || 'Erreur, reessaie'
|
||||
|
||||
Reference in New Issue
Block a user