@@ -24,6 +24,7 @@ import { useForm } from "../../DataContext";
2424import { HiCheckCircle } from "react-icons/hi2" ;
2525import { HiExclamationTriangle } from "react-icons/hi2" ;
2626import { HiExclamationCircle } from "react-icons/hi2" ;
27+ import { compareStringPasses } from "../../types/levenshtein-distance" ;
2728
2829type EntrySliverProp = {
2930 gptPass : GPTResponse ;
@@ -158,13 +159,23 @@ export default function EntrySliver({
158159 const tests_2 = pass_2 [ i ] [ typesafeKey ] ;
159160 const tests_3 = pass_3 [ i ] [ typesafeKey ] ;
160161
161- // if the key is special_notes, just fill in one value and return
162- // this is a compromise, as special_notes is often one long string and hard to compare
162+ // the 'special_notes' field is a long string and thus should probably be compared using a different method
163163 if ( typesafeKey === "special_notes" ) {
164- updatedTest = {
165- ...updatedTest ,
166- [ typesafeKey ] : tests_1 ,
167- } ;
164+ const result = compareStringPasses ( tests_1 , tests_2 , tests_3 ) ;
165+ if ( result . pass ) {
166+ updatedTest = {
167+ ...updatedTest ,
168+ [ typesafeKey ] : result . pass ,
169+ } ;
170+ }
171+ if ( result . severity ) {
172+ addConflict2 (
173+ updatedConflicts ,
174+ `parts-${ testIndex } -sees-${ i } -${ key } ` ,
175+ result . severity
176+ ) ;
177+ }
178+
168179 return ;
169180 }
170181
@@ -238,13 +249,22 @@ export default function EntrySliver({
238249 const tests_2 = pass_2 [ i ] [ typesafeKey ] ;
239250 const tests_3 = pass_3 [ i ] [ typesafeKey ] ;
240251
241- // if the key is special_notes, just fill in one value and return
242- // this is a compromise, as special_notes is often one long string and hard to compare
252+ // the 'special_notes' field is a long string and thus should probably be compared using a different method
243253 if ( typesafeKey === "special_notes" ) {
244- updatedTest = {
245- ...updatedTest ,
246- [ typesafeKey ] : tests_1 ,
247- } ;
254+ const result = compareStringPasses ( tests_1 , tests_2 , tests_3 ) ;
255+ if ( result . pass ) {
256+ updatedTest = {
257+ ...updatedTest ,
258+ [ typesafeKey ] : result . pass ,
259+ } ;
260+ }
261+ if ( result . severity ) {
262+ addConflict2 (
263+ updatedConflicts ,
264+ `parts-${ testIndex } -sees-${ i } -${ key } ` ,
265+ result . severity
266+ ) ;
267+ }
248268 return ;
249269 }
250270
@@ -318,16 +338,25 @@ export default function EntrySliver({
318338 const tests_2 = pass_2 [ i ] [ typesafeKey ] ;
319339 const tests_3 = pass_3 [ i ] [ typesafeKey ] ;
320340
321- // if the key is special_notes, just fill in one value and return
322- // this is a compromise, as special_notes is often one long string and hard to compare
341+ // the 'special_notes' field is a long string and thus should probably be compared using a different method
323342 if ( typesafeKey === "special_notes" ) {
324- updatedTest = {
325- ...updatedTest ,
326- [ typesafeKey ] : tests_1 ,
327- } ;
343+ const result = compareStringPasses ( tests_1 , tests_2 , tests_3 ) ;
344+ if ( result . pass ) {
345+ updatedTest = {
346+ ...updatedTest ,
347+ [ typesafeKey ] : result . pass ,
348+ } ;
349+ }
350+ if ( result . severity ) {
351+ addConflict2 (
352+ updatedConflicts ,
353+ `parts-${ testIndex } -sees-${ i } -${ key } ` ,
354+ result . severity
355+ ) ;
356+ }
357+
328358 return ;
329359 }
330-
331360 if (
332361 tests_1 === tests_2 &&
333362 tests_1 === tests_3 &&
@@ -447,13 +476,24 @@ export default function EntrySliver({
447476 } ;
448477 return ;
449478 }
450- // if the key is other_details, just fill in one value and return
451- // this is a compromise, as other_details is often one long string and hard to compare
479+
480+ // the 'other_details' field is a long string and thus should probably be compared using a different method
452481 if ( typesafeKey === "other_details" ) {
453- updatedPart = {
454- ...updatedPart ,
455- [ typesafeKey ] : parts_1 ,
456- } ;
482+ const result = compareStringPasses ( parts_1 , parts_2 , parts_3 ) ;
483+ if ( result . pass ) {
484+ updatedPart = {
485+ ...updatedPart ,
486+ [ typesafeKey ] : result . pass ,
487+ } ;
488+ }
489+ if ( result . severity ) {
490+ addConflict2 (
491+ updatedConflicts ,
492+ `parts-${ i } -${ key } ` ,
493+ result . severity
494+ ) ;
495+ }
496+
457497 return ;
458498 }
459499
@@ -544,12 +584,20 @@ export default function EntrySliver({
544584 if ( editedEntry [ typesafeKey ] !== undefined ) {
545585 return ;
546586 }
547- // the 'objective' field is a long string and thus cannot be compared via string comparison
587+ // the 'objective' field is a long string and thus should probably be compared using a different method
548588 if ( typesafeKey === "objective" ) {
549- updatedEntry = {
550- ...updatedEntry ,
551- objective : pass_1 ,
552- } ;
589+ const result = compareStringPasses ( pass_1 , pass_2 , pass_3 ) ;
590+
591+ if ( result . pass ) {
592+ updatedEntry = {
593+ ...updatedEntry ,
594+ objective : result . pass ,
595+ } ;
596+ }
597+ if ( result . severity ) {
598+ addConflict2 ( updatedConflicts , key , result . severity ) ;
599+ }
600+
553601 return ;
554602 }
555603 // Compare the part information in the passes
0 commit comments