feat(transport) : onglet contacts transporteur (ERP-168)
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Successful in 3m9s
Pull Request — Quality gate / Frontend (lint + Vitest + build) (pull_request) Successful in 1m40s

This commit is contained in:
2026-06-17 09:28:03 +02:00
parent 6a69d7cd23
commit 94db73b807
7 changed files with 487 additions and 5 deletions
@@ -207,7 +207,40 @@
</div>
</template>
<!-- Contacts / Prix : contenu aux tickets suivants. -->
<!-- Onglet Contacts (ERP-168) : un bloc par contact (RG-4.08 ≥ 1 champ,
max 2 téléphones). Erreurs 422 par ligne. -->
<template #contacts>
<div class="mt-12 flex flex-col gap-6">
<CarrierContactBlock
v-for="(contact, index) in contacts"
:key="index"
:model-value="contact"
:removable="isRowRemovable(contacts, index)"
:readonly="isValidated('contacts')"
:errors="contactErrors[index]"
@update:model-value="(v) => contacts[index] = v"
@remove="askRemoveContact(index)"
/>
<div v-if="!isValidated('contacts')" class="flex justify-center gap-6">
<MalioButton
variant="secondary"
icon-name="mdi:add-bold"
icon-position="left"
:label="t('transport.carriers.form.contact.add')"
:disabled="!canAddContact"
@click="addContact"
/>
<MalioButton
variant="primary"
:label="t('transport.carriers.form.submit')"
:disabled="tabSubmitting || carrierId === null"
@click="onSubmitContacts"
/>
</div>
</div>
</template>
<!-- Prix : contenu au ticket suivant. -->
<template
v-for="key in placeholderTabs"
:key="key"
@@ -271,6 +304,7 @@ import { debounce } from '~/shared/utils/debounce'
import { extractApiErrorMessage } from '~/shared/utils/api'
import { isRowRemovable } from '~/shared/utils/collectionRow'
import CarrierAddressBlock from '~/modules/transport/components/CarrierAddressBlock.vue'
import CarrierContactBlock from '~/modules/transport/components/CarrierContactBlock.vue'
import { useCarrierForm } from '~/modules/transport/composables/useCarrierForm'
import { useQualimatSearch, type QualimatCarrierRow } from '~/modules/transport/composables/useQualimatSearch'
@@ -315,6 +349,12 @@ const {
addAddress,
removeAddress,
submitAddresses,
contacts,
contactErrors,
canAddContact,
addContact,
removeContact,
submitContacts,
submitMain,
applyQualimatSelection,
} = useCarrierForm()
@@ -408,8 +448,10 @@ const tabs = computed(() => tabKeys.value.map((key, index) => ({
disabled: index > unlockedIndex.value,
})))
// Onglets dont le contenu arrive aux tickets suivants (Contacts / Prix).
const placeholderTabs = computed(() => tabKeys.value.filter(key => key !== 'qualimat' && key !== 'addresses'))
// Onglets dont le contenu arrive aux tickets suivants (Prix).
const placeholderTabs = computed(() => tabKeys.value.filter(
key => key !== 'qualimat' && key !== 'addresses' && key !== 'contacts',
))
// ── Onglet Adresses (ERP-167) ────────────────────────────────────────────────
// Pays : France garantie en tete meme si /countries echoue (resilience), pour
@@ -469,7 +511,7 @@ async function onSubmitAddresses(): Promise<void> {
}
}
// Modal de confirmation de suppression (bloc adresse).
// Modal de confirmation de suppression (générique : bloc adresse OU contact).
const deleteConfirm = reactive({ open: false, action: null as null | (() => void) })
function askRemoveAddress(index: number): void {
@@ -477,6 +519,22 @@ function askRemoveAddress(index: number): void {
deleteConfirm.open = true
}
/** Valide l'onglet Contacts (POST/PATCH par ligne ; avance gérée par le composable). */
async function onSubmitContacts(): Promise<void> {
const ok = await submitContacts(error => toast.error({
title: t('transport.carriers.toast.error'),
message: apiErrorMessage(error),
}))
if (ok) {
toast.success({ title: t('transport.carriers.toast.contactSaved') })
}
}
function askRemoveContact(index: number): void {
deleteConfirm.action = () => { void removeContact(index) }
deleteConfirm.open = true
}
function runDeleteConfirm(): void {
deleteConfirm.action?.()
deleteConfirm.action = null