feat: use id instead of field label

This commit is contained in:
karishmas6
2024-09-21 15:56:26 +05:30
parent fe1015981f
commit 5e73fb6aa5

View File

@@ -132,42 +132,40 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
onFinishCapture(); onFinishCapture();
}, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps]); }, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps]);
const getListSettingsObject = useCallback(() => { const getListSettingsObject = useCallback(() => {
let settings: { let settings: {
listSelector?: string; listSelector?: string;
fields?: Record<string, { selector: string; tag?: string;[key: string]: any }>; fields?: Record<string, { selector: string; tag?: string; [key: string]: any }>;
pagination?: { type: string; selector?: string }; pagination?: { type: string; selector?: string };
limit?: number; limit?: number;
} = {}; } = {};
browserSteps.forEach(step => { browserSteps.forEach(step => {
if (step.type === 'list' && step.listSelector && Object.keys(step.fields).length > 0) { if (step.type === 'list' && step.listSelector && Object.keys(step.fields).length > 0) {
const fields: Record<string, { selector: string; tag?: string;[key: string]: any }> = {}; const fields: Record<string, { selector: string; tag?: string; [key: string]: any }> = {};
Object.entries(step.fields).forEach(([label, field]) => {
Object.entries(step.fields).forEach(([id, field]) => {
if (field.selectorObj?.selector) { if (field.selectorObj?.selector) {
fields[label] = { fields[field.label] = {
selector: field.selectorObj.selector, selector: field.selectorObj.selector,
tag: field.selectorObj.tag, tag: field.selectorObj.tag,
attribute: field.selectorObj.attribute, attribute: field.selectorObj.attribute,
}; };
} }
}); });
settings = { settings = {
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(limitType === 'custom' ? customLimit : limitType), limit: parseInt(limitType === 'custom' ? customLimit : limitType),
}; };
} }
}); });
return settings; return settings;
}, [browserSteps, paginationType, limitType, customLimit]); }, [browserSteps, paginationType, limitType, customLimit]);
const resetListState = useCallback(() => { const resetListState = useCallback(() => {
setShowPaginationOptions(false); setShowPaginationOptions(false);
updatePaginationType(''); updatePaginationType('');