feat: check schedule status

This commit is contained in:
karishmas6
2024-10-22 23:17:09 +05:30
parent 2a1b2ec8f4
commit 3a6f448559

View File

@@ -25,6 +25,7 @@ export interface ScheduleSettings {
} }
export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initialSettings }: ScheduleSettingsProps) => { export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initialSettings }: ScheduleSettingsProps) => {
const [schedule, setSchedule] = useState<any>(null);
const [settings, setSettings] = useState<ScheduleSettings>({ const [settings, setSettings] = useState<ScheduleSettings>({
runEvery: 1, runEvery: 1,
runEveryUnit: 'HOURS', runEveryUnit: 'HOURS',
@@ -89,11 +90,14 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
const { recordingId } = useGlobalInfoStore(); const { recordingId } = useGlobalInfoStore();
console.log(`Recoridng ID Shculde: ${recordingId}`);
const getRobotSchedule = async () => { const getRobotSchedule = async () => {
if (recordingId) { if (recordingId) {
const schedule = await getSchedule(recordingId); const schedule = await getSchedule(recordingId);
console.log(`RObot found schedule: ${schedule}`)
if (schedule) { if (schedule) {
setSettings(schedule); setSchedule(schedule);
} }
} else { } else {
console.error('No recording id provided'); console.error('No recording id provided');
@@ -104,7 +108,7 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
if (isOpen) { if (isOpen) {
getRobotSchedule(); getRobotSchedule();
} }
}, [isOpen]); }, [isOpen, getRobotSchedule]);
return ( return (
@@ -122,7 +126,20 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
}}> }}>
<Typography variant="h6" sx={{ marginBottom: '20px' }}>Schedule Settings</Typography> <Typography variant="h6" sx={{ marginBottom: '20px' }}>Schedule Settings</Typography>
<> <>
<Box sx={{ display: 'flex', alignItems: 'center', width: '100%' }}> {
(schedule != null) ? (
<Box mt={2} display="flex" justifyContent="space-between">
<Button
onClick={deleteSchedule}
variant="outlined"
color="secondary"
>
Delete Schedule
</Button>
</Box>
) : (
<>
<Box sx={{ display: 'flex', alignItems: 'center', width: '100%' }}>
<Typography sx={{ marginRight: '10px' }}>Run once every</Typography> <Typography sx={{ marginRight: '10px' }}>Run once every</Typography>
<TextField <TextField
type="number" type="number"
@@ -203,8 +220,7 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
))} ))}
</Dropdown> </Dropdown>
</Box> </Box>
</> <Box mt={2} display="flex" justifyContent="flex-end">
<Box mt={2} display="flex" justifyContent="flex-end">
<Button onClick={() => handleStart(settings)} variant="contained" color="primary"> <Button onClick={() => handleStart(settings)} variant="contained" color="primary">
Save Schedule Save Schedule
</Button> </Button>
@@ -212,16 +228,10 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
Cancel Cancel
</Button> </Button>
</Box> </Box>
</>
<Box mt={2} display="flex" justifyContent="space-between"> )
<Button }
onClick={deleteSchedule} </>
variant="outlined"
color="secondary"
>
Delete Schedule
</Button>
</Box>
</Box> </Box>
</GenericModal> </GenericModal>
); );