fix: use limitType from global context

This commit is contained in:
karishmas6
2024-09-08 14:01:17 +05:30
parent b2a1226bca
commit c5719ecea3

View File

@@ -34,10 +34,8 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: number]: boolean }>({}); const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: number]: boolean }>({});
const [showPaginationOptions, setShowPaginationOptions] = useState(false); const [showPaginationOptions, setShowPaginationOptions] = useState(false);
const [showLimitOptions, setShowLimitOptions] = useState(false); const [showLimitOptions, setShowLimitOptions] = useState(false);
const [selectedLimit, setSelectedLimit] = useState<string>('10');
const [captureStage, setCaptureStage] = useState<'initial' | 'pagination' | 'limit' | 'complete'>('initial'); const [captureStage, setCaptureStage] = useState<'initial' | 'pagination' | 'limit' | 'complete'>('initial');
const { lastAction, notify } = useGlobalInfoStore(); const { lastAction, notify } = useGlobalInfoStore();
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, paginationMode, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitMode, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext(); const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, paginationMode, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitMode, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext();
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep } = useBrowserSteps(); const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep } = useBrowserSteps();
@@ -52,10 +50,6 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
} }
}; };
const handleLimitChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setSelectedLimit(event.target.value);
};
const handleTextStepConfirm = (id: number) => { const handleTextStepConfirm = (id: number) => {
const label = textLabels[id]?.trim(); const label = textLabels[id]?.trim();
if (label) { if (label) {
@@ -130,20 +124,20 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
listSelector: step.listSelector, listSelector: step.listSelector,
fields: fields, fields: fields,
pagination: { type: paginationType, selector: step.pagination?.selector }, pagination: { type: paginationType, selector: step.pagination?.selector },
limit: parseInt(selectedLimit === 'custom' ? customLimit : selectedLimit), limit: parseInt(limitType === 'custom' ? customLimit : limitType),
}; };
} }
}); });
return settings; return settings;
}, [browserSteps, paginationType, selectedLimit, customLimit]); }, [browserSteps, paginationType, limitType, customLimit]);
const resetListState = useCallback(() => { const resetListState = useCallback(() => {
setShowPaginationOptions(false); setShowPaginationOptions(false);
updatePaginationType(''); updatePaginationType('');
setShowLimitOptions(false); setShowLimitOptions(false);
setSelectedLimit('10'); updateLimitType('10');
updateLimitType(''); updateLimitType('');
updateCustomLimit(''); updateCustomLimit('');
}, [updatePaginationType, updateLimitType, updateCustomLimit]); }, [updatePaginationType, updateLimitType, updateCustomLimit]);
@@ -168,7 +162,6 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
const handleConfirmListCapture = useCallback(() => { const handleConfirmListCapture = useCallback(() => {
switch (captureStage) { switch (captureStage) {
case 'initial': case 'initial':
// Start pagination mode
startPaginationMode(); startPaginationMode();
setShowPaginationOptions(true); setShowPaginationOptions(true);
setCaptureStage('pagination'); setCaptureStage('pagination');
@@ -188,7 +181,6 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
return; return;
} }
// Close pagination mode and start limit mode
stopPaginationMode(); stopPaginationMode();
setShowPaginationOptions(false); setShowPaginationOptions(false);
startLimitMode(); startLimitMode();
@@ -208,7 +200,6 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
return; return;
} }
// Close limit mode and emit settings
stopLimitMode(); stopLimitMode();
setShowLimitOptions(false); setShowLimitOptions(false);
stopCaptureAndEmitGetListSettings(); stopCaptureAndEmitGetListSettings();
@@ -216,7 +207,6 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
break; break;
case 'complete': case 'complete':
// Reset the capture process
setCaptureStage('initial'); setCaptureStage('initial');
break; break;
} }