feat: user input for label
This commit is contained in:
@@ -25,12 +25,13 @@ export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => {
|
|||||||
const [content, setContent] = useState<string>('action');
|
const [content, setContent] = useState<string>('action');
|
||||||
const [action, setAction] = useState<string>('');
|
const [action, setAction] = useState<string>('');
|
||||||
const [isSettingsDisplayed, setIsSettingsDisplayed] = useState<boolean>(false);
|
const [isSettingsDisplayed, setIsSettingsDisplayed] = useState<boolean>(false);
|
||||||
const [stepLabel, setStepLabel] = useState<string>('');
|
const [labels, setLabels] = useState<{ [id: number]: string }>({});
|
||||||
const [stepDescription, setStepDescription] = useState<string>('');
|
const [stepDescription, setStepDescription] = useState<string>('');
|
||||||
|
|
||||||
|
|
||||||
const { lastAction } = useGlobalInfoStore();
|
const { lastAction } = useGlobalInfoStore();
|
||||||
const { getText, getScreenshot, startGetText, stopGetText, startGetScreenshot, stopGetScreenshot } = useActionContext();
|
const { getText, getScreenshot, startGetText, stopGetText, startGetScreenshot, stopGetScreenshot } = useActionContext();
|
||||||
const { browserSteps } = useBrowserSteps();
|
const { browserSteps, updateBrowserStepLabel, deleteBrowserStep } = useBrowserSteps();
|
||||||
|
|
||||||
const handleChange = (event: React.SyntheticEvent, newValue: string) => {
|
const handleChange = (event: React.SyntheticEvent, newValue: string) => {
|
||||||
setContent(newValue);
|
setContent(newValue);
|
||||||
@@ -56,6 +57,20 @@ export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => {
|
|||||||
// setStepDescription('');
|
// setStepDescription('');
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
const handleLabelChange = (id: number, label: string) => {
|
||||||
|
setLabels(prevLabels => ({ ...prevLabels, [id]: label }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirm = (id: number) => {
|
||||||
|
if (labels[id]) {
|
||||||
|
updateBrowserStepLabel(id, labels[id]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDiscard = (id: number) => {
|
||||||
|
deleteBrowserStep(id);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -122,13 +137,27 @@ export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
{browserSteps.map(step => (
|
{browserSteps.map(step => (
|
||||||
<Box key={step.id} sx={{ border: '1px solid black', padding: '10px' }}>
|
<Box key={step.id} sx={{ border: '1px solid black', padding: '10px', marginBottom: '10px' }}>
|
||||||
<Typography variant="h6">{step.label}</Typography>
|
<TextField
|
||||||
<Typography>{step.value}</Typography>
|
label="Label"
|
||||||
</Box>
|
value={labels[step.id] || step.label || ''}
|
||||||
))}
|
onChange={(e) => handleLabelChange(step.id, e.target.value)}
|
||||||
</Box>
|
fullWidth
|
||||||
|
margin="normal"
|
||||||
|
/>
|
||||||
|
<Typography variant="h6">Description: {step.value}</Typography>
|
||||||
|
<Box display="flex" justifyContent="space-between" gap={2}>
|
||||||
|
<Button variant="contained" onClick={() => handleConfirm(step.id)}>
|
||||||
|
Confirm
|
||||||
|
</Button>
|
||||||
|
<Button variant="contained" onClick={() => handleDiscard(step.id)}>
|
||||||
|
Discard
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user