diff --git a/src/components/molecules/ScheduleSettings.tsx b/src/components/molecules/ScheduleSettings.tsx index 4630920e..77ae73d7 100644 --- a/src/components/molecules/ScheduleSettings.tsx +++ b/src/components/molecules/ScheduleSettings.tsx @@ -25,7 +25,7 @@ export interface ScheduleSettings { } export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initialSettings }: ScheduleSettingsProps) => { - const [schedule, setSchedule] = useState(null); + const [schedule, setSchedule] = useState(null); const [settings, setSettings] = useState({ runEvery: 1, runEveryUnit: 'HOURS', @@ -101,11 +101,9 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia const getRobotSchedule = async () => { if (recordingId) { - const schedule = await getSchedule(recordingId); - console.log(`RObot found schedule: ${schedule}`) - if (schedule) { - setSchedule(schedule); - } + const scheduleData = await getSchedule(recordingId); + console.log(`Robot found schedule: ${JSON.stringify(scheduleData, null, 2)}`); + setSchedule(scheduleData); } else { console.error('No recording id provided'); } @@ -113,10 +111,12 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia useEffect(() => { if (isOpen) { - getRobotSchedule(); + const fetchSchedule = async () => { + await getRobotSchedule(); + }; + fetchSchedule(); } - }, [isOpen, getRobotSchedule]); - + }, [isOpen]); return ( Schedule Settings <> { - (schedule != null) ? ( + (schedule !== null) ? ( <> Robot is scheduled to run every {schedule.runEvery} {schedule.runEveryUnit} starting from {schedule.startFrom} at {schedule.atTimeStart} to {schedule.atTimeEnd} in {schedule.timezone} timezone.