import React, { useState, useEffect } from 'react'; import { Check } from 'lucide-react'; import Popup from '@/components/Popup'; const DateTab = ({ dates, activeTab, handleDateChange, handleEdit, type, paymentPlanId, resetModifiedDates }) => { const [popupVisible, setPopupVisible] = useState(false); const [popupMessage, setPopupMessage] = useState(""); const [modifiedDates, setModifiedDates] = useState({}); useEffect(() => { if (resetModifiedDates) { setModifiedDates({}); } }, [resetModifiedDates]); const submit = (updatedData) => { const dataWithType = { ...updatedData, type: type }; handleEdit(paymentPlanId, dataWithType) .then(() => { setPopupMessage(`Mise à jour de la date d'échéance effectuée avec succès`); setPopupVisible(true); setModifiedDates({}); }) .catch(error => { console.error(error); }); }; const handleDateChangeWithModification = (tab, index, value) => { handleDateChange(tab, index, value); setModifiedDates(prev => ({ ...prev, [`${tab}-${index}`]: true })); }; return (