feat: disable confirm capture if unconfirmed fields
This commit is contained in:
@@ -271,15 +271,11 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
}, [stopGetList, getListSettingsObject, socket, notify, handleStopGetList]);
|
}, [stopGetList, getListSettingsObject, socket, notify, handleStopGetList]);
|
||||||
|
|
||||||
|
const hasUnconfirmedListTextFields = browserSteps.some(step => step.type === 'list' && Object.values(step.fields).some(field => !confirmedListTextFields[step.id]?.[field.id]));
|
||||||
|
|
||||||
const handleConfirmListCapture = useCallback(() => {
|
const handleConfirmListCapture = useCallback(() => {
|
||||||
switch (captureStage) {
|
switch (captureStage) {
|
||||||
case 'initial':
|
case 'initial':
|
||||||
const hasUnconfirmedListTextFields = browserSteps.some(step => step.type === 'list' && Object.values(step.fields).some(field => !confirmedListTextFields[step.id]?.[field.id]));
|
|
||||||
if (hasUnconfirmedListTextFields) {
|
|
||||||
notify('error', 'Please confirm all field labels.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
startPaginationMode();
|
|
||||||
setShowPaginationOptions(true);
|
setShowPaginationOptions(true);
|
||||||
setCaptureStage('pagination');
|
setCaptureStage('pagination');
|
||||||
break;
|
break;
|
||||||
@@ -376,17 +372,22 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '15px' }}>
|
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '15px' }}>
|
||||||
{!getText && !getScreenshot && !getList && showCaptureList && <Button variant="contained" onClick={startGetList}>Capture List</Button>}
|
{!getText && !getScreenshot && !getList && showCaptureList && <Button variant="contained" onClick={startGetList}>Capture List</Button>}
|
||||||
{getList && (
|
{getList && (
|
||||||
<>
|
<>
|
||||||
<Box display="flex" justifyContent="space-between" gap={2} style={{ margin: '15px' }}>
|
<Box display="flex" justifyContent="space-between" gap={2} style={{ margin: '15px' }}>
|
||||||
<Button variant="outlined" onClick={handleConfirmListCapture}>
|
<Button
|
||||||
{captureStage === 'initial' ? 'Confirm Capture' :
|
variant="outlined"
|
||||||
captureStage === 'pagination' ? 'Confirm Pagination' :
|
onClick={handleConfirmListCapture}
|
||||||
captureStage === 'limit' ? 'Confirm Limit' : 'Finish Capture'}
|
disabled={hasUnconfirmedListTextFields}
|
||||||
</Button>
|
>
|
||||||
<Button variant="outlined" color="error" onClick={discardGetList}>Discard</Button>
|
{captureStage === 'initial' ? 'Confirm Capture' :
|
||||||
</Box>
|
captureStage === 'pagination' ? 'Confirm Pagination' :
|
||||||
</>
|
captureStage === 'limit' ? 'Confirm Limit' : 'Finish Capture'}
|
||||||
)}
|
</Button>
|
||||||
|
<Button variant="outlined" color="error" onClick={discardGetList}>Discard</Button>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{showPaginationOptions && (
|
{showPaginationOptions && (
|
||||||
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '15px' }}>
|
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '15px' }}>
|
||||||
<Typography>How can we find the next list item on the page?</Typography>
|
<Typography>How can we find the next list item on the page?</Typography>
|
||||||
|
|||||||
Reference in New Issue
Block a user