[WEB-5454] fix: optimize date validation logic in CycleCreateUpdateModal #8394
This commit is contained in:
parent
1e3514575f
commit
f3d5e7def3
1 changed files with 13 additions and 7 deletions
|
|
@ -136,14 +136,20 @@ export function CycleCreateUpdateModal(props: CycleModalProps) {
|
||||||
|
|
||||||
if (payload.start_date && payload.end_date) {
|
if (payload.start_date && payload.end_date) {
|
||||||
if (data?.id) {
|
if (data?.id) {
|
||||||
// Update existing cycle - always include cycle_id for validation
|
// 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, {
|
isDateValid = await dateChecker(projectId, {
|
||||||
start_date: payload.start_date,
|
start_date: payload.start_date,
|
||||||
end_date: payload.end_date,
|
end_date: payload.end_date,
|
||||||
cycle_id: data.id,
|
cycle_id: data.id,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create new cycle - no cycle_id needed
|
// Create new cycle - always check dates
|
||||||
isDateValid = await dateChecker(projectId, {
|
isDateValid = await dateChecker(projectId, {
|
||||||
start_date: payload.start_date,
|
start_date: payload.start_date,
|
||||||
end_date: payload.end_date,
|
end_date: payload.end_date,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue