From 7a4954e01aee0f428a228320312c0ffcc49fa791 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 16:51:02 +0530 Subject: [PATCH 1/7] chore: -rm comments --- src/components/organisms/RightSidePanel.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 6938e090..535b4c98 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -45,10 +45,8 @@ export const RightSidePanel: React.FC = ({ onFinishCapture if (confirmedListTextFields[listId]?.[fieldKey]) { return; } - // This is a text field within a list step updateListTextFieldLabel(listId, fieldKey, label); } else { - // This is a standalone text step setTextLabels(prevLabels => ({ ...prevLabels, [id]: label })); } if (!label.trim()) { From 7fa4bf99f4ae7bad1c6972c63ae505c1984f066a Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 16:52:58 +0530 Subject: [PATCH 2/7] feat: better error messages --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 535b4c98..6e6a95d4 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -250,7 +250,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture setTextLabels({}); setErrors({}); setConfirmedTextSteps({}); - notify('info', 'Capture Text steps discarded'); + notify('info', 'Capture Text Discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); const discardGetList = useCallback(() => { @@ -261,7 +261,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture } }); resetListState(); - notify('info', 'Capture List steps discarded'); + notify('info', 'Capture List Discarded'); }, [browserSteps, stopGetList, deleteBrowserStep, resetListState]); From f95d1dc550cc961c36f9b1e14df54299d36dd75b Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 16:57:07 +0530 Subject: [PATCH 3/7] feat: error severity --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 6e6a95d4..e34e3571 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -250,7 +250,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture setTextLabels({}); setErrors({}); setConfirmedTextSteps({}); - notify('info', 'Capture Text Discarded'); + notify('error', 'Capture Text Discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); const discardGetList = useCallback(() => { @@ -261,7 +261,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture } }); resetListState(); - notify('info', 'Capture List Discarded'); + notify('error', 'Capture List Discarded'); }, [browserSteps, stopGetList, deleteBrowserStep, resetListState]); From a49353386d7105198590e55272dec9af8e70bf82 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 17:37:52 +0530 Subject: [PATCH 4/7] feat: throw error if unconfirmed list text fields --- src/components/organisms/RightSidePanel.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index e34e3571..026296d9 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -194,6 +194,11 @@ export const RightSidePanel: React.FC = ({ onFinishCapture startPaginationMode(); setShowPaginationOptions(true); setCaptureStage('pagination'); + 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; + } break; case 'pagination': From b1b4a1233eadfbf7a8caaaef38e31bbc48a62915 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 17:39:35 +0530 Subject: [PATCH 5/7] fix: show pagination options after confirmed list text field check --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 026296d9..de0a6a9b 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -192,13 +192,13 @@ export const RightSidePanel: React.FC = ({ onFinishCapture switch (captureStage) { case 'initial': startPaginationMode(); - setShowPaginationOptions(true); - setCaptureStage('pagination'); 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; } + setShowPaginationOptions(true); + setCaptureStage('pagination'); break; case 'pagination': From 5ec0dd146cf5000bb8faf50fde9fc47cd8ba3d7a Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 17:40:06 +0530 Subject: [PATCH 6/7] chore: lint --- src/components/organisms/RightSidePanel.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index de0a6a9b..c1e9cf75 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -133,15 +133,15 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const getListSettingsObject = useCallback(() => { let settings: { listSelector?: string; - fields?: Record; + fields?: Record; pagination?: { type: string; selector?: string }; limit?: number; } = {}; - + browserSteps.forEach(step => { if (step.type === 'list' && step.listSelector && Object.keys(step.fields).length > 0) { - const fields: Record = {}; - + const fields: Record = {}; + Object.entries(step.fields).forEach(([id, field]) => { if (field.selectorObj?.selector) { fields[field.label] = { @@ -151,7 +151,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture }; } }); - + settings = { listSelector: step.listSelector, fields: fields, @@ -160,10 +160,10 @@ export const RightSidePanel: React.FC = ({ onFinishCapture }; } }); - + return settings; }, [browserSteps, paginationType, limitType, customLimit]); - + const resetListState = useCallback(() => { setShowPaginationOptions(false); updatePaginationType(''); From dc9957d72f0ed56a8e5cc6f40082f4c954e887dc Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 18:21:49 +0530 Subject: [PATCH 7/7] fix: show confirm error --- src/components/organisms/RightSidePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index c1e9cf75..9148fb5a 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -118,7 +118,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const stopCaptureAndEmitGetTextSettings = useCallback(() => { const hasUnconfirmedTextSteps = browserSteps.some(step => step.type === 'text' && !confirmedTextSteps[step.id]); if (hasUnconfirmedTextSteps) { - notify('error', 'Please confirm no labels are empty'); + notify('error', 'Please confirm all text fields'); return; } stopGetText();