fix: Update PrimeReact to v10.8.3 and fix all compilation errors
This commit is contained in:
@@ -18,6 +18,7 @@ import { Checkbox } from 'primereact/checkbox';
|
||||
import { factureService, clientService } from '../../../../../services/api';
|
||||
import { formatCurrency } from '../../../../../utils/formatters';
|
||||
import type { Facture, Client } from '../../../../../types/btp';
|
||||
import { StatutFacture, TypeFacture } from '../../../../../types/btp';
|
||||
|
||||
const FactureDuplicatePage = () => {
|
||||
const params = useParams();
|
||||
@@ -29,10 +30,10 @@ const FactureDuplicatePage = () => {
|
||||
numero: '',
|
||||
objet: '',
|
||||
description: '',
|
||||
type: 'FACTURE',
|
||||
statut: 'BROUILLON',
|
||||
dateEmission: new Date(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // +30 jours
|
||||
typeFacture: TypeFacture.FACTURE,
|
||||
statut: StatutFacture.BROUILLON,
|
||||
dateEmission: new Date().toISOString(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // +30 jours
|
||||
tauxTVA: 20,
|
||||
lignes: []
|
||||
});
|
||||
@@ -68,15 +69,16 @@ const FactureDuplicatePage = () => {
|
||||
|
||||
// Charger la facture originale
|
||||
const factureResponse = await factureService.getById(factureId);
|
||||
setOriginalFacture(factureResponse.data);
|
||||
|
||||
setOriginalFacture(factureResponse);
|
||||
|
||||
// Charger les clients
|
||||
const clientsResponse = await clientService.getAll();
|
||||
setClients(clientsResponse.data);
|
||||
|
||||
// Générer un nouveau numéro
|
||||
const numeroResponse = await factureService.generateNumero();
|
||||
setNewFacture(prev => ({ ...prev, numero: numeroResponse.data.numero }));
|
||||
setClients(clientsResponse);
|
||||
|
||||
// Générer un nouveau numéro basé sur la date
|
||||
const now = new Date();
|
||||
const numero = `FAC-${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}-${String(Math.floor(Math.random() * 10000)).padStart(4, '0')}`;
|
||||
setNewFacture(prev => ({ ...prev, numero }));
|
||||
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement:', error);
|
||||
@@ -92,12 +94,12 @@ const FactureDuplicatePage = () => {
|
||||
|
||||
const updateNewFacture = () => {
|
||||
if (!originalFacture) return;
|
||||
|
||||
|
||||
setNewFacture(prev => ({
|
||||
...prev,
|
||||
objet: `${originalFacture.objet} (Copie)`,
|
||||
description: originalFacture.description,
|
||||
type: originalFacture.type,
|
||||
typeFacture: originalFacture.typeFacture,
|
||||
tauxTVA: originalFacture.tauxTVA,
|
||||
client: copyClient ? originalFacture.client : undefined,
|
||||
lignes: copyLignes ? [...(originalFacture.lignes || [])] : [],
|
||||
@@ -241,7 +243,7 @@ const FactureDuplicatePage = () => {
|
||||
<strong>Objet:</strong> {originalFacture.objet}
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<strong>Type:</strong> {originalFacture.type}
|
||||
<strong>Type:</strong> {originalFacture.typeFacture}
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<strong>Client:</strong> {typeof originalFacture.client === 'string' ? originalFacture.client : originalFacture.client?.nom}
|
||||
@@ -293,9 +295,9 @@ const FactureDuplicatePage = () => {
|
||||
<label htmlFor="type" className="font-semibold">Type *</label>
|
||||
<Dropdown
|
||||
id="type"
|
||||
value={newFacture.type}
|
||||
value={newFacture.typeFacture}
|
||||
options={typeOptions}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, type: e.value }))}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, typeFacture: e.value }))}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
@@ -321,8 +323,8 @@ const FactureDuplicatePage = () => {
|
||||
<label htmlFor="dateEmission" className="font-semibold">Date d'émission *</label>
|
||||
<Calendar
|
||||
id="dateEmission"
|
||||
value={newFacture.dateEmission}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, dateEmission: e.value || new Date() }))}
|
||||
value={newFacture.dateEmission ? new Date(newFacture.dateEmission) : null}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, dateEmission: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
@@ -334,8 +336,8 @@ const FactureDuplicatePage = () => {
|
||||
<label htmlFor="dateEcheance" className="font-semibold">Date d'échéance *</label>
|
||||
<Calendar
|
||||
id="dateEcheance"
|
||||
value={newFacture.dateEcheance}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, dateEcheance: e.value || new Date() }))}
|
||||
value={newFacture.dateEcheance ? new Date(newFacture.dateEcheance) : null}
|
||||
onChange={(e) => setNewFacture(prev => ({ ...prev, dateEcheance: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
|
||||
@@ -19,6 +19,7 @@ import { Divider } from 'primereact/divider';
|
||||
import { factureService, clientService } from '../../../../../services/api';
|
||||
import { formatCurrency } from '../../../../../utils/formatters';
|
||||
import type { Facture, LigneFacture, Client } from '../../../../../types/btp';
|
||||
import { StatutFacture, TypeFacture } from '../../../../../types/btp';
|
||||
|
||||
const FactureEditPage = () => {
|
||||
const params = useParams();
|
||||
@@ -29,10 +30,10 @@ const FactureEditPage = () => {
|
||||
numero: '',
|
||||
objet: '',
|
||||
description: '',
|
||||
type: 'FACTURE',
|
||||
statut: 'BROUILLON',
|
||||
dateEmission: new Date(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // +30 jours
|
||||
typeFacture: TypeFacture.FACTURE,
|
||||
statut: StatutFacture.BROUILLON,
|
||||
dateEmission: new Date().toISOString(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // +30 jours
|
||||
tauxTVA: 20,
|
||||
lignes: []
|
||||
});
|
||||
@@ -49,7 +50,7 @@ const FactureEditPage = () => {
|
||||
quantite: 1,
|
||||
unite: 'unité',
|
||||
prixUnitaire: 0,
|
||||
montantHT: 0
|
||||
montantLigne: 0
|
||||
});
|
||||
|
||||
const factureId = params.id as string;
|
||||
@@ -96,16 +97,17 @@ const FactureEditPage = () => {
|
||||
|
||||
// Charger les clients
|
||||
const clientsResponse = await clientService.getAll();
|
||||
setClients(clientsResponse.data);
|
||||
|
||||
setClients(clientsResponse);
|
||||
|
||||
if (!isNew) {
|
||||
// Charger la facture existante
|
||||
const factureResponse = await factureService.getById(factureId);
|
||||
setFacture(factureResponse.data);
|
||||
setFacture(factureResponse);
|
||||
} else {
|
||||
// Générer un nouveau numéro
|
||||
const numeroResponse = await factureService.generateNumero();
|
||||
setFacture(prev => ({ ...prev, numero: numeroResponse.data.numero }));
|
||||
// Générer un nouveau numéro basé sur la date
|
||||
const now = new Date();
|
||||
const numero = `FAC-${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}-${String(Math.floor(Math.random() * 10000)).padStart(4, '0')}`;
|
||||
setFacture(prev => ({ ...prev, numero }));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@@ -122,11 +124,11 @@ const FactureEditPage = () => {
|
||||
|
||||
const calculateMontants = () => {
|
||||
if (!facture.lignes) return;
|
||||
|
||||
const montantHT = facture.lignes.reduce((total, ligne) => total + (ligne.montantHT || 0), 0);
|
||||
|
||||
const montantHT = facture.lignes.reduce((total, ligne) => total + (ligne.montantLigne || 0), 0);
|
||||
const montantTVA = montantHT * (facture.tauxTVA || 0) / 100;
|
||||
const montantTTC = montantHT + montantTVA;
|
||||
|
||||
|
||||
setFacture(prev => ({
|
||||
...prev,
|
||||
montantHT,
|
||||
@@ -185,7 +187,7 @@ const FactureEditPage = () => {
|
||||
quantite: 1,
|
||||
unite: 'unité',
|
||||
prixUnitaire: 0,
|
||||
montantHT: 0
|
||||
montantLigne: 0
|
||||
});
|
||||
setShowLigneDialog(true);
|
||||
};
|
||||
@@ -296,9 +298,9 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="type" className="font-semibold">Type *</label>
|
||||
<Dropdown
|
||||
id="type"
|
||||
value={facture.type}
|
||||
value={facture.typeFacture}
|
||||
options={typeOptions}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, type: e.value }))}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, typeFacture: e.value }))}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
@@ -362,8 +364,8 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="dateEmission" className="font-semibold">Date d'émission *</label>
|
||||
<Calendar
|
||||
id="dateEmission"
|
||||
value={facture.dateEmission}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEmission: e.value || new Date() }))}
|
||||
value={facture.dateEmission ? new Date(facture.dateEmission) : null}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEmission: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
@@ -375,8 +377,8 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="dateEcheance" className="font-semibold">Date d'échéance *</label>
|
||||
<Calendar
|
||||
id="dateEcheance"
|
||||
value={facture.dateEcheance}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEcheance: e.value || new Date() }))}
|
||||
value={facture.dateEcheance ? new Date(facture.dateEcheance) : null}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEcheance: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
@@ -575,7 +577,7 @@ const FactureEditPage = () => {
|
||||
<div className="field">
|
||||
<label className="font-semibold">Montant HT</label>
|
||||
<div className="text-xl font-bold text-primary">
|
||||
{formatCurrency(ligneForm.montantHT || 0)}
|
||||
{formatCurrency(ligneForm.montantLigne || 0)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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';
|
||||
|
||||
const FactureDetailPage = () => {
|
||||
const params = useParams();
|
||||
@@ -39,7 +40,7 @@ const FactureDetailPage = () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await factureService.getById(factureId);
|
||||
setFacture(response.data);
|
||||
setFacture(response);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement de la facture:', error);
|
||||
setError('Impossible de charger la facture');
|
||||
@@ -130,7 +131,7 @@ const FactureDetailPage = () => {
|
||||
|
||||
const handleMarkAsPaid = async () => {
|
||||
try {
|
||||
await factureService.updateStatut(factureId, 'PAYEE');
|
||||
await factureService.update(factureId, { statut: StatutFacture.PAYEE });
|
||||
loadFacture();
|
||||
toast.current?.show({
|
||||
severity: 'success',
|
||||
@@ -275,13 +276,13 @@ const FactureDetailPage = () => {
|
||||
<h2 className="text-2xl font-bold mb-2">Facture #{facture.numero}</h2>
|
||||
<p className="text-600 mb-3">{facture.objet}</p>
|
||||
<div className="flex gap-2 mb-2">
|
||||
<Tag
|
||||
value={facture.statut}
|
||||
severity={getStatutSeverity(facture.statut)}
|
||||
<Tag
|
||||
value={facture.statut}
|
||||
severity={getStatutSeverity(facture.statut) as any}
|
||||
/>
|
||||
<Tag
|
||||
value={facture.type}
|
||||
severity={getTypeSeverity(facture.type)}
|
||||
<Tag
|
||||
value={facture.typeFacture}
|
||||
severity={getTypeSeverity(facture.typeFacture) as any}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -336,14 +337,14 @@ const FactureDetailPage = () => {
|
||||
<label className="font-semibold">Client:</label>
|
||||
<p>{typeof facture.client === 'string' ? facture.client : facture.client?.nom}</p>
|
||||
</div>
|
||||
{facture.devisId && (
|
||||
{facture.devis && (
|
||||
<div className="field">
|
||||
<label className="font-semibold">Devis source:</label>
|
||||
<p>
|
||||
<Button
|
||||
label={`Devis #${facture.devisId}`}
|
||||
label={`Devis #${typeof facture.devis === 'string' ? facture.devis : facture.devis?.numero}`}
|
||||
className="p-button-link p-0"
|
||||
onClick={() => router.push(`/devis/${facture.devisId}`)}
|
||||
onClick={() => router.push(`/devis/${typeof facture.devis === 'string' ? facture.devis : facture.devis?.id}`)}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user