From 42a5a25be67017c3bdb72159110fac90c5a95b5b Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 10 Oct 2024 16:18:16 +0530 Subject: [PATCH] feat: map browsersteps to workflow.workflow --- src/components/organisms/RightSidePanel.tsx | 248 +++++++++++--------- 1 file changed, 133 insertions(+), 115 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 7eed37e2..68dcc315 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -120,15 +120,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture setHoverStates(prev => ({ ...prev, [id]: false })); }; - const handlePairDelete = () => { - // deletePair(index - 1).then((updatedWorkflow) => { - // updateWorkflow(updatedWorkflow); - // }).catch((error) => { - // console.error(error); - // }); - // }; - console.log("handlePairDelete") - } + const handlePairDelete = () => {} const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { if (listId !== undefined && fieldKey !== undefined) { @@ -459,135 +451,161 @@ export const RightSidePanel: React.FC = ({ onFinishCapture )} - - {browserSteps.map(step => ( - handleMouseEnter(step.id)} onMouseLeave={() => handleMouseLeave(step.id)}> - { - step.type === 'text' && ( - <> - {confirmedTextSteps[step.id] && hoverStates[step.id] && ( - handlePairDelete()} - sx={{ - position: 'absolute', - top: -15, - right: -15, - color: 'red', - p: 0, - zIndex: 1, - boxShadow: '5px', - backgroundColor: 'white', - borderRadius: '50%', - }} - > - - - )} + {workflow.workflow && workflow.workflow.map((pair, i, workflow) => ( + + {browserSteps.map((step) => ( + handleMouseEnter(step.id)} + onMouseLeave={() => handleMouseLeave(step.id)} + > + {step.type === 'text' && ( + <> + {confirmedTextSteps[step.id] && hoverStates[step.id] && ( + handlePairDelete()} + sx={{ + position: 'absolute', + top: -15, + right: -15, + color: 'red', + p: 0, + zIndex: 1, + boxShadow: '5px', + backgroundColor: 'white', + borderRadius: '50%', + }} + > + + + )} + handleTextLabelChange(step.id, e.target.value)} + fullWidth + margin="normal" + error={!!errors[step.id]} + helperText={errors[step.id]} + InputProps={{ + readOnly: confirmedTextSteps[step.id], + startAdornment: ( + + + + ), + }} + /> + + + + ), + }} + /> + {!confirmedTextSteps[step.id] && ( + + + + + )} + + )} + {step.type === 'screenshot' && ( + + + + {`Take ${step.fullPage ? 'Fullpage' : 'Visible Part'} Screenshot`} + + + )} + {step.type === 'list' && ( + <> + List Selected Successfully + {Object.entries(step.fields).map(([key, field]) => ( + handleTextLabelChange(step.id, e.target.value)} + label="Field Label" + value={field.label || ''} + onChange={(e) => + handleTextLabelChange(field.id, e.target.value, step.id, key) + } fullWidth margin="normal" - error={!!errors[step.id]} - helperText={errors[step.id]} InputProps={{ - readOnly: confirmedTextSteps[step.id], + readOnly: confirmedListTextFields[field.id]?.[key], startAdornment: ( - ) + ), }} /> - ) + ), }} /> - {!confirmedTextSteps[step.id] && ( + {!confirmedListTextFields[step.id]?.[key] && ( - - + + )} - - )} - {step.type === 'screenshot' && ( - - - - {`Take ${step.fullPage ? 'Fullpage' : 'Visible Part'} Screenshot`} - - - )} - {step.type === 'list' && ( - <> - List Selected Successfully - {Object.entries(step.fields).map(([key, field]) => ( - - handleTextLabelChange(field.id, e.target.value, step.id, key)} - fullWidth - margin="normal" - InputProps={{ - readOnly: confirmedListTextFields[field.id]?.[key], - startAdornment: ( - - - - ) - }} - /> - - - - ) - }} - /> - {!confirmedListTextFields[step.id]?.[key] && ( - - - - - )} - - ))} - - )} - - ))} - + + ))} + + )} + + ))} + + ))} + ); }; \ No newline at end of file