fix: revert changes

This commit is contained in:
karishmas6
2024-10-10 16:27:38 +05:30
parent 11974a52f1
commit d81e2684ce

View File

@@ -120,7 +120,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
setHoverStates(prev => ({ ...prev, [id]: false })); setHoverStates(prev => ({ ...prev, [id]: false }));
}; };
const handlePairDelete = () => { } const handlePairDelete = () => {}
const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => {
if (listId !== undefined && fieldKey !== undefined) { if (listId !== undefined && fieldKey !== undefined) {
@@ -451,137 +451,135 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
</Box> </Box>
)} )}
</Box> </Box>
{ <Box>
workflow.workflow.map((pair, i, workflow) => ( {browserSteps.map(step => (
<Box key={workflow.length - i} sx={{ mb: 2 }}> <Box key={step.id} sx={{ boxShadow: 5, padding: '10px', margin: '13px', borderRadius: '4px', position: 'relative', }} onMouseEnter={() => handleMouseEnter(step.id)} onMouseLeave={() => handleMouseLeave(step.id)}>
{browserSteps.filter(step => { {
if (step.type === 'text') { step.type === 'text' && (
return confirmedTextSteps[step.id]; // Check if text step is confirmed <>
} else if (step.type === 'list') { {confirmedTextSteps[step.id] && hoverStates[step.id] && (
return Object.values(confirmedListTextFields[step.id] || {}).some(Boolean); // Check if any list fields are confirmed <IconButton
} else if (step.type === 'screenshot') { onClick={() => handlePairDelete()}
return true; // Assuming all screenshot steps are considered confirmed by default sx={{
} position: 'absolute',
return false; // Default case top: -15,
}).map((step) => ( right: -15,
<Box color: 'red',
key={step.id} p: 0,
sx={{ zIndex: 1,
boxShadow: 5, boxShadow: '5px',
padding: '10px', backgroundColor: 'white',
margin: '13px', borderRadius: '50%',
borderRadius: '4px', }}
position: 'relative', >
}} <DeleteIcon sx={{ fontSize: 40 }} />
onMouseEnter={() => handleMouseEnter(step.id)} </IconButton>
onMouseLeave={() => handleMouseLeave(step.id)} )}
> <TextField
{step.type === 'text' && ( label="Label"
<> value={textLabels[step.id] || step.label || ''}
{hoverStates[step.id] && ( onChange={(e) => handleTextLabelChange(step.id, e.target.value)}
<IconButton fullWidth
onClick={() => handlePairDelete()} margin="normal"
sx={{ error={!!errors[step.id]}
position: 'absolute', helperText={errors[step.id]}
top: -15, InputProps={{
right: -15, readOnly: confirmedTextSteps[step.id],
color: 'red', startAdornment: (
p: 0, <InputAdornment position="start">
zIndex: 1, <EditIcon />
boxShadow: '5px', </InputAdornment>
backgroundColor: 'white', )
borderRadius: '50%', }}
}} />
> <TextField
<DeleteIcon sx={{ fontSize: 40 }} /> label="Data"
</IconButton> value={step.data}
)} fullWidth
margin="normal"
InputProps={{
readOnly: confirmedTextSteps[step.id],
startAdornment: (
<InputAdornment position="start">
<TextFieldsIcon />
</InputAdornment>
)
}}
/>
{!confirmedTextSteps[step.id] && (
<Box display="flex" justifyContent="space-between" gap={2}>
<Button variant="contained" onClick={() => handleTextStepConfirm(step.id)} disabled={!textLabels[step.id]?.trim()}>Confirm</Button>
<Button variant="contained" onClick={() => handleTextStepDiscard(step.id)}>Discard</Button>
</Box>
)}
</>
)}
{step.type === 'screenshot' && (
<Box display="flex" alignItems="center">
<DocumentScannerIcon sx={{ mr: 1 }} />
<Typography>
{`Take ${step.fullPage ? 'Fullpage' : 'Visible Part'} Screenshot`}
</Typography>
</Box>
)}
{step.type === 'list' && (
<>
<Typography>List Selected Successfully</Typography>
{Object.entries(step.fields).map(([key, field]) => (
<Box key={key}>
<TextField <TextField
label="Label" label="Field Label"
value={textLabels[step.id] || step.label || ''} value={field.label || ''}
onChange={(e) => handleTextLabelChange(step.id, e.target.value)} onChange={(e) => handleTextLabelChange(field.id, e.target.value, step.id, key)}
fullWidth fullWidth
margin="normal" margin="normal"
error={!!errors[step.id]}
helperText={errors[step.id]}
InputProps={{ InputProps={{
readOnly: confirmedTextSteps[step.id], readOnly: confirmedListTextFields[field.id]?.[key],
startAdornment: ( startAdornment: (
<InputAdornment position="start"> <InputAdornment position="start">
<EditIcon /> <EditIcon />
</InputAdornment> </InputAdornment>
), )
}} }}
/> />
<TextField <TextField
label="Data" label="Field Data"
value={step.data} value={field.data || ''}
fullWidth fullWidth
margin="normal" margin="normal"
InputProps={{ InputProps={{
readOnly: confirmedTextSteps[step.id], readOnly: true,
startAdornment: ( startAdornment: (
<InputAdornment position="start"> <InputAdornment position="start">
<TextFieldsIcon /> <TextFieldsIcon />
</InputAdornment> </InputAdornment>
), )
}} }}
/> />
</> {!confirmedListTextFields[step.id]?.[key] && (
)} <Box display="flex" justifyContent="space-between" gap={2}>
{step.type === 'screenshot' && ( <Button
<Box display="flex" alignItems="center"> variant="contained"
<DocumentScannerIcon sx={{ mr: 1 }} /> onClick={() => handleListTextFieldConfirm(step.id, key)}
<Typography> disabled={!field.label?.trim()}
{`Take ${step.fullPage ? 'Fullpage' : 'Visible Part'} Screenshot`} >
</Typography> Confirm
</Box> </Button>
)} <Button
{step.type === 'list' && ( variant="contained"
<> onClick={() => handleListTextFieldDiscard(step.id, key)}
<Typography>List Selected Successfully</Typography> >
{Object.entries(step.fields).map(([key, field]) => ( Discard
<Box key={key}> </Button>
<TextField
label="Field Label"
value={field.label || ''}
onChange={(e) =>
handleTextLabelChange(field.id, e.target.value, step.id, key)
}
fullWidth
margin="normal"
InputProps={{
readOnly: confirmedListTextFields[field.id]?.[key],
startAdornment: (
<InputAdornment position="start">
<EditIcon />
</InputAdornment>
),
}}
/>
<TextField
label="Field Data"
value={field.data || ''}
fullWidth
margin="normal"
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="start">
<TextFieldsIcon />
</InputAdornment>
),
}}
/>
</Box> </Box>
))} )}
</> </Box>
)} ))}
</Box> </>
))} )}
</Box> </Box>
))} ))}
</Box>
</Paper> </Paper>
); );
}; };