Skip to content

Commit e0ef99c

Browse files
committed
chore: Add max length calculation logic using extracted output
1 parent a0e68e8 commit e0ef99c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/app/create/[id]/createBlueprintSteps/ExtractFields.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ const ExtractFields = ({
144144
parsedRegex,
145145
revealPrivateFields
146146
);
147+
147148
setRegexGeneratedOutputs((prev) => {
148149
const updated = [...prev];
149150
// @ts-ignore
150151
updated[index] = regexOutputs;
151152
return updated;
152153
});
154+
155+
// update the max length of the regex at that particular index
156+
const decomposedRegexes = [...store.decomposedRegexes];
157+
decomposedRegexes[index].maxLength = regexOutputs[0].length ?? 64;
158+
setField('decomposedRegexes', decomposedRegexes);
153159
} catch (error) {
154160
console.error('Error testing decomposed regex:', error);
155161
setRegexGeneratedOutputs((prev) => {
@@ -168,7 +174,18 @@ const ExtractFields = ({
168174
generateRegexOutputs().finally(() => {
169175
setIsGeneratingFields(false);
170176
});
171-
}, [file, JSON.stringify(store.decomposedRegexes)]);
177+
}, [
178+
file,
179+
revealPrivateFields,
180+
JSON.stringify(
181+
store.decomposedRegexes?.map((regex) => ({
182+
name: regex.name,
183+
location: regex.location,
184+
parts: regex.parts,
185+
isHashed: regex.isHashed,
186+
}))
187+
),
188+
]);
172189

173190
const handleGenerateFields = async (index: number) => {
174191
const updatedIsGeneratingFieldsLoading = [...isGeneratingFieldsLoading];

0 commit comments

Comments
 (0)