[WEB-5454] fix: optimize date validation logic in CycleCreateUpdateModal #8394

This commit is contained in:
Jayash Tripathy 2025-12-19 15:41:21 +05:30 committed by GitHub
parent 1e3514575f
commit f3d5e7def3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,14 +136,20 @@ export function CycleCreateUpdateModal(props: CycleModalProps) {
if (payload.start_date && payload.end_date) {
if (data?.id) {
// Update existing cycle - always include cycle_id for validation
isDateValid = await dateChecker(projectId, {
start_date: payload.start_date,
end_date: payload.end_date,
cycle_id: data.id,
});
// Update existing cycle - only check dates if they've changed
const originalStartDate = renderFormattedPayloadDate(data.start_date) ?? null;
const originalEndDate = renderFormattedPayloadDate(data.end_date) ?? null;
const hasDateChanged = payload.start_date !== originalStartDate || payload.end_date !== originalEndDate;
if (hasDateChanged) {
isDateValid = await dateChecker(projectId, {
start_date: payload.start_date,
end_date: payload.end_date,
cycle_id: data.id,
});
}
} else {
// Create new cycle - no cycle_id needed
// Create new cycle - always check dates
isDateValid = await dateChecker(projectId, {
start_date: payload.start_date,
end_date: payload.end_date,