import React, { useEffect, useState } from 'react'; import { Button, MenuItem, Paper, Box, TextField } from "@mui/material"; import { Dropdown as MuiDropdown } from '../atoms/DropdownMui'; import styled from "styled-components"; import { ActionSettings } from "../molecules/ActionSettings"; import { SelectChangeEvent } from "@mui/material/Select/Select"; import { SimpleBox } from "../atoms/Box"; import Typography from "@mui/material/Typography"; import { useGlobalInfoStore } from "../../context/globalInfo"; import { PairForEdit } from "../../pages/RecordingPage"; import { useActionContext } from '../../context/browserActions'; interface RightSidePanelProps { pairForEdit: PairForEdit; } interface BrowserStep { id: number; label: string; description: string; } export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => { const [content, setContent] = useState('action'); const [action, setAction] = useState(''); const [isSettingsDisplayed, setIsSettingsDisplayed] = useState(false); const [browserSteps, setBrowserSteps] = useState([]); const [stepLabel, setStepLabel] = useState(''); const { lastAction } = useGlobalInfoStore(); const { getText, getScreenshot, startGetText, stopGetText, startGetScreenshot, stopGetScreenshot } = useActionContext(); const handleChange = (event: React.SyntheticEvent, newValue: string) => { setContent(newValue); }; const handleActionSelect = (event: SelectChangeEvent) => { const { value } = event.target; setAction(value); setIsSettingsDisplayed(true); }; useEffect(() => { if (content !== 'detail' && pairForEdit.pair !== null) { setContent('detail'); } }, [pairForEdit]); const addBrowserStep = () => { setBrowserSteps([...browserSteps, { id: Date.now(), label: stepLabel, description: 'Description of the step' }]); setStepLabel(''); }; const confirmStep = (id: number) => { console.log(`Step with ID ${id} confirmed.`); // Implement your logic here }; const discardStep = (id: number) => { setBrowserSteps(browserSteps.filter(step => step.id !== id)); }; return ( Last action: {` ${lastAction}`} {content === 'action' ? ( Type of action: click on coordinates enqueueLinks scrape scrapeSchema screenshot script scroll {isSettingsDisplayed && } ) : null} {!getText && !getScreenshot && ( )} {getText && ( )} {!getText && !getScreenshot && ( )} {getScreenshot && ( )} setStepLabel(e.target.value)} /> {browserSteps.map(step => ( {step.label} {step.description} ))} ); }; const ActionTypeWrapper = styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 20px; `; export const ActionDescription = styled.p` margin-left: 15px; `;