mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-06-04 13:26:11 +00:00
chore: application prettier
This commit is contained in:
@ -2,9 +2,17 @@ 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 DateTab = ({
|
||||
dates,
|
||||
activeTab,
|
||||
handleDateChange,
|
||||
handleEdit,
|
||||
type,
|
||||
paymentPlanId,
|
||||
resetModifiedDates,
|
||||
}) => {
|
||||
const [popupVisible, setPopupVisible] = useState(false);
|
||||
const [popupMessage, setPopupMessage] = useState("");
|
||||
const [popupMessage, setPopupMessage] = useState('');
|
||||
const [modifiedDates, setModifiedDates] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
@ -16,22 +24,24 @@ const DateTab = ({ dates, activeTab, handleDateChange, handleEdit, type, payment
|
||||
const submit = (updatedData) => {
|
||||
const dataWithType = {
|
||||
...updatedData,
|
||||
type: type
|
||||
type: type,
|
||||
};
|
||||
handleEdit(paymentPlanId, dataWithType)
|
||||
.then(() => {
|
||||
setPopupMessage(`Mise à jour de la date d'échéance effectuée avec succès`);
|
||||
setPopupMessage(
|
||||
`Mise à jour de la date d'échéance effectuée avec succès`
|
||||
);
|
||||
setPopupVisible(true);
|
||||
setModifiedDates({});
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
const handleDateChangeWithModification = (tab, index, value) => {
|
||||
handleDateChange(tab, index, value);
|
||||
setModifiedDates(prev => ({ ...prev, [`${tab}-${index}`]: true }));
|
||||
setModifiedDates((prev) => ({ ...prev, [`${tab}-${index}`]: true }));
|
||||
};
|
||||
|
||||
return (
|
||||
@ -39,17 +49,30 @@ const DateTab = ({ dates, activeTab, handleDateChange, handleEdit, type, payment
|
||||
<div className="flex flex-col space-y-3">
|
||||
{dates[activeTab]?.map((date, index) => (
|
||||
<div key={index} className="flex items-center space-x-3">
|
||||
<span className="text-emerald-700 font-semibold">Échéance {index + 1}</span>
|
||||
<span className="text-emerald-700 font-semibold">
|
||||
Échéance {index + 1}
|
||||
</span>
|
||||
<input
|
||||
type="date"
|
||||
value={date}
|
||||
onChange={(e) => handleDateChangeWithModification(activeTab, index, e.target.value)}
|
||||
onChange={(e) =>
|
||||
handleDateChangeWithModification(
|
||||
activeTab,
|
||||
index,
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
className="p-2 border border-emerald-300 rounded focus:outline-none focus:ring-2 focus:ring-emerald-500 cursor-pointer"
|
||||
/>
|
||||
{modifiedDates[`${activeTab}-${index}`] && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => submit({ frequency: dates[activeTab].length, due_dates: dates[activeTab] })}
|
||||
onClick={() =>
|
||||
submit({
|
||||
frequency: dates[activeTab].length,
|
||||
due_dates: dates[activeTab],
|
||||
})
|
||||
}
|
||||
className="text-emerald-500 hover:text-emerald-800"
|
||||
>
|
||||
<Check className="w-5 h-5" />
|
||||
@ -71,4 +94,4 @@ const DateTab = ({ dates, activeTab, handleDateChange, handleEdit, type, payment
|
||||
);
|
||||
};
|
||||
|
||||
export default DateTab;
|
||||
export default DateTab;
|
||||
|
||||
Reference in New Issue
Block a user