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:
@@ -11,31 +11,15 @@ import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { Chart } from 'primereact/chart';
|
||||
import { TabView, TabPanel } from 'primereact/tabview';
|
||||
import { apiService } from '@/services/api';
|
||||
|
||||
interface TacheChantier {
|
||||
id: number;
|
||||
nom: string;
|
||||
description: string;
|
||||
dateDebut: string;
|
||||
dateFin: string;
|
||||
statut: string;
|
||||
responsable: {
|
||||
nom: string;
|
||||
prenom: string;
|
||||
};
|
||||
equipe: {
|
||||
nom: string;
|
||||
};
|
||||
progression: number;
|
||||
}
|
||||
import { planningService } from '@/services/api';
|
||||
import type { PlanningEvent } from '@/types/btp';
|
||||
|
||||
export default function ChantierPlanningPage() {
|
||||
const params = useParams();
|
||||
const router = useRouter();
|
||||
const id = params.id as string;
|
||||
|
||||
const [taches, setTaches] = useState<TacheChantier[]>([]);
|
||||
const [taches, setTaches] = useState<PlanningEvent[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
|
||||
const [viewMode, setViewMode] = useState<'timeline' | 'gantt'>('timeline');
|
||||
@@ -49,7 +33,8 @@ export default function ChantierPlanningPage() {
|
||||
const loadPlanning = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await apiService.planning.getByChantier(Number(id));
|
||||
// Récupérer les événements de planning pour ce chantier
|
||||
const data = await planningService.getEvents({ chantierId: id });
|
||||
setTaches(data || []);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement du planning:', error);
|
||||
@@ -90,7 +75,7 @@ export default function ChantierPlanningPage() {
|
||||
return labels[statut] || statut;
|
||||
};
|
||||
|
||||
const statutBodyTemplate = (rowData: TacheChantier) => {
|
||||
const statutBodyTemplate = (rowData: PlanningEvent) => {
|
||||
return (
|
||||
<Tag
|
||||
value={getStatutLabel(rowData.statut)}
|
||||
@@ -99,7 +84,7 @@ export default function ChantierPlanningPage() {
|
||||
);
|
||||
};
|
||||
|
||||
const dateBodyTemplate = (rowData: TacheChantier) => {
|
||||
const dateBodyTemplate = (rowData: PlanningEvent) => {
|
||||
return (
|
||||
<div>
|
||||
<div><strong>Début:</strong> {formatDate(rowData.dateDebut)}</div>
|
||||
@@ -108,31 +93,16 @@ export default function ChantierPlanningPage() {
|
||||
);
|
||||
};
|
||||
|
||||
const responsableBodyTemplate = (rowData: TacheChantier) => {
|
||||
return `${rowData.responsable?.prenom} ${rowData.responsable?.nom}`;
|
||||
};
|
||||
|
||||
const equipeBodyTemplate = (rowData: TacheChantier) => {
|
||||
const equipeBodyTemplate = (rowData: PlanningEvent) => {
|
||||
return rowData.equipe?.nom || 'Non assignée';
|
||||
};
|
||||
|
||||
const progressionBodyTemplate = (rowData: TacheChantier) => {
|
||||
return (
|
||||
<div className="flex align-items-center">
|
||||
<div className="flex-1 mr-2">
|
||||
<div className="surface-300 border-round" style={{ height: '8px' }}>
|
||||
<div
|
||||
className="bg-primary border-round"
|
||||
style={{ height: '8px', width: `${rowData.progression}%` }}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<span>{rowData.progression}%</span>
|
||||
</div>
|
||||
);
|
||||
const prioriteBodyTemplate = (rowData: PlanningEvent) => {
|
||||
const severity = rowData.priorite === 'CRITIQUE' ? 'danger' : rowData.priorite === 'HAUTE' ? 'warning' : rowData.priorite === 'NORMALE' ? 'info' : 'success';
|
||||
return <Tag value={rowData.priorite} severity={severity} />;
|
||||
};
|
||||
|
||||
const actionsBodyTemplate = (rowData: TacheChantier) => {
|
||||
const actionsBodyTemplate = (rowData: PlanningEvent) => {
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
@@ -154,7 +124,7 @@ export default function ChantierPlanningPage() {
|
||||
);
|
||||
};
|
||||
|
||||
const customizedMarker = (item: TacheChantier) => {
|
||||
const customizedMarker = (item: PlanningEvent) => {
|
||||
return (
|
||||
<span
|
||||
className="flex w-2rem h-2rem align-items-center justify-content-center text-white border-circle z-1 shadow-1"
|
||||
@@ -165,17 +135,17 @@ export default function ChantierPlanningPage() {
|
||||
);
|
||||
};
|
||||
|
||||
const customizedContent = (item: TacheChantier) => {
|
||||
const customizedContent = (item: PlanningEvent) => {
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex justify-content-between align-items-center mb-2">
|
||||
<span className="font-bold">{item.nom}</span>
|
||||
<span className="font-bold">{item.titre}</span>
|
||||
<Tag value={getStatutLabel(item.statut)} severity={getStatutSeverity(item.statut)} />
|
||||
</div>
|
||||
<p className="text-600 mb-2">{item.description}</p>
|
||||
<div className="text-sm">
|
||||
<div><strong>Responsable:</strong> {item.responsable?.prenom} {item.responsable?.nom}</div>
|
||||
<div><strong>Équipe:</strong> {item.equipe?.nom || 'Non assignée'}</div>
|
||||
<div><strong>Priorité:</strong> {item.priorite}</div>
|
||||
<div><strong>Dates:</strong> {formatDate(item.dateDebut)} - {formatDate(item.dateFin)}</div>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -193,7 +163,7 @@ export default function ChantierPlanningPage() {
|
||||
const duree = Math.ceil((fin - debut) / (1000 * 60 * 60 * 24));
|
||||
|
||||
return {
|
||||
label: tache.nom,
|
||||
label: tache.titre,
|
||||
duree: duree,
|
||||
statut: tache.statut
|
||||
};
|
||||
@@ -346,12 +316,11 @@ export default function ChantierPlanningPage() {
|
||||
sortField="dateDebut"
|
||||
sortOrder={1}
|
||||
>
|
||||
<Column field="nom" header="Tâche" sortable filter />
|
||||
<Column field="titre" header="Tâche" sortable filter />
|
||||
<Column field="statut" header="Statut" body={statutBodyTemplate} sortable filter />
|
||||
<Column header="Dates" body={dateBodyTemplate} sortable />
|
||||
<Column header="Responsable" body={responsableBodyTemplate} sortable filter />
|
||||
<Column header="Priorité" body={prioriteBodyTemplate} sortable filter />
|
||||
<Column header="Équipe" body={equipeBodyTemplate} sortable filter />
|
||||
<Column header="Progression" body={progressionBodyTemplate} sortable />
|
||||
<Column header="Actions" body={actionsBodyTemplate} />
|
||||
</DataTable>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user