feat: ensure list ids and labels are updated

This commit is contained in:
karishmas6
2024-09-21 15:57:44 +05:30
parent 7d5a43be3a
commit 918c79d71c

View File

@@ -61,13 +61,11 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
const addListStep = (listSelector: string, newFields: { [key: string]: TextStep }, listId: number, pagination?: { type: string; selector: string }, limit?: number) => {
setBrowserSteps(prevSteps => {
const existingListStepIndex = prevSteps.findIndex(
step => step.type === 'list' && step.id === listId
);
const existingListStepIndex = prevSteps.findIndex(step => step.type === 'list' && step.id === listId);
if (existingListStepIndex !== -1) {
// Update the existing ListStep with new fields, excluding discarded ones
const updatedSteps = [...prevSteps];
const existingListStep = updatedSteps[existingListStepIndex] as ListStep;
const filteredNewFields = Object.entries(newFields).reduce((acc, [key, value]) => {
if (!discardedFields.has(`${listId}-${key}`)) {
acc[key] = value;
@@ -134,7 +132,6 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
);
};
const removeListTextField = (listId: number, fieldKey: string) => {
setBrowserSteps(prevSteps =>
prevSteps.map(step => {