feat: delete schedule

This commit is contained in:
karishmas6
2024-10-23 00:13:29 +05:30
parent 0ae1fe8d3b
commit e0c014e98a

View File

@@ -6,7 +6,7 @@ import Button from "@mui/material/Button";
import { modalStyle } from "./AddWhereCondModal"; import { modalStyle } from "./AddWhereCondModal";
import { validMomentTimezones } from '../../constants/const'; import { validMomentTimezones } from '../../constants/const';
import { useGlobalInfoStore } from '../../context/globalInfo'; import { useGlobalInfoStore } from '../../context/globalInfo';
import { getSchedule } from '../../api/storage'; import { getSchedule, deleteSchedule } from '../../api/storage';
interface ScheduleSettingsProps { interface ScheduleSettingsProps {
isOpen: boolean; isOpen: boolean;
@@ -77,7 +77,18 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
'SUNDAY' 'SUNDAY'
]; ];
const deleteSchedule = () => { const { recordingId } = useGlobalInfoStore();
console.log(`Recoridng ID Shculde: ${recordingId}`);
const deleteRobotSchedule = () => {
if (recordingId) {
deleteSchedule(recordingId);
setSchedule(null);
} else {
console.error('No recording id provided');
}
setSettings({ setSettings({
runEvery: 1, runEvery: 1,
runEveryUnit: 'HOURS', runEveryUnit: 'HOURS',
@@ -88,10 +99,6 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
}); });
}; };
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);
@@ -130,7 +137,7 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
(schedule != null) ? ( (schedule != null) ? (
<Box mt={2} display="flex" justifyContent="space-between"> <Box mt={2} display="flex" justifyContent="space-between">
<Button <Button
onClick={deleteSchedule} onClick={deleteRobotSchedule}
variant="outlined" variant="outlined"
color="secondary" color="secondary"
> >