fix: Resolve TypeScript errors in page.tsx and phases-chantier/page.tsx

This commit is contained in:
dahoud
2025-10-15 20:01:04 +00:00
parent 763ab81da3
commit aed2ce0182
22 changed files with 152 additions and 118 deletions

View File

@@ -20,6 +20,7 @@ import { Checkbox } from 'primereact/checkbox';
import { factureService } from '../../../../../services/api';
import { formatDate, formatCurrency } from '../../../../../utils/formatters';
import type { Facture } from '../../../../../types/btp';
import { StatutFacture } from '../../../../../types/btp';
interface Relance {
id: string;
@@ -85,7 +86,7 @@ const FactureRelancePage = () => {
// Charger la facture
const factureResponse = await factureService.getById(factureId);
setFacture(factureResponse.data);
setFacture(factureResponse);
// TODO: Charger les relances et templates depuis l'API
// const relancesResponse = await factureService.getRelances(factureId);
@@ -142,8 +143,8 @@ const FactureRelancePage = () => {
setTemplates(mockTemplates);
// Pré-remplir le destinataire
if (factureResponse.data.client) {
const client = factureResponse.data.client;
if (factureResponse.client) {
const client = factureResponse.client;
setNouvelleRelance(prev => ({
...prev,
destinataire: typeof client === 'string' ? client : client.email || client.nom
@@ -309,9 +310,9 @@ const FactureRelancePage = () => {
<div>
<h2 className="text-2xl font-bold mb-2">Relances - Facture #{facture.numero}</h2>
<p className="text-600 mb-3">{facture.objet}</p>
<Tag
value={facture.statut}
severity={facture.statut === 'EN_RETARD' ? 'danger' : 'warning'}
<Tag
value={facture.statut}
severity={facture.statut === StatutFacture.ECHUE ? 'danger' : 'warning'}
/>
</div>
<div className="text-right">

View File

@@ -314,7 +314,7 @@ BTP Express`
return <Tag value="À échoir" severity="info" />;
}
let severity = 'warning';
let severity: "warning" | "danger" = 'warning';
if (rowData.joursRetard > 60) severity = 'danger';
else if (rowData.joursRetard > 30) severity = 'warning';
@@ -340,7 +340,7 @@ BTP Express`
};
const risqueBodyTemplate = (rowData: any) => {
const config = {
const config: Record<string, { color: "success" | "warning" | "danger", icon: string }> = {
'FAIBLE': { color: 'success', icon: 'pi-check-circle' },
'MOYEN': { color: 'warning', icon: 'pi-exclamation-triangle' },
'FORT': { color: 'danger', icon: 'pi-times-circle' }
@@ -360,20 +360,22 @@ BTP Express`
<ActionButtonGroup>
<ActionButton
icon="pi pi-send"
color="warning"
color="orange"
tooltip="Envoyer relance"
onClick={() => ouvrirRelance(rowData)}
disabled={rowData.joursRetard <= 0}
/>
<ActionButton
icon="pi pi-phone"
color="info"
color="blue"
tooltip="Appeler client"
onClick={() => {}}
/>
<ViewButton
tooltip="Voir historique"
onClick={() => {}}
/>
</ActionButtonGroup>
);