Skip to content

Commit 3cfdd64

Browse files
committed
Set last submit date if selected date unavailable
1 parent 9abddf4 commit 3cfdd64

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/modules/Dashboard/features/RespondentData/RespondentDataReview/RespondentDataReview.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,15 @@ const RespondentDataReviewInner = () => {
271271
}
272272

273273
const selectedDate = parseDateToMidnightLocal(selectedDateParam);
274-
if (
275-
prevSelectedDateRef.current !== selectedDateParam &&
276-
responseDates.some((date) => date.getTime() === selectedDate.getTime())
277-
) {
278-
handleSetInitialDate(selectedDate);
274+
if (prevSelectedDateRef.current !== selectedDateParam) {
275+
// Set last submit date if selected date is unavailable
276+
const hasSelectedDate = responseDates.some(
277+
(date) => date.getTime() === selectedDate.getTime(),
278+
);
279+
280+
handleSetInitialDate(
281+
hasSelectedDate ? selectedDate : responseDates[responseDates.length - 1],
282+
);
279283
}
280284
}, [responseDates, selectedDateParam, handleSetInitialDate]);
281285

0 commit comments

Comments
 (0)