From 0e9d0c02dd0d7c8a83d5a75f254cbafd091fcded Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 22 Jun 2024 20:03:55 +0530 Subject: [PATCH] feat: action settings --- src/components/molecules/ActionSettings.tsx | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/components/molecules/ActionSettings.tsx diff --git a/src/components/molecules/ActionSettings.tsx b/src/components/molecules/ActionSettings.tsx new file mode 100644 index 00000000..816c3e76 --- /dev/null +++ b/src/components/molecules/ActionSettings.tsx @@ -0,0 +1,79 @@ +import React, { useRef } from 'react'; +import styled from "styled-components"; +import { Button } from "@mui/material"; +import { ActionDescription } from "../organisms/RightSidePanel"; +import * as Settings from "./action-settings"; +import { useSocketStore } from "../../context/socket"; + +interface ActionSettingsProps { + action: string; +} + +export const ActionSettings = ({ action }: ActionSettingsProps) => { + + const settingsRef = useRef<{ getSettings: () => object }>(null); + const { socket } = useSocketStore(); + + const DisplaySettings = () => { + switch (action) { + case "screenshot": + return ; + case 'scroll': + return ; + case 'scrape': + return ; + case 'scrapeSchema': + return ; + case 'script': + return ; + case 'enqueueLinks': + return ; + case 'mouse.click': + return ; + default: + return null; + } + } + + const handleSubmit = (event: React.SyntheticEvent) => { + event.preventDefault(); + //get the data from settings + const settings = settingsRef.current?.getSettings(); + //Send notification to the server and generate the pair + socket?.emit(`action`, { + action, + settings + }); + } + + return ( +
+ Action settings: + +
+ + + +
+
+ ); +}; + +const ActionSettingsWrapper = styled.div<{ action: string }>` + display: flex; + flex-direction: column; + align-items: ${({ action }) => action === 'script' ? 'stretch' : 'center'};; + justify-content: center; + margin-top: 20px; +`;