feat: disable capture list initial stage confirmation if !listSelector and browser steps
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect, useMemo } from 'react';
|
||||||
import { Button, Paper, Box, TextField, IconButton } from "@mui/material";
|
import { Button, Paper, Box, TextField, IconButton } from "@mui/material";
|
||||||
import EditIcon from '@mui/icons-material/Edit';
|
import EditIcon from '@mui/icons-material/Edit';
|
||||||
import TextFieldsIcon from '@mui/icons-material/TextFields';
|
import TextFieldsIcon from '@mui/icons-material/TextFields';
|
||||||
@@ -373,6 +373,19 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
stopGetScreenshot();
|
stopGetScreenshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isConfirmCaptureDisabled = useMemo(() => {
|
||||||
|
// Check if we are in the initial stage and if there are no browser steps or no valid list selectors with fields
|
||||||
|
if (captureStage !== 'initial') return false;
|
||||||
|
|
||||||
|
const hasValidListSelector = browserSteps.some(step =>
|
||||||
|
step.type === 'list' &&
|
||||||
|
step.listSelector &&
|
||||||
|
Object.keys(step.fields).length > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
return !hasValidListSelector;
|
||||||
|
}, [captureStage, browserSteps]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper sx={{ height: '520px', width: 'auto', alignItems: "center", background: 'inherit' }} id="browser-actions" elevation={0}>
|
<Paper sx={{ height: '520px', width: 'auto', alignItems: "center", background: 'inherit' }} id="browser-actions" elevation={0}>
|
||||||
{/* <SimpleBox height={60} width='100%' background='lightGray' radius='0%'>
|
{/* <SimpleBox height={60} width='100%' background='lightGray' radius='0%'>
|
||||||
@@ -387,7 +400,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={handleConfirmListCapture}
|
onClick={handleConfirmListCapture}
|
||||||
disabled={hasUnconfirmedListTextFields}
|
disabled={captureStage === 'initial' ? isConfirmCaptureDisabled : hasUnconfirmedListTextFields}
|
||||||
>
|
>
|
||||||
{captureStage === 'initial' ? 'Confirm Capture' :
|
{captureStage === 'initial' ? 'Confirm Capture' :
|
||||||
captureStage === 'pagination' ? 'Confirm Pagination' :
|
captureStage === 'pagination' ? 'Confirm Pagination' :
|
||||||
|
|||||||
Reference in New Issue
Block a user