From a368ea2cd05d00f285db6bccca4660465463bc9c Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 22 Oct 2024 18:25:32 +0530 Subject: [PATCH] feat: modify to handle minutes --- src/components/molecules/ScheduleSettings.tsx | 77 ++++++++++++------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/src/components/molecules/ScheduleSettings.tsx b/src/components/molecules/ScheduleSettings.tsx index ef300a91..04c93f82 100644 --- a/src/components/molecules/ScheduleSettings.tsx +++ b/src/components/molecules/ScheduleSettings.tsx @@ -16,7 +16,8 @@ export interface ScheduleSettings { runEvery: number; runEveryUnit: string; startFrom: string; - atTime: string; + atTimeStart?: string; // Start time for "In Between" + atTimeEnd?: string; // End time for "In Between" timezone: string; } @@ -25,7 +26,8 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose }: Sche runEvery: 1, runEveryUnit: 'HOURS', startFrom: 'MONDAY', - atTime: '00:00', + atTimeStart: '00:00', + atTimeEnd: '01:00', // Default end time timezone: 'UTC' }); @@ -33,8 +35,6 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose }: Sche setSettings(prev => ({ ...prev, [field]: value })); }; - console.log(`Settings:`, settings); - const textStyle = { width: '150px', height: '52px', @@ -49,11 +49,12 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose }: Sche }; const units = [ + 'MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS' - ] + ]; const days = [ 'MONDAY', @@ -63,7 +64,7 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose }: Sche 'FRIDAY', 'SATURDAY', 'SUNDAY' - ] + ]; return ( - - - At around + {/* Conditional rendering based on the selected runEveryUnit */} + {['MINUTES', 'HOURS'].includes(settings.runEveryUnit) ? ( + + + In Between + handleChange('atTimeStart', e.target.value)} + sx={textStyle} + /> + handleChange('atTimeEnd', e.target.value)} + sx={textStyle} + /> + + + ) : ( + + At Around handleChange('atTime', e.target.value)} + value={settings.atTimeStart} + onChange={(e) => handleChange('atTimeStart', e.target.value)} sx={textStyle} /> - - Timezone - handleChange('timezone', e.target.value)} - sx={dropDownStyle} - > - {validMomentTimezones.map((tz) => ( - {tz} - ))} - - + )} + + + Timezone + handleChange('timezone', e.target.value)} + sx={dropDownStyle} + > + {validMomentTimezones.map((tz) => ( + {tz} + ))} + ); -} - -export default ScheduleSettingsModal; \ No newline at end of file +};