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:
@@ -9,33 +9,8 @@ import { Tag } from 'primereact/tag';
|
||||
import { ProgressBar } from 'primereact/progressbar';
|
||||
import { Divider } from 'primereact/divider';
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
import { apiService } from '@/services/api';
|
||||
|
||||
interface Chantier {
|
||||
id: number;
|
||||
nom: string;
|
||||
description: string;
|
||||
adresse: string;
|
||||
ville: string;
|
||||
codePostal: string;
|
||||
dateDebut: string;
|
||||
dateFin: string;
|
||||
dateLivraison: string;
|
||||
statut: string;
|
||||
budget: number;
|
||||
client: {
|
||||
id: number;
|
||||
nom: string;
|
||||
email: string;
|
||||
telephone: string;
|
||||
};
|
||||
responsable: {
|
||||
id: number;
|
||||
nom: string;
|
||||
prenom: string;
|
||||
};
|
||||
progression: number;
|
||||
}
|
||||
import { chantierService } from '@/services/api';
|
||||
import type { Chantier } from '@/types/btp';
|
||||
|
||||
export default function ChantierDetailsPage() {
|
||||
const params = useParams();
|
||||
@@ -55,7 +30,7 @@ export default function ChantierDetailsPage() {
|
||||
const loadChantier = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await apiService.chantiers.getById(Number(id));
|
||||
const data = await chantierService.getById(id);
|
||||
setChantier(data);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement du chantier:', error);
|
||||
@@ -191,8 +166,8 @@ export default function ChantierDetailsPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex align-items-center mb-2">
|
||||
<i className="pi pi-users mr-2 text-600"></i>
|
||||
<span><strong>Responsable:</strong> {chantier.responsable?.prenom} {chantier.responsable?.nom}</span>
|
||||
<i className="pi pi-building mr-2 text-600"></i>
|
||||
<span><strong>Type:</strong> {chantier.typeChantier || 'N/A'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -200,7 +175,7 @@ export default function ChantierDetailsPage() {
|
||||
<div className="surface-100 border-round p-3">
|
||||
<div className="mb-3">
|
||||
<span className="text-600 text-sm">Progression</span>
|
||||
<ProgressBar value={chantier.progression || 0} className="mt-2" />
|
||||
<ProgressBar value={0} className="mt-2" />
|
||||
</div>
|
||||
|
||||
<div className="mb-3">
|
||||
@@ -210,12 +185,12 @@ export default function ChantierDetailsPage() {
|
||||
|
||||
<div className="mb-3">
|
||||
<span className="text-600 text-sm">Fin prévue</span>
|
||||
<div className="font-bold">{formatDate(chantier.dateFin)}</div>
|
||||
<div className="font-bold">{formatDate(chantier.dateFinPrevue || '')}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span className="text-600 text-sm">Budget</span>
|
||||
<div className="font-bold text-xl text-primary">{formatMontant(chantier.budget)}</div>
|
||||
<div className="font-bold text-xl text-primary">{formatMontant(chantier.montantPrevu || 0)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -234,7 +209,7 @@ export default function ChantierDetailsPage() {
|
||||
<i className="pi pi-calendar text-4xl text-blue-500 mb-2"></i>
|
||||
<div className="text-600 text-sm mb-1">Durée</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{Math.ceil((new Date(chantier.dateFin).getTime() - new Date(chantier.dateDebut).getTime()) / (1000 * 60 * 60 * 24))} jours
|
||||
{chantier.dateFinPrevue ? Math.ceil((new Date(chantier.dateFinPrevue).getTime() - new Date(chantier.dateDebut).getTime()) / (1000 * 60 * 60 * 24)) : 0} jours
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
@@ -243,7 +218,7 @@ export default function ChantierDetailsPage() {
|
||||
<Card className="text-center">
|
||||
<i className="pi pi-check-circle text-4xl text-green-500 mb-2"></i>
|
||||
<div className="text-600 text-sm mb-1">Avancement</div>
|
||||
<div className="text-2xl font-bold">{chantier.progression || 0}%</div>
|
||||
<div className="text-2xl font-bold">N/A</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -251,7 +226,7 @@ export default function ChantierDetailsPage() {
|
||||
<Card className="text-center">
|
||||
<i className="pi pi-euro text-4xl text-orange-500 mb-2"></i>
|
||||
<div className="text-600 text-sm mb-1">Budget</div>
|
||||
<div className="text-2xl font-bold">{formatMontant(chantier.budget)}</div>
|
||||
<div className="text-2xl font-bold">{formatMontant(chantier.montantPrevu || 0)}</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user