Fix: Correction des types TypeScript et validation du build production
Corrections apportées: 1. **Utilisation correcte des services exportés** - Remplacement de apiService.X par les services nommés (chantierService, clientService, etc.) - Alignement avec l'architecture d'export du fichier services/api.ts 2. **Correction des types d'interface** - Utilisation des types officiels depuis @/types/btp - Chantier: suppression des propriétés custom, utilisation du type standard - Client: ajout des imports Chantier et Facture - Materiel: adaptation aux propriétés réelles (numeroSerie au lieu de reference) - PlanningEvent: remplacement de TacheChantier par PlanningEvent 3. **Correction des propriétés obsolètes** - Chantier: dateFin → dateFinPrevue, budget → montantPrevu, responsable → typeChantier - Client: typeClient → entreprise, suppression de chantiers/factures inexistants - Materiel: reference → numeroSerie, prixAchat → valeurAchat - PlanningEvent: nom → titre, suppression de progression 4. **Correction des enums** - StatutFacture: EN_ATTENTE → ENVOYEE/BROUILLON/PARTIELLEMENT_PAYEE - PrioritePlanningEvent: MOYENNE → CRITIQUE/HAUTE/NORMALE/BASSE 5. **Fix async/await pour cookies()** - Ajout de await pour cookies() dans les routes API (Next.js 15 requirement) - app/api/auth/logout/route.ts - app/api/auth/token/route.ts - app/api/auth/userinfo/route.ts 6. **Fix useSearchParams() Suspense** - Enveloppement de useSearchParams() dans un Suspense boundary - Création d'un composant LoginContent séparé - Ajout d'un fallback avec spinner Résultat: ✅ Build production réussi: 126 pages générées ✅ Compilation TypeScript sans erreurs ✅ Linting validé ✅ Middleware 34.4 kB ✅ First Load JS shared: 651 kB 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,37 +10,8 @@ import { Divider } from 'primereact/divider';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import { apiService } from '@/services/api';
|
||||
|
||||
interface Client {
|
||||
id: number;
|
||||
nom: string;
|
||||
email: string;
|
||||
telephone: string;
|
||||
adresse: string;
|
||||
ville: string;
|
||||
codePostal: string;
|
||||
typeClient: string;
|
||||
dateCreation: string;
|
||||
chantiers: Chantier[];
|
||||
factures: Facture[];
|
||||
}
|
||||
|
||||
interface Chantier {
|
||||
id: number;
|
||||
nom: string;
|
||||
statut: string;
|
||||
dateDebut: string;
|
||||
budget: number;
|
||||
}
|
||||
|
||||
interface Facture {
|
||||
id: number;
|
||||
numero: string;
|
||||
montant: number;
|
||||
dateEmission: string;
|
||||
statut: string;
|
||||
}
|
||||
import { clientService } from '@/services/api';
|
||||
import type { Client, Chantier, Facture } from '@/types/btp';
|
||||
|
||||
export default function ClientDetailsPage() {
|
||||
const params = useParams();
|
||||
@@ -59,7 +30,7 @@ export default function ClientDetailsPage() {
|
||||
const loadClient = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await apiService.clients.getById(Number(id));
|
||||
const data = await clientService.getById(id);
|
||||
setClient(data);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement du client:', error);
|
||||
@@ -84,7 +55,8 @@ export default function ClientDetailsPage() {
|
||||
|
||||
const statutFactureTemplate = (rowData: Facture) => {
|
||||
const severity = rowData.statut === 'PAYEE' ? 'success' :
|
||||
rowData.statut === 'EN_ATTENTE' ? 'warning' : 'danger';
|
||||
rowData.statut === 'ENVOYEE' || rowData.statut === 'BROUILLON' ? 'warning' :
|
||||
rowData.statut === 'PARTIELLEMENT_PAYEE' ? 'info' : 'danger';
|
||||
return <Tag value={rowData.statut} severity={severity} />;
|
||||
};
|
||||
|
||||
@@ -106,8 +78,8 @@ export default function ClientDetailsPage() {
|
||||
/>
|
||||
<Avatar label={client.nom[0]} size="xlarge" shape="circle" className="mr-3" />
|
||||
<div>
|
||||
<h2 className="m-0">{client.nom}</h2>
|
||||
<p className="text-600 m-0">{client.typeClient}</p>
|
||||
<h2 className="m-0">{client.nom} {client.prenom}</h2>
|
||||
<p className="text-600 m-0">{client.entreprise || 'Particulier'}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
@@ -137,81 +109,24 @@ export default function ClientDetailsPage() {
|
||||
</div>
|
||||
|
||||
<div className="col-12 md:col-6">
|
||||
<h3>Statistiques</h3>
|
||||
<div className="grid">
|
||||
<div className="col-6">
|
||||
<Card className="text-center">
|
||||
<div className="text-600">Chantiers</div>
|
||||
<div className="text-2xl font-bold">{client.chantiers?.length || 0}</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="col-6">
|
||||
<Card className="text-center">
|
||||
<div className="text-600">Factures</div>
|
||||
<div className="text-2xl font-bold">{client.factures?.length || 0}</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
<h3>Informations supplémentaires</h3>
|
||||
<div className="mb-2"><strong>SIRET:</strong> {client.siret || 'N/A'}</div>
|
||||
<div className="mb-2"><strong>N° TVA:</strong> {client.numeroTVA || 'N/A'}</div>
|
||||
<div className="mb-2"><strong>Date de création:</strong> {new Date(client.dateCreation).toLocaleDateString('fr-FR')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="col-12">
|
||||
<Card>
|
||||
<TabView>
|
||||
<TabPanel header="Chantiers" leftIcon="pi pi-home mr-2">
|
||||
<DataTable value={client.chantiers || []} emptyMessage="Aucun chantier">
|
||||
<Column field="nom" header="Nom" sortable />
|
||||
<Column field="statut" header="Statut" body={statutChantierTemplate} sortable />
|
||||
<Column field="dateDebut" header="Date début" sortable />
|
||||
<Column
|
||||
field="budget"
|
||||
header="Budget"
|
||||
body={(rowData) => formatMontant(rowData.budget)}
|
||||
sortable
|
||||
/>
|
||||
<Column
|
||||
header="Actions"
|
||||
body={(rowData) => (
|
||||
<Button
|
||||
icon="pi pi-eye"
|
||||
className="p-button-text p-button-sm"
|
||||
onClick={() => router.push(`/chantiers/${rowData.id}`)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</DataTable>
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel header="Factures" leftIcon="pi pi-file mr-2">
|
||||
<DataTable value={client.factures || []} emptyMessage="Aucune facture">
|
||||
<Column field="numero" header="Numéro" sortable />
|
||||
<Column
|
||||
field="montant"
|
||||
header="Montant"
|
||||
body={(rowData) => formatMontant(rowData.montant)}
|
||||
sortable
|
||||
/>
|
||||
<Column field="dateEmission" header="Date" sortable />
|
||||
<Column field="statut" header="Statut" body={statutFactureTemplate} sortable />
|
||||
<Column
|
||||
header="Actions"
|
||||
body={(rowData) => (
|
||||
<Button
|
||||
icon="pi pi-eye"
|
||||
className="p-button-text p-button-sm"
|
||||
onClick={() => router.push(`/factures/${rowData.id}`)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</DataTable>
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel header="Documents" leftIcon="pi pi-folder mr-2">
|
||||
<p>Documents du client</p>
|
||||
</TabPanel>
|
||||
</TabView>
|
||||
<Card title="Activités">
|
||||
<p className="text-600">
|
||||
Les chantiers et factures associés à ce client seront affichés ici une fois la relation établie dans le backend.
|
||||
</p>
|
||||
<div className="flex gap-2 mt-3">
|
||||
<Button label="Voir les chantiers" icon="pi pi-home" className="p-button-outlined" onClick={() => router.push('/chantiers')} />
|
||||
<Button label="Voir les factures" icon="pi pi-file" className="p-button-outlined" onClick={() => router.push('/factures')} />
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user