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 { validMomentTimezones } from '../../constants/const';
import { useGlobalInfoStore } from '../../context/globalInfo';
import { getSchedule } from '../../api/storage';
import { getSchedule, deleteSchedule } from '../../api/storage';
interface ScheduleSettingsProps {
isOpen: boolean;
@@ -77,7 +77,18 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
'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({
runEvery: 1,
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 () => {
if (recordingId) {
const schedule = await getSchedule(recordingId);
@@ -130,7 +137,7 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
(schedule != null) ? (
<Box mt={2} display="flex" justifyContent="space-between">
<Button
onClick={deleteSchedule}
onClick={deleteRobotSchedule}
variant="outlined"
color="secondary"
>