From 63512f08e69e318bba38954e021360ec7ce1dc65 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 24 Oct 2024 03:37:57 +0530 Subject: [PATCH] feat: get robot details + types --- src/components/molecules/RobotSettings.tsx | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/components/molecules/RobotSettings.tsx diff --git a/src/components/molecules/RobotSettings.tsx b/src/components/molecules/RobotSettings.tsx new file mode 100644 index 00000000..843f86ae --- /dev/null +++ b/src/components/molecules/RobotSettings.tsx @@ -0,0 +1,105 @@ +import React, { useState, useEffect } from 'react'; +import { GenericModal } from "../atoms/GenericModal"; +import { MenuItem, TextField, Typography, Box, Switch, FormControlLabel } from "@mui/material"; +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, deleteSchedule, getStoredRecording } from '../../api/storage'; +import { WorkflowFile, Where, What, WhereWhatPair } from 'maxun-core'; + +interface RobotMeta { + name: string; + id: string; + createdAt: string; + pairs: number; + updatedAt: string; + params: any[]; +} + +interface RobotWorkflow { + workflow: WhereWhatPair[]; + } + + interface ScheduleConfig { + runEvery: number; + runEveryUnit: 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS'; + startFrom: 'SUNDAY' | 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY'; + atTimeStart?: string; + atTimeEnd?: string; + timezone: string; + lastRunAt?: Date; + nextRunAt?: Date; + cronExpression?: string; + } + +interface RobotSettings { +id: string; +userId?: number; +recording_meta: RobotMeta; +recording: RobotWorkflow; +google_sheet_email?: string | null; +google_sheet_name?: string | null; +google_sheet_id?: string | null; +google_access_token?: string | null; +google_refresh_token?: string | null; +schedule?: ScheduleConfig | null; +} + +interface RobotSettingsProps { + isOpen: boolean; + handleStart: (settings: RobotSettings) => void; + handleClose: () => void; +initialSettings?: RobotSettings | null; + +} + + + +export const RobotSettingsModal = ({ isOpen, handleStart, handleClose, initialSettings }: RobotSettingsProps) => { + const [robot, setRobot] = useState(null); + const { recordingId } = useGlobalInfoStore(); + + useEffect(() => { + if (isOpen) { + getRobot(); + } + }, [isOpen]); + + const getRobot = async () => { + if (recordingId) { + const robot = await getStoredRecording(recordingId); + setRobot(robot); + } else { + console.log(`Could not find robot`) + } + } + + + return ( + + <> + Robot Settings + + { + robot && ( + <> + + + ) + } + + + + ); +};