From e0c014e98ae826fdbc82971a7954aa230982adf3 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 23 Oct 2024 00:13:29 +0530 Subject: [PATCH] feat: delete schedule --- src/components/molecules/ScheduleSettings.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/molecules/ScheduleSettings.tsx b/src/components/molecules/ScheduleSettings.tsx index 6449835c..11ef3185 100644 --- a/src/components/molecules/ScheduleSettings.tsx +++ b/src/components/molecules/ScheduleSettings.tsx @@ -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) ? (