fix: Resolve TypeScript errors in page.tsx and phases-chantier/page.tsx
This commit is contained in:
@@ -255,8 +255,7 @@ const FacturesPage = () => {
|
||||
|
||||
const editFacture = (facture: Facture) => {
|
||||
setFacture({
|
||||
...facture,
|
||||
client: facture.client?.id || null
|
||||
...facture
|
||||
});
|
||||
setFactureDialog(true);
|
||||
};
|
||||
@@ -390,7 +389,7 @@ const FacturesPage = () => {
|
||||
/>
|
||||
<ActionButton
|
||||
icon="pi pi-send"
|
||||
color="secondary"
|
||||
color="blue"
|
||||
tooltip="Envoyer par email"
|
||||
onClick={() => {
|
||||
toast.current?.show({
|
||||
@@ -402,10 +401,12 @@ const FacturesPage = () => {
|
||||
}}
|
||||
/>
|
||||
<EditButton
|
||||
onClick={() => editFacture(rowData)}
|
||||
tooltip="Modifier"
|
||||
onClick={() => editFacture(rowData)}
|
||||
/>
|
||||
<DeleteButton
|
||||
onClick={() => confirmDeleteFacture(rowData)}
|
||||
tooltip="Supprimer"
|
||||
onClick={() => confirmDeleteFacture(rowData)}
|
||||
/>
|
||||
</ActionButtonGroup>
|
||||
);
|
||||
@@ -456,9 +457,9 @@ const FacturesPage = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Tag
|
||||
value={getTypeLabel(rowData.type)}
|
||||
severity={rowData.type === 'AVOIR' ? 'warning' : 'info'}
|
||||
<Tag
|
||||
value={getTypeLabel(rowData.typeFacture)}
|
||||
severity={rowData.typeFacture === 'AVOIR' ? 'warning' : 'info'}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -526,6 +527,7 @@ const FacturesPage = () => {
|
||||
value={factures}
|
||||
selection={selectedFactures}
|
||||
onSelectionChange={(e) => setSelectedFactures(e.value)}
|
||||
selectionMode="checkbox"
|
||||
dataKey="id"
|
||||
paginator
|
||||
rows={10}
|
||||
@@ -575,12 +577,12 @@ const FacturesPage = () => {
|
||||
</div>
|
||||
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="type">Type</label>
|
||||
<Dropdown
|
||||
id="type"
|
||||
value={facture.type}
|
||||
options={types}
|
||||
onChange={(e) => onDropdownChange(e, 'type')}
|
||||
<label htmlFor="typeFacture">Type</label>
|
||||
<Dropdown
|
||||
id="typeFacture"
|
||||
value={facture.typeFacture}
|
||||
options={types}
|
||||
onChange={(e) => onDropdownChange(e, 'typeFacture')}
|
||||
placeholder="Sélectionnez un type"
|
||||
/>
|
||||
</div>
|
||||
@@ -636,35 +638,35 @@ const FacturesPage = () => {
|
||||
|
||||
<div className="field col-12 md:col-4">
|
||||
<label htmlFor="dateEmission">Date d'émission</label>
|
||||
<Calendar
|
||||
id="dateEmission"
|
||||
value={facture.dateEmission}
|
||||
onChange={(e) => onDateChange(e, 'dateEmission')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
<Calendar
|
||||
id="dateEmission"
|
||||
value={facture.dateEmission ? new Date(facture.dateEmission) : null}
|
||||
onChange={(e) => onDateChange(e, 'dateEmission')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="field col-12 md:col-4">
|
||||
<label htmlFor="dateEcheance">Date d'échéance</label>
|
||||
<Calendar
|
||||
id="dateEcheance"
|
||||
value={facture.dateEcheance}
|
||||
onChange={(e) => onDateChange(e, 'dateEcheance')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
minDate={facture.dateEmission}
|
||||
<Calendar
|
||||
id="dateEcheance"
|
||||
value={facture.dateEcheance ? new Date(facture.dateEcheance) : null}
|
||||
onChange={(e) => onDateChange(e, 'dateEcheance')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
minDate={facture.dateEmission ? new Date(facture.dateEmission) : undefined}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="field col-12 md:col-4">
|
||||
<label htmlFor="datePaiement">Date de paiement</label>
|
||||
<Calendar
|
||||
id="datePaiement"
|
||||
value={facture.datePaiement}
|
||||
onChange={(e) => onDateChange(e, 'datePaiement')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
<Calendar
|
||||
id="datePaiement"
|
||||
value={facture.datePaiement ? new Date(facture.datePaiement) : null}
|
||||
onChange={(e) => onDateChange(e, 'datePaiement')}
|
||||
dateFormat="dd/mm/yy"
|
||||
showIcon
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -488,6 +488,7 @@ RECOMMANDATIONS:
|
||||
value={factures}
|
||||
selection={selectedFactures}
|
||||
onSelectionChange={(e) => setSelectedFactures(e.value)}
|
||||
selectionMode="checkbox"
|
||||
dataKey="id"
|
||||
paginator
|
||||
rows={10}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ import { ProgressBar } from 'primereact/progressbar';
|
||||
import { factureService } from '../../../../services/api';
|
||||
import { formatDate, formatCurrency } from '../../../../utils/formatters';
|
||||
import type { Facture } from '../../../../types/btp';
|
||||
import { StatutFacture } from '../../../../types/btp';
|
||||
import factureActionsService from '../../../../services/factureActionsService';
|
||||
|
||||
const FacturesRetardPage = () => {
|
||||
@@ -66,12 +67,12 @@ const FacturesRetardPage = () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await factureService.getAll();
|
||||
// Filtrer les factures en retard (échéance dépassée + statut EN_RETARD)
|
||||
// Filtrer les factures en retard (échéance dépassée + statut ECHUE)
|
||||
const facturesEnRetard = data.filter(facture => {
|
||||
const today = new Date();
|
||||
const echeanceDate = new Date(facture.dateEcheance);
|
||||
return (facture.statut === 'EN_RETARD' ||
|
||||
(echeanceDate < today && facture.statut !== 'PAYEE' && !facture.datePaiement));
|
||||
return (facture.statut === StatutFacture.ECHUE ||
|
||||
(echeanceDate < today && facture.statut !== StatutFacture.PAYEE && !facture.datePaiement));
|
||||
});
|
||||
setFactures(facturesEnRetard);
|
||||
} catch (error) {
|
||||
@@ -155,11 +156,12 @@ const FacturesRetardPage = () => {
|
||||
break;
|
||||
|
||||
case 'legal_notice':
|
||||
const delaiJours = Math.ceil((legalNoticeData.deadline.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
|
||||
await factureActionsService.sendMiseEnDemeure({
|
||||
factureId: selectedFacture.id,
|
||||
delaiPaiement: legalNoticeData.delai,
|
||||
mentionsLegales: legalNoticeData.mentions,
|
||||
fraisDossier: legalNoticeData.frais
|
||||
delaiPaiement: delaiJours,
|
||||
mentionsLegales: legalNoticeData.content,
|
||||
fraisDossier: 0
|
||||
});
|
||||
message = 'Mise en demeure émise avec succès';
|
||||
break;
|
||||
@@ -535,6 +537,7 @@ ACTIONS RECOMMANDÉES:
|
||||
value={factures}
|
||||
selection={selectedFactures}
|
||||
onSelectionChange={(e) => setSelectedFactures(e.value)}
|
||||
selectionMode="checkbox"
|
||||
dataKey="id"
|
||||
paginator
|
||||
rows={10}
|
||||
|
||||
@@ -315,9 +315,9 @@ const FactureTemplatesPage = () => {
|
||||
);
|
||||
|
||||
const typeBodyTemplate = (rowData: FactureTemplate) => (
|
||||
<Tag
|
||||
value={rowData.type}
|
||||
severity={rowData.type === 'FACTURE' ? 'primary' : 'info'}
|
||||
<Tag
|
||||
value={rowData.type}
|
||||
severity={rowData.type === 'FACTURE' ? 'success' : 'info'}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user