chore: lint
This commit is contained in:
@@ -27,8 +27,8 @@ export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => {
|
|||||||
const [isSettingsDisplayed, setIsSettingsDisplayed] = useState<boolean>(false);
|
const [isSettingsDisplayed, setIsSettingsDisplayed] = useState<boolean>(false);
|
||||||
const [labels, setLabels] = useState<{ [id: number]: string }>({});
|
const [labels, setLabels] = useState<{ [id: number]: string }>({});
|
||||||
const [errors, setErrors] = useState<{ [id: number]: string }>({});
|
const [errors, setErrors] = useState<{ [id: number]: string }>({});
|
||||||
const [confirmedSteps, setConfirmedSteps] = useState<{ [id: number]: boolean }>({});
|
const [confirmedSteps, setConfirmedSteps] = useState<{ [id: number]: boolean }>({});
|
||||||
|
|
||||||
|
|
||||||
const { lastAction } = useGlobalInfoStore();
|
const { lastAction } = useGlobalInfoStore();
|
||||||
const { getText, getScreenshot, startGetText, stopGetText, startGetScreenshot, stopGetScreenshot } = useActionContext();
|
const { getText, getScreenshot, startGetText, stopGetText, startGetScreenshot, stopGetScreenshot } = useActionContext();
|
||||||
@@ -48,33 +48,33 @@ export const RightSidePanel = ({ pairForEdit }: RightSidePanelProps) => {
|
|||||||
const handleLabelChange = (id: number, label: string) => {
|
const handleLabelChange = (id: number, label: string) => {
|
||||||
setLabels(prevLabels => ({ ...prevLabels, [id]: label }));
|
setLabels(prevLabels => ({ ...prevLabels, [id]: label }));
|
||||||
if (!label.trim()) {
|
if (!label.trim()) {
|
||||||
setErrors(prevErrors => ({ ...prevErrors, [id]: 'Label cannot be empty' }));
|
setErrors(prevErrors => ({ ...prevErrors, [id]: 'Label cannot be empty' }));
|
||||||
} else {
|
} else {
|
||||||
setErrors(prevErrors => ({ ...prevErrors, [id]: '' }));
|
setErrors(prevErrors => ({ ...prevErrors, [id]: '' }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = (id: number) => {
|
const handleConfirm = (id: number) => {
|
||||||
const label = labels[id]?.trim();
|
const label = labels[id]?.trim();
|
||||||
if (label) {
|
if (label) {
|
||||||
updateBrowserStepLabel(id, label);
|
updateBrowserStepLabel(id, label);
|
||||||
setConfirmedSteps(prev => ({ ...prev, [id]: true }));
|
setConfirmedSteps(prev => ({ ...prev, [id]: true }));
|
||||||
} else {
|
} else {
|
||||||
setErrors(prevErrors => ({ ...prevErrors, [id]: 'Label cannot be empty' }));
|
setErrors(prevErrors => ({ ...prevErrors, [id]: 'Label cannot be empty' }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDiscard = (id: number) => {
|
const handleDiscard = (id: number) => {
|
||||||
deleteBrowserStep(id);
|
deleteBrowserStep(id);
|
||||||
setLabels(prevLabels => {
|
setLabels(prevLabels => {
|
||||||
const { [id]: _, ...rest } = prevLabels;
|
const { [id]: _, ...rest } = prevLabels;
|
||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
setErrors(prevErrors => {
|
setErrors(prevErrors => {
|
||||||
const { [id]: _, ...rest } = prevErrors;
|
const { [id]: _, ...rest } = prevErrors;
|
||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
@@ -142,36 +142,36 @@ const handleDiscard = (id: number) => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
{browserSteps.map(step => (
|
{browserSteps.map(step => (
|
||||||
<Box key={step.id} sx={{ border: '1px solid black', padding: '10px', marginBottom: '10px' }}>
|
<Box key={step.id} sx={{ border: '1px solid black', padding: '10px', marginBottom: '10px' }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="Label"
|
label="Label"
|
||||||
value={labels[step.id] || step.label || ''}
|
value={labels[step.id] || step.label || ''}
|
||||||
onChange={(e) => handleLabelChange(step.id, e.target.value)}
|
onChange={(e) => handleLabelChange(step.id, e.target.value)}
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="normal"
|
margin="normal"
|
||||||
error={!!errors[step.id]}
|
error={!!errors[step.id]}
|
||||||
helperText={errors[step.id]}
|
helperText={errors[step.id]}
|
||||||
disabled={confirmedSteps[step.id]}
|
disabled={confirmedSteps[step.id]}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h6">Description: {step.value}</Typography>
|
<Typography variant="h6">Description: {step.value}</Typography>
|
||||||
{!confirmedSteps[step.id] && (
|
{!confirmedSteps[step.id] && (
|
||||||
<Box display="flex" justifyContent="space-between" gap={2}>
|
<Box display="flex" justifyContent="space-between" gap={2}>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={() => handleConfirm(step.id)}
|
onClick={() => handleConfirm(step.id)}
|
||||||
disabled={!labels[step.id]?.trim()}
|
disabled={!labels[step.id]?.trim()}
|
||||||
>
|
>
|
||||||
Confirm
|
Confirm
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="contained" onClick={() => handleDiscard(step.id)}>
|
<Button variant="contained" onClick={() => handleDiscard(step.id)}>
|
||||||
Discard
|
Discard
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user