feat: get schedule of robot

This commit is contained in:
karishmas6
2024-10-22 21:15:05 +05:30
parent ef6fa8d212
commit 1bd7b2fd47

View File

@@ -5,6 +5,8 @@ import { Dropdown } from "../atoms/DropdownMui";
import Button from "@mui/material/Button";
import { modalStyle } from "./AddWhereCondModal";
import { validMomentTimezones } from '../../constants/const';
import { useGlobalInfoStore } from '../../context/globalInfo';
import { getSchedule } from '../../api/storage';
interface ScheduleSettingsProps {
isOpen: boolean;
@@ -85,6 +87,26 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
});
};
const { recordingId } = useGlobalInfoStore();
const getRobotSchedule = async () => {
if (recordingId) {
const schedule = await getSchedule(recordingId);
if (schedule) {
setSettings(schedule);
}
} else {
console.error('No recording id provided');
}
}
useEffect(() => {
if (isOpen) {
getRobotSchedule();
}
}, [isOpen]);
return (
<GenericModal
isOpen={isOpen}
@@ -182,6 +204,14 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
</Dropdown>
</Box>
</>
<Box mt={2} display="flex" justifyContent="flex-end">
<Button onClick={() => handleStart(settings)} variant="contained" color="primary">
Save Schedule
</Button>
<Button onClick={handleClose} color="primary" variant="outlined" style={{ marginLeft: '10px' }}>
Cancel
</Button>
</Box>
<Box mt={2} display="flex" justifyContent="space-between">
<Button
@@ -192,15 +222,6 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
Delete Schedule
</Button>
</Box>
<Box mt={2} display="flex" justifyContent="flex-end">
<Button onClick={() => handleStart(settings)} variant="contained" color="primary">
Save Schedule
</Button>
<Button onClick={handleClose} color="primary" variant="outlined" style={{ marginLeft: '10px' }}>
Cancel
</Button>
</Box>
</Box>
</GenericModal>
);