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:
@@ -2,7 +2,7 @@ import type { Address, AddressWrite } from './dto/address'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useAddressService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { CommercialReport, CommercialReportWrite } from './dto/commercial-r
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useCommercialReportService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Contact, ContactWrite } from './dto/contact'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useContactService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -9,6 +9,7 @@ export type Address = {
|
||||
country: string
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
export type AddressWrite = {
|
||||
@@ -20,4 +21,5 @@ export type AddressWrite = {
|
||||
country: string
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ export type Client = {
|
||||
name: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
}
|
||||
|
||||
export type ClientWrite = {
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export type CommercialReport = {
|
||||
author?: { id: number, username: string } | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
documents?: ReportDocument[]
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
@@ -24,4 +25,5 @@ export type CommercialReportWrite = {
|
||||
type: ReportType
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ export type Contact = {
|
||||
phoneSecondary: string | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
export type ContactWrite = {
|
||||
@@ -20,4 +21,5 @@ export type ContactWrite = {
|
||||
phoneSecondary: string | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export type Prestataire = {
|
||||
id: number
|
||||
'@id'?: string
|
||||
name: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
}
|
||||
|
||||
export type PrestataireWrite = {
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
}
|
||||
@@ -5,10 +5,10 @@ export type ProspectStatus = 'new' | 'contacted' | 'qualified' | 'won' | 'lost'
|
||||
export type Prospect = {
|
||||
id: number
|
||||
'@id'?: string
|
||||
name: string
|
||||
company: string | null
|
||||
company: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
status: ProspectStatus
|
||||
source: string | null
|
||||
notes: string | null
|
||||
@@ -18,10 +18,10 @@ export type Prospect = {
|
||||
}
|
||||
|
||||
export type ProspectWrite = {
|
||||
name: string
|
||||
company?: string | null
|
||||
company: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
status?: ProspectStatus
|
||||
source?: string | null
|
||||
notes?: string | null
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { Prestataire, PrestataireWrite } from './dto/prestataire'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
export function usePrestataireService() {
|
||||
const api = useApi()
|
||||
|
||||
async function getAll(): Promise<Prestataire[]> {
|
||||
const data = await api.get<HydraCollection<Prestataire>>('/prestataires')
|
||||
return extractHydraMembers(data)
|
||||
}
|
||||
|
||||
async function getById(id: number): Promise<Prestataire> {
|
||||
return api.get<Prestataire>(`/prestataires/${id}`)
|
||||
}
|
||||
|
||||
async function create(payload: PrestataireWrite): Promise<Prestataire> {
|
||||
return api.post<Prestataire>('/prestataires', payload as Record<string, unknown>, {
|
||||
toastSuccessKey: 'prestataires.created',
|
||||
})
|
||||
}
|
||||
|
||||
async function update(id: number, payload: Partial<PrestataireWrite>): Promise<Prestataire> {
|
||||
return api.patch<Prestataire>(`/prestataires/${id}`, payload as Record<string, unknown>, {
|
||||
toastSuccessKey: 'prestataires.updated',
|
||||
})
|
||||
}
|
||||
|
||||
async function remove(id: number): Promise<void> {
|
||||
await api.delete(`/prestataires/${id}`, {}, {
|
||||
toastSuccessKey: 'prestataires.deleted',
|
||||
})
|
||||
}
|
||||
|
||||
return { getAll, getById, create, update, remove }
|
||||
}
|
||||
Reference in New Issue
Block a user