diff --git a/src/components/DateRangePopup.tsx b/src/components/DateRangePopup.tsx index 1b375134..6a2621ab 100644 --- a/src/components/DateRangePopup.tsx +++ b/src/components/DateRangePopup.tsx @@ -9,6 +9,7 @@ import { Modal, Select, Typography, + useStepContext, } from '@mui/material'; import React, { useState } from 'react'; import { getDayAndMonthName, getTodayDate } from '@/utils/Helper'; @@ -79,6 +80,7 @@ const DateRangePopup: React.FC = ({ const [displayCalendarToDate, setDisplayCalendarToDate] = React.useState( getDayAndMonthName(getTodayDate()) ); + const [cancelClicked, setCancelClicked] = React.useState(false) const toggleModal = () => setIsModalOpen(!isModalOpen); const toggleCalendarModal = () => @@ -91,18 +93,24 @@ const DateRangePopup: React.FC = ({ if (index === 4) { toggleCalendarModal(); } - if (index === 4) { - toggleCalendarModal(); - } }; + const handleCancelClicked = ()=>{ + toggleCalendarModal(); + setCancelClicked(true) + } const onApply = () => { - console.log('applied', selectedIndex, selectedValue); - const values = getDateRange(selectedIndex); - const { toDate, fromDate } = values; - console.log(toDate, fromDate); - onDateRangeSelected({ fromDate, toDate }); - toggleModal(); + if (cancelClicked){ + toggleModal(); + setCancelClicked(false) + }else{ + console.log('applied', selectedIndex, selectedValue); + const values = getDateRange(selectedIndex); + const { toDate, fromDate } = values; + console.log(toDate, fromDate); + onDateRangeSelected({ fromDate, toDate }); + toggleModal(); + } }; const getDateRange = (index: number | null) => { @@ -264,7 +272,7 @@ const DateRangePopup: React.FC = ({ - {/* CustomeCalendarModal */} + {/* Custom CalendarModal */} = ({ > handleCancelClicked()} style={{ cursor: 'pointer' }} /> @@ -295,7 +303,7 @@ const DateRangePopup: React.FC = ({ handleCancelClicked()} style={{ cursor: 'pointer' }} /> @@ -324,7 +332,7 @@ const DateRangePopup: React.FC = ({ justifyContent: 'end', }} > - + handleCancelClicked()}> {t('COMMON.CANCEL')}