feat(directory) : type prestataire, validateurs front, autocomplete adresse BAN
- Prestataire : entité/repo + ressource API Platform (RBAC directory.providers.*), ownership prestataire sur contacts/adresses/comptes-rendus (CHECK XOR à 3), DTO/service/drawer/fiche détail + onglet dédié dans le répertoire. - Prospect : société uniquement (suppression du champ name, company requis) ; migration de backfill, conversion prospect→client et MCP adaptés. - Champ site web sur client/prospect/prestataire (entités, DTO, onglet Information, MCP). - Validateurs front email / téléphone FR (0549200910) / URL sur Information et Contacts, enregistrement bloqué tant qu'un champ est invalide. - Autocomplete adresse branché sur la Base Adresse Nationale (api-adresse.data.gouv.fr) avec mode dégradé en saisie libre. - Administration : retrait de l'onglet Clients.
This commit is contained in:
@@ -42,9 +42,10 @@ class ConvertProspectTool
|
||||
|
||||
if (null === $prospect->getConvertedClient()) {
|
||||
$client = new Client();
|
||||
$client->setName($prospect->getCompany() ?: (string) $prospect->getName());
|
||||
$client->setName((string) $prospect->getCompany());
|
||||
$client->setEmail($prospect->getEmail());
|
||||
$client->setPhone($prospect->getPhone());
|
||||
$client->setWebsite($prospect->getWebsite());
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class CreateClientTool
|
||||
string $name,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
@@ -32,6 +33,7 @@ class CreateClientTool
|
||||
$client->setName($name);
|
||||
$client->setEmail($email);
|
||||
$client->setPhone($phone);
|
||||
$client->setWebsite($website);
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'create-prospect', description: 'Create a prospect (admin). Only name is required. Status defaults to "new".')]
|
||||
#[McpTool(name: 'create-prospect', description: 'Create a prospect (admin). Only company is required. Status defaults to "new".')]
|
||||
class CreateProspectTool
|
||||
{
|
||||
public function __construct(
|
||||
@@ -24,10 +24,10 @@ class CreateProspectTool
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
string $name,
|
||||
?string $company = null,
|
||||
string $company,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
?string $status = null,
|
||||
?string $source = null,
|
||||
?string $notes = null,
|
||||
@@ -37,10 +37,10 @@ class CreateProspectTool
|
||||
}
|
||||
|
||||
$prospect = new Prospect();
|
||||
$prospect->setName($name);
|
||||
$prospect->setCompany($company);
|
||||
$prospect->setEmail($email);
|
||||
$prospect->setPhone($phone);
|
||||
$prospect->setWebsite($website);
|
||||
$prospect->setSource($source);
|
||||
$prospect->setNotes($notes);
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ class DeleteProspectTool
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$name = $prospect->getName();
|
||||
$company = $prospect->getCompany();
|
||||
$this->entityManager->remove($prospect);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('Prospect "%s" deleted.', $name)]);
|
||||
return json_encode(['success' => true, 'message' => sprintf('Prospect "%s" deleted.', $company)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ListProspectsTool
|
||||
$criteria['status'] = $statusEnum;
|
||||
}
|
||||
|
||||
$prospects = $this->prospectRepository->findBy($criteria, ['name' => 'ASC']);
|
||||
$prospects = $this->prospectRepository->findBy($criteria, ['company' => 'ASC']);
|
||||
|
||||
return json_encode(array_map(static fn ($prospect) => Serializer::prospect($prospect), $prospects));
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class UpdateClientTool
|
||||
?string $name = null,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
@@ -47,6 +48,9 @@ class UpdateClientTool
|
||||
if (null !== $phone) {
|
||||
$client->setPhone($phone);
|
||||
}
|
||||
if (null !== $website) {
|
||||
$client->setWebsite($website);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ class UpdateProspectTool
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $name = null,
|
||||
?string $company = null,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
?string $status = null,
|
||||
?string $source = null,
|
||||
?string $notes = null,
|
||||
@@ -43,9 +43,6 @@ class UpdateProspectTool
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $name) {
|
||||
$prospect->setName($name);
|
||||
}
|
||||
if (null !== $company) {
|
||||
$prospect->setCompany($company);
|
||||
}
|
||||
@@ -55,6 +52,9 @@ class UpdateProspectTool
|
||||
if (null !== $phone) {
|
||||
$prospect->setPhone($phone);
|
||||
}
|
||||
if (null !== $website) {
|
||||
$prospect->setWebsite($website);
|
||||
}
|
||||
if (null !== $status) {
|
||||
$statusEnum = ProspectStatus::tryFrom($status);
|
||||
if (null === $statusEnum) {
|
||||
|
||||
Reference in New Issue
Block a user