diff --git a/.VSCodeCounter/2025-03-17_14-20-03/details.md b/.VSCodeCounter/2025-03-17_14-20-03/details.md new file mode 100644 index 0000000..b261a96 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/details.md @@ -0,0 +1,43 @@ +# Details + +Date : 2025-03-17 14:20:03 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 28 files, 6565 codes, 1027 comments, 1053 blanks, all 8645 lines + +[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md) + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md) | Markdown | 39 | 0 | 19 | 58 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx) | TypeScript JSX | 230 | 10 | 8 | 248 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx) | TypeScript JSX | 18 | 0 | 3 | 21 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx) | TypeScript JSX | 83 | 0 | 4 | 87 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx) | TypeScript JSX | 273 | 19 | 37 | 329 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx) | TypeScript JSX | 193 | 4 | 15 | 212 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx) | TypeScript JSX | 374 | 42 | 44 | 460 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx) | TypeScript JSX | 1,101 | 234 | 213 | 1,548 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx) | TypeScript JSX | 499 | 48 | 54 | 601 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx) | TypeScript JSX | 112 | 12 | 21 | 145 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx) | TypeScript JSX | 232 | 31 | 32 | 295 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx) | TypeScript JSX | 407 | 56 | 52 | 515 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx) | TypeScript JSX | 193 | 23 | 22 | 238 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx) | TypeScript JSX | 289 | 36 | 31 | 356 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx) | TypeScript JSX | 500 | 75 | 89 | 664 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx) | TypeScript JSX | 89 | 12 | 16 | 117 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx) | TypeScript JSX | 204 | 26 | 33 | 263 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx) | TypeScript JSX | 93 | 13 | 18 | 124 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx) | TypeScript JSX | 219 | 39 | 47 | 305 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx) | TypeScript JSX | 1,060 | 228 | 229 | 1,517 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx) | TypeScript JSX | 20 | 6 | 2 | 28 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts) | TypeScript | 4 | 0 | 1 | 5 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts) | TypeScript | 16 | 4 | 4 | 24 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts) | TypeScript | 124 | 4 | 14 | 142 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts) | TypeScript | 21 | 15 | 5 | 41 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts) | TypeScript | 43 | 24 | 7 | 74 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js) | JavaScript | 28 | 7 | 9 | 44 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts) | TypeScript | 101 | 59 | 24 | 184 | + +[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/diff-details.md b/.VSCodeCounter/2025-03-17_14-20-03/diff-details.md new file mode 100644 index 0000000..2ced50c --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/diff-details.md @@ -0,0 +1,15 @@ +# Diff Details + +Date : 2025-03-17 14:20:03 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines + +[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | + +[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/diff.md b/.VSCodeCounter/2025-03-17_14-20-03/diff.md new file mode 100644 index 0000000..59bf091 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/diff.md @@ -0,0 +1,19 @@ +# Diff Summary + +Date : 2025-03-17 14:20:03 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines + +[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | + +[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/diff.txt b/.VSCodeCounter/2025-03-17_14-20-03/diff.txt new file mode 100644 index 0000000..cbf774f --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/diff.txt @@ -0,0 +1,22 @@ +Date : 2025-03-17 14:20:03 +Directory : /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew +Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines + +Languages ++----------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++----------+------------+------------+------------+------------+------------+ ++----------+------------+------------+------------+------------+------------+ + +Directories ++------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++------+------------+------------+------------+------------+------------+ ++------+------------+------------+------------+------------+------------+ + +Files ++----------+----------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++----------+----------+------------+------------+------------+------------+ +| Total | | 0 | 0 | 0 | 0 | ++----------+----------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/results.json b/.VSCodeCounter/2025-03-17_14-20-03/results.json new file mode 100644 index 0000000..049a4ba --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/results.json @@ -0,0 +1 @@ +{"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx":{"language":"TypeScript JSX","code":1060,"comment":228,"blank":229},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx":{"language":"TypeScript JSX","code":204,"comment":26,"blank":33},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx":{"language":"TypeScript JSX","code":89,"comment":12,"blank":16},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx":{"language":"TypeScript JSX","code":219,"comment":39,"blank":47},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx":{"language":"TypeScript JSX","code":93,"comment":13,"blank":18},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx":{"language":"TypeScript JSX","code":500,"comment":75,"blank":89},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx":{"language":"TypeScript JSX","code":193,"comment":4,"blank":15},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts":{"language":"TypeScript","code":4,"comment":0,"blank":1},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx":{"language":"TypeScript JSX","code":230,"comment":10,"blank":8},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx":{"language":"TypeScript JSX","code":374,"comment":42,"blank":44},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx":{"language":"TypeScript JSX","code":18,"comment":0,"blank":3},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx":{"language":"TypeScript JSX","code":1101,"comment":234,"blank":213},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx":{"language":"TypeScript JSX","code":499,"comment":48,"blank":54},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts":{"language":"TypeScript","code":43,"comment":24,"blank":7},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx":{"language":"TypeScript JSX","code":20,"comment":6,"blank":2},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx":{"language":"TypeScript JSX","code":83,"comment":0,"blank":4},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts":{"language":"TypeScript","code":124,"comment":4,"blank":14},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx":{"language":"TypeScript JSX","code":273,"comment":19,"blank":37},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js":{"language":"JavaScript","code":28,"comment":7,"blank":9},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts":{"language":"TypeScript","code":101,"comment":59,"blank":24},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts":{"language":"TypeScript","code":16,"comment":4,"blank":4},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts":{"language":"TypeScript","code":21,"comment":15,"blank":5},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx":{"language":"TypeScript JSX","code":193,"comment":23,"blank":22},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx":{"language":"TypeScript JSX","code":112,"comment":12,"blank":21},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx":{"language":"TypeScript JSX","code":407,"comment":56,"blank":52},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx":{"language":"TypeScript JSX","code":289,"comment":36,"blank":31},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx":{"language":"TypeScript JSX","code":232,"comment":31,"blank":32},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md":{"language":"Markdown","code":39,"comment":0,"blank":19}} \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/results.md b/.VSCodeCounter/2025-03-17_14-20-03/results.md new file mode 100644 index 0000000..33551f0 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/results.md @@ -0,0 +1,31 @@ +# Summary + +Date : 2025-03-17 14:20:03 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 28 files, 6565 codes, 1027 comments, 1053 blanks, all 8645 lines + +Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| TypeScript JSX | 20 | 6,189 | 914 | 970 | 8,073 | +| TypeScript | 6 | 309 | 106 | 55 | 470 | +| Markdown | 1 | 39 | 0 | 19 | 58 | +| JavaScript | 1 | 28 | 7 | 9 | 44 | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| . | 28 | 6,565 | 1,027 | 1,053 | 8,645 | +| . (Files) | 3 | 63 | 6 | 22 | 91 | +| components | 13 | 4,004 | 515 | 536 | 5,055 | +| components (Files) | 8 | 2,771 | 357 | 378 | 3,506 | +| components/cells | 5 | 1,233 | 158 | 158 | 1,549 | +| hooks | 6 | 2,165 | 393 | 432 | 2,990 | +| types | 1 | 16 | 4 | 4 | 24 | +| utils | 5 | 317 | 109 | 59 | 485 | + +Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_14-20-03/results.txt b/.VSCodeCounter/2025-03-17_14-20-03/results.txt new file mode 100644 index 0000000..43aae7c --- /dev/null +++ b/.VSCodeCounter/2025-03-17_14-20-03/results.txt @@ -0,0 +1,62 @@ +Date : 2025-03-17 14:20:03 +Directory : /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew +Total : 28 files, 6565 codes, 1027 comments, 1053 blanks, all 8645 lines + +Languages ++----------------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++----------------+------------+------------+------------+------------+------------+ +| TypeScript JSX | 20 | 6,189 | 914 | 970 | 8,073 | +| TypeScript | 6 | 309 | 106 | 55 | 470 | +| Markdown | 1 | 39 | 0 | 19 | 58 | +| JavaScript | 1 | 28 | 7 | 9 | 44 | ++----------------+------------+------------+------------+------------+------------+ + +Directories ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| . | 28 | 6,565 | 1,027 | 1,053 | 8,645 | +| . (Files) | 3 | 63 | 6 | 22 | 91 | +| components | 13 | 4,004 | 515 | 536 | 5,055 | +| components (Files) | 8 | 2,771 | 357 | 378 | 3,506 | +| components/cells | 5 | 1,233 | 158 | 158 | 1,549 | +| hooks | 6 | 2,165 | 393 | 432 | 2,990 | +| types | 1 | 16 | 4 | 4 | 24 | +| utils | 5 | 317 | 109 | 59 | 485 | ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ + +Files ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md | Markdown | 39 | 0 | 19 | 58 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx | TypeScript JSX | 230 | 10 | 8 | 248 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx | TypeScript JSX | 18 | 0 | 3 | 21 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx | TypeScript JSX | 83 | 0 | 4 | 87 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx | TypeScript JSX | 273 | 19 | 37 | 329 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx | TypeScript JSX | 193 | 4 | 15 | 212 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx | TypeScript JSX | 374 | 42 | 44 | 460 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx | TypeScript JSX | 1,101 | 234 | 213 | 1,548 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx | TypeScript JSX | 499 | 48 | 54 | 601 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx | TypeScript JSX | 112 | 12 | 21 | 145 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx | TypeScript JSX | 232 | 31 | 32 | 295 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx | TypeScript JSX | 407 | 56 | 52 | 515 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx | TypeScript JSX | 193 | 23 | 22 | 238 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx | TypeScript JSX | 289 | 36 | 31 | 356 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx | TypeScript JSX | 500 | 75 | 89 | 664 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx | TypeScript JSX | 89 | 12 | 16 | 117 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx | TypeScript JSX | 204 | 26 | 33 | 263 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx | TypeScript JSX | 93 | 13 | 18 | 124 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx | TypeScript JSX | 219 | 39 | 47 | 305 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx | TypeScript JSX | 1,060 | 228 | 229 | 1,517 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx | TypeScript JSX | 20 | 6 | 2 | 28 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts | TypeScript | 4 | 0 | 1 | 5 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts | TypeScript | 16 | 4 | 4 | 24 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts | TypeScript | 124 | 4 | 14 | 142 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts | TypeScript | 21 | 15 | 5 | 41 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts | TypeScript | 43 | 24 | 7 | 74 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js | JavaScript | 28 | 7 | 9 | 44 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts | TypeScript | 101 | 59 | 24 | 184 | +| Total | | 6,565 | 1,027 | 1,053 | 8,645 | ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/details.md b/.VSCodeCounter/2025-03-17_16-02-14/details.md new file mode 100644 index 0000000..e207cc1 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/details.md @@ -0,0 +1,43 @@ +# Details + +Date : 2025-03-17 16:02:14 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 28 files, 6551 codes, 1023 comments, 1050 blanks, all 8624 lines + +[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md) + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md) | Markdown | 39 | 0 | 19 | 58 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx) | TypeScript JSX | 230 | 10 | 8 | 248 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx) | TypeScript JSX | 18 | 0 | 3 | 21 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx) | TypeScript JSX | 83 | 0 | 4 | 87 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx) | TypeScript JSX | 273 | 19 | 37 | 329 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx) | TypeScript JSX | 193 | 4 | 15 | 212 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx) | TypeScript JSX | 374 | 42 | 44 | 460 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx) | TypeScript JSX | 971 | 194 | 178 | 1,343 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx) | TypeScript JSX | 499 | 48 | 54 | 601 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx) | TypeScript JSX | 112 | 12 | 21 | 145 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx) | TypeScript JSX | 232 | 31 | 32 | 295 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx) | TypeScript JSX | 407 | 56 | 52 | 515 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx) | TypeScript JSX | 193 | 23 | 22 | 238 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx) | TypeScript JSX | 289 | 36 | 31 | 356 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx) | TypeScript JSX | 500 | 75 | 89 | 664 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx) | TypeScript JSX | 89 | 12 | 16 | 117 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx) | TypeScript JSX | 204 | 26 | 33 | 263 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx) | TypeScript JSX | 209 | 49 | 50 | 308 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx) | TypeScript JSX | 219 | 39 | 47 | 305 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx) | TypeScript JSX | 1,060 | 228 | 229 | 1,517 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx) | TypeScript JSX | 20 | 6 | 2 | 28 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts) | TypeScript | 4 | 0 | 1 | 5 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts) | TypeScript | 16 | 4 | 4 | 24 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts) | TypeScript | 124 | 4 | 14 | 142 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts) | TypeScript | 21 | 15 | 5 | 41 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts) | TypeScript | 43 | 24 | 7 | 74 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js) | JavaScript | 28 | 7 | 9 | 44 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts) | TypeScript | 101 | 59 | 24 | 184 | + +[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/diff-details.md b/.VSCodeCounter/2025-03-17_16-02-14/diff-details.md new file mode 100644 index 0000000..860ac11 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/diff-details.md @@ -0,0 +1,17 @@ +# Diff Details + +Date : 2025-03-17 16:02:14 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 2 files, -14 codes, -4 comments, -3 blanks, all -21 lines + +[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx) | TypeScript JSX | -130 | -40 | -35 | -205 | +| [inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx](/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx) | TypeScript JSX | 116 | 36 | 32 | 184 | + +[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/diff.md b/.VSCodeCounter/2025-03-17_16-02-14/diff.md new file mode 100644 index 0000000..6fc807d --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/diff.md @@ -0,0 +1,23 @@ +# Diff Summary + +Date : 2025-03-17 16:02:14 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 2 files, -14 codes, -4 comments, -3 blanks, all -21 lines + +[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| TypeScript JSX | 2 | -14 | -4 | -3 | -21 | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| . | 2 | -14 | -4 | -3 | -21 | +| components | 1 | -130 | -40 | -35 | -205 | +| hooks | 1 | 116 | 36 | 32 | 184 | + +[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/diff.txt b/.VSCodeCounter/2025-03-17_16-02-14/diff.txt new file mode 100644 index 0000000..55f3458 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/diff.txt @@ -0,0 +1,28 @@ +Date : 2025-03-17 16:02:14 +Directory : /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew +Total : 2 files, -14 codes, -4 comments, -3 blanks, all -21 lines + +Languages ++----------------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++----------------+------------+------------+------------+------------+------------+ +| TypeScript JSX | 2 | -14 | -4 | -3 | -21 | ++----------------+------------+------------+------------+------------+------------+ + +Directories ++-------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++-------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| . | 2 | -14 | -4 | -3 | -21 | +| components | 1 | -130 | -40 | -35 | -205 | +| hooks | 1 | 116 | 36 | 32 | 184 | ++-------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ + +Files ++-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx | TypeScript JSX | -130 | -40 | -35 | -205 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx | TypeScript JSX | 116 | 36 | 32 | 184 | +| Total | | -14 | -4 | -3 | -21 | ++-------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/results.json b/.VSCodeCounter/2025-03-17_16-02-14/results.json new file mode 100644 index 0000000..53a1872 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/results.json @@ -0,0 +1 @@ +{"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx":{"language":"TypeScript JSX","code":1060,"comment":228,"blank":229},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx":{"language":"TypeScript JSX","code":89,"comment":12,"blank":16},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx":{"language":"TypeScript JSX","code":500,"comment":75,"blank":89},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx":{"language":"TypeScript JSX","code":204,"comment":26,"blank":33},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx":{"language":"TypeScript JSX","code":219,"comment":39,"blank":47},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx":{"language":"TypeScript JSX","code":209,"comment":49,"blank":50},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx":{"language":"TypeScript JSX","code":499,"comment":48,"blank":54},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx":{"language":"TypeScript JSX","code":374,"comment":42,"blank":44},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx":{"language":"TypeScript JSX","code":273,"comment":19,"blank":37},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx":{"language":"TypeScript JSX","code":971,"comment":194,"blank":178},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx":{"language":"TypeScript JSX","code":83,"comment":0,"blank":4},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx":{"language":"TypeScript JSX","code":18,"comment":0,"blank":3},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx":{"language":"TypeScript JSX","code":232,"comment":31,"blank":32},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx":{"language":"TypeScript JSX","code":112,"comment":12,"blank":21},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx":{"language":"TypeScript JSX","code":193,"comment":23,"blank":22},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx":{"language":"TypeScript JSX","code":289,"comment":36,"blank":31},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx":{"language":"TypeScript JSX","code":407,"comment":56,"blank":52},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx":{"language":"TypeScript JSX","code":193,"comment":4,"blank":15},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx":{"language":"TypeScript JSX","code":230,"comment":10,"blank":8},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts":{"language":"TypeScript","code":4,"comment":0,"blank":1},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md":{"language":"Markdown","code":39,"comment":0,"blank":19},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts":{"language":"TypeScript","code":43,"comment":24,"blank":7},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js":{"language":"JavaScript","code":28,"comment":7,"blank":9},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts":{"language":"TypeScript","code":101,"comment":59,"blank":24},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts":{"language":"TypeScript","code":21,"comment":15,"blank":5},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts":{"language":"TypeScript","code":124,"comment":4,"blank":14},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts":{"language":"TypeScript","code":16,"comment":4,"blank":4},"file:///Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx":{"language":"TypeScript JSX","code":20,"comment":6,"blank":2}} \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/results.md b/.VSCodeCounter/2025-03-17_16-02-14/results.md new file mode 100644 index 0000000..febef61 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/results.md @@ -0,0 +1,31 @@ +# Summary + +Date : 2025-03-17 16:02:14 + +Directory /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew + +Total : 28 files, 6551 codes, 1023 comments, 1050 blanks, all 8624 lines + +Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| TypeScript JSX | 20 | 6,175 | 910 | 967 | 8,052 | +| TypeScript | 6 | 309 | 106 | 55 | 470 | +| Markdown | 1 | 39 | 0 | 19 | 58 | +| JavaScript | 1 | 28 | 7 | 9 | 44 | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| . | 28 | 6,551 | 1,023 | 1,050 | 8,624 | +| . (Files) | 3 | 63 | 6 | 22 | 91 | +| components | 13 | 3,874 | 475 | 501 | 4,850 | +| components (Files) | 8 | 2,641 | 317 | 343 | 3,301 | +| components/cells | 5 | 1,233 | 158 | 158 | 1,549 | +| hooks | 6 | 2,281 | 429 | 464 | 3,174 | +| types | 1 | 16 | 4 | 4 | 24 | +| utils | 5 | 317 | 109 | 59 | 485 | + +Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2025-03-17_16-02-14/results.txt b/.VSCodeCounter/2025-03-17_16-02-14/results.txt new file mode 100644 index 0000000..7f4b6b0 --- /dev/null +++ b/.VSCodeCounter/2025-03-17_16-02-14/results.txt @@ -0,0 +1,62 @@ +Date : 2025-03-17 16:02:14 +Directory : /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew +Total : 28 files, 6551 codes, 1023 comments, 1050 blanks, all 8624 lines + +Languages ++----------------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++----------------+------------+------------+------------+------------+------------+ +| TypeScript JSX | 20 | 6,175 | 910 | 967 | 8,052 | +| TypeScript | 6 | 309 | 106 | 55 | 470 | +| Markdown | 1 | 39 | 0 | 19 | 58 | +| JavaScript | 1 | 28 | 7 | 9 | 44 | ++----------------+------------+------------+------------+------------+------------+ + +Directories ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| . | 28 | 6,551 | 1,023 | 1,050 | 8,624 | +| . (Files) | 3 | 63 | 6 | 22 | 91 | +| components | 13 | 3,874 | 475 | 501 | 4,850 | +| components (Files) | 8 | 2,641 | 317 | 343 | 3,301 | +| components/cells | 5 | 1,233 | 158 | 158 | 1,549 | +| hooks | 6 | 2,281 | 429 | 464 | 3,174 | +| types | 1 | 16 | 4 | 4 | 24 | +| utils | 5 | 317 | 109 | 59 | 485 | ++------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ + +Files ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/README.md | Markdown | 39 | 0 | 19 | 58 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/AiValidationDialogs.tsx | TypeScript JSX | 230 | 10 | 8 | 248 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/BaseCellContent.tsx | TypeScript JSX | 18 | 0 | 3 | 21 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SaveTemplateDialog.tsx | TypeScript JSX | 83 | 0 | 4 | 87 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx | TypeScript JSX | 273 | 19 | 37 | 329 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/TemplateManager.tsx | TypeScript JSX | 193 | 4 | 15 | 212 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationCell.tsx | TypeScript JSX | 374 | 42 | 44 | 460 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx | TypeScript JSX | 971 | 194 | 178 | 1,343 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationTable.tsx | TypeScript JSX | 499 | 48 | 54 | 601 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/CheckboxCell.tsx | TypeScript JSX | 112 | 12 | 21 | 145 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/InputCell.tsx | TypeScript JSX | 232 | 31 | 32 | 295 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx | TypeScript JSX | 407 | 56 | 52 | 515 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/MultilineInput.tsx | TypeScript JSX | 193 | 23 | 22 | 238 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/cells/SelectCell.tsx | TypeScript JSX | 289 | 36 | 31 | 356 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useAiValidation.tsx | TypeScript JSX | 500 | 75 | 89 | 664 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useFilters.tsx | TypeScript JSX | 89 | 12 | 16 | 117 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useTemplates.tsx | TypeScript JSX | 204 | 26 | 33 | 263 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx | TypeScript JSX | 209 | 49 | 50 | 308 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidation.tsx | TypeScript JSX | 219 | 39 | 47 | 305 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx | TypeScript JSX | 1,060 | 228 | 229 | 1,517 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/index.tsx | TypeScript JSX | 20 | 6 | 2 | 28 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types.ts | TypeScript | 4 | 0 | 1 | 5 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/types/index.ts | TypeScript | 16 | 4 | 4 | 24 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/dataMutations.ts | TypeScript | 124 | 4 | 14 | 142 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/errorUtils.ts | TypeScript | 21 | 15 | 5 | 41 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/upcValidation.ts | TypeScript | 43 | 24 | 7 | 74 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validation-helper.js | JavaScript | 28 | 7 | 9 | 44 | +| /Users/matt/Dev/inventory/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/utils/validationUtils.ts | TypeScript | 101 | 59 | 24 | 184 | +| Total | | 6,551 | 1,023 | 1,050 | 8,624 | ++------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx index b1f7d11..d28fc78 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx @@ -15,6 +15,7 @@ import { SearchProductTemplateDialog } from '@/components/templates/SearchProduc import { TemplateForm } from '@/components/templates/TemplateForm' import axios from 'axios' import { RowSelectionState } from '@tanstack/react-table' +import { useUpcValidation } from '../hooks/useUpcValidation' /** * ValidationContainer component - the main wrapper for the validation step @@ -72,50 +73,17 @@ const ValidationContainer = ({ const [companyLinesCache, setCompanyLinesCache] = useState>({}); const [lineSublineCache, setLineSublineCache] = useState>({}); - // Add UPC validation state - const [, setIsValidatingUpc] = useState(false); - const [validatingUpcRows, setValidatingUpcRows] = useState>(new Set()); - // Add state for tracking cells in loading state const [validatingCells, setValidatingCells] = useState>(new Set()); - // Store item numbers in a separate state to avoid updating the main data - const [itemNumbers, setItemNumbers] = useState>({}); - - // Cache for UPC validation results - const processedUpcMapRef = useRef(new Map()); - const initialUpcValidationDoneRef = useRef(false); + // Use UPC validation hook + const upcValidation = useUpcValidation(data, setData); // Function to check if a specific row is being validated - memoized - const isRowValidatingUpc = useCallback((rowIndex: number): boolean => { - return validatingUpcRows.has(rowIndex); - }, [validatingUpcRows]); + const isRowValidatingUpc = upcValidation.isRowValidatingUpc; // Apply all pending updates to the data state - const applyItemNumbersToData = useCallback(() => { - if (Object.keys(itemNumbers).length === 0) return; - - setData(prevData => { - const newData = [...prevData]; - - // Apply all item numbers without changing other data - Object.entries(itemNumbers).forEach(([indexStr, itemNumber]) => { - const index = parseInt(indexStr); - if (index >= 0 && index < newData.length) { - // Only update the item_number field and leave everything else unchanged - newData[index] = { - ...newData[index], - item_number: itemNumber - }; - } - }); - - return newData; - }); - - // Clear the item numbers state after applying - setItemNumbers({}); - }, [setData, itemNumbers]); + const applyItemNumbersToData = upcValidation.applyItemNumbersToData; // Function to fetch product lines for a specific company - memoized const fetchProductLines = useCallback(async (rowIndex: string | number, companyId: string) => { @@ -223,170 +191,6 @@ const ValidationContainer = ({ } }, [lineSublineCache]); - // Function to validate UPC with the API - memoized - const validateUpc = useCallback(async (rowIndex: number, supplierId: string, upcValue: string): Promise<{ success: boolean, itemNumber?: string }> => { - try { - // Skip if either value is missing - if (!supplierId || !upcValue) { - return { success: false }; - } - - // Add logging to help debug - console.log(`Validating UPC for row ${rowIndex}. Supplier ID: ${supplierId}, UPC: ${upcValue}`); - - // Check if we've already validated this UPC/supplier combination - const cacheKey = `${supplierId}-${upcValue}`; - if (processedUpcMapRef.current.has(cacheKey)) { - const cachedItemNumber = processedUpcMapRef.current.get(cacheKey); - - if (cachedItemNumber) { - // Just update the item numbers state, not the main data - setItemNumbers(prev => ({ - ...prev, - [rowIndex]: cachedItemNumber - })); - - return { success: true, itemNumber: cachedItemNumber }; - } - - return { success: false }; - } - - // Make API call to validate UPC - ensure we're using supplierId (not company) - const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`); - - // Process the response - if (response.status === 409) { - // UPC already exists - show validation error - - // We need to trigger validation for this row to update the validation errors - // This will update the validationErrors Map in useValidationState - const row = data[rowIndex]; - if (row) { - // Update the UPC field to trigger validation - updateRow(rowIndex, 'upc' as T, row.upc); - - // We also need to manually add the error to the validation errors - // But we don't have direct access to setValidationErrors - // So we'll use a workaround by updating the row data - setData(prevData => { - const newData = [...prevData]; - // We're only updating the row to trigger validation - // The actual error will be handled by the validation system - return newData; - }); - } - - return { success: false }; - } else if (response.ok) { - // Successful validation - update item number - const responseData = await response.json(); - - if (responseData.success && responseData.itemNumber) { - // Store in cache - processedUpcMapRef.current.set(cacheKey, responseData.itemNumber); - - // Update the item numbers state, not the main data - setItemNumbers(prev => ({ - ...prev, - [rowIndex]: responseData.itemNumber - })); - - // Clear any UPC errors by triggering validation - const row = data[rowIndex]; - if (row) { - // Update the UPC field to trigger validation - updateRow(rowIndex, 'upc' as T, row.upc); - } - - return { success: true, itemNumber: responseData.itemNumber }; - } - } - - return { success: false }; - } catch (error) { - console.error(`Error validating UPC for row ${rowIndex}:`, error); - return { success: false }; - } - }, [data, updateRow, setData]); - - // Apply item numbers when they're available - useEffect(() => { - // Apply item numbers immediately if there are any - if (Object.keys(itemNumbers).length > 0) { - applyItemNumbersToData(); - } - }, [itemNumbers, applyItemNumbersToData]); - - // Optimized batch validation function - memoized - const validateAllUPCs = useCallback(async () => { - // Skip if we've already done the initial validation - if (initialUpcValidationDoneRef.current) { - return; - } - - // Mark that we've done the initial validation - initialUpcValidationDoneRef.current = true; - - console.log('Starting UPC validation...'); - - // Set validation state - setIsValidatingUpc(true); - - // Find all rows that have both supplier and UPC/barcode - const rowsToValidate = data - .map((row, index) => ({ row, index })) - .filter(({ row }) => { - const rowAny = row as Record; - const hasSupplier = rowAny.supplier; - const hasUpc = rowAny.upc || rowAny.barcode; - return hasSupplier && hasUpc; - }); - - const totalRows = rowsToValidate.length; - console.log(`Found ${totalRows} rows with both supplier and UPC`); - - if (totalRows === 0) { - setIsValidatingUpc(false); - return; - } - - // Mark all rows as being validated - setValidatingUpcRows(new Set(rowsToValidate.map(({ index }) => index))); - - try { - // Process all rows in parallel without batching - await Promise.all( - rowsToValidate.map(async ({ row, index }) => { - try { - const rowAny = row as Record; - const supplierId = rowAny.supplier.toString(); - const upcValue = (rowAny.upc || rowAny.barcode).toString(); - - // Validate the UPC - await validateUpc(index, supplierId, upcValue); - - // Remove this row from the validating set - setValidatingUpcRows(prev => { - const newSet = new Set(prev); - newSet.delete(index); - return newSet; - }); - } catch (error) { - console.error(`Error processing row ${index}:`, error); - } - }) - ); - } catch (error) { - console.error('Error in validation:', error); - } finally { - // Reset validation state - setIsValidatingUpc(false); - setValidatingUpcRows(new Set()); - console.log('Completed UPC validation'); - } - }, [data, validateUpc]); - // Enhanced updateRow function - memoized const enhancedUpdateRow = useCallback(async (rowIndex: number, fieldKey: T, value: any) => { // Process value before updating data @@ -478,30 +282,23 @@ const ValidationContainer = ({ if (rowDataAny.upc || rowDataAny.barcode) { const upcValue = rowDataAny.upc || rowDataAny.barcode; - // Run UPC validation immediately without timeout try { - // Mark this row as being validated - setValidatingUpcRows(prev => { + // Mark the item_number cell as being validated + setValidatingCells(prev => { const newSet = new Set(prev); - newSet.add(rowIndex); + newSet.add(`${rowIndex}-item_number`); return newSet; }); - // Set global validation state - setIsValidatingUpc(true); - // Use supplier ID (the value being set) to validate UPC - await validateUpc(rowIndex, value.toString(), upcValue.toString()); + await upcValidation.validateUpc(rowIndex, value.toString(), upcValue.toString()); } catch (error) { console.error('Error validating UPC:', error); } finally { - // Always clean up validation state, even if there was an error - setValidatingUpcRows(prev => { + // Clear validation state for the item_number cell + setValidatingCells(prev => { const newSet = new Set(prev); - newSet.delete(rowIndex); - if (newSet.size === 0) { - setIsValidatingUpc(false); - } + newSet.delete(`${rowIndex}-item_number`); return newSet; }); } @@ -547,36 +344,29 @@ const ValidationContainer = ({ if ((fieldKey === 'upc' || fieldKey === 'barcode') && value && rowData) { const rowDataAny = rowData as Record; if (rowDataAny.supplier) { - // Run UPC validation immediately without timeout try { - // Mark this row as being validated - setValidatingUpcRows(prev => { + // Mark the item_number cell as being validated + setValidatingCells(prev => { const newSet = new Set(prev); - newSet.add(rowIndex); + newSet.add(`${rowIndex}-item_number`); return newSet; }); - // Set global validation state - setIsValidatingUpc(true); - - // Use supplier ID from the row data (NOT company ID) to validate UPC - await validateUpc(rowIndex, rowDataAny.supplier.toString(), value.toString()); + // Use supplier ID from the row data to validate UPC + await upcValidation.validateUpc(rowIndex, rowDataAny.supplier.toString(), value.toString()); } catch (error) { console.error('Error validating UPC:', error); } finally { - // Always clean up validation state, even if there was an error - setValidatingUpcRows(prev => { + // Clear validation state for the item_number cell + setValidatingCells(prev => { const newSet = new Set(prev); - newSet.delete(rowIndex); - if (newSet.size === 0) { - setIsValidatingUpc(false); - } + newSet.delete(`${rowIndex}-item_number`); return newSet; }); } } } - }, [data, filteredData, updateRow, fetchProductLines, fetchSublines, validateUpc, setData, companyLinesCache, lineSublineCache]); + }, [data, filteredData, updateRow, fetchProductLines, fetchSublines, setData, companyLinesCache, lineSublineCache, upcValidation]); // When data changes, fetch product lines and sublines for rows that have company/line values useEffect(() => { @@ -834,16 +624,16 @@ const ValidationContainer = ({ }, [data, rowProductLines, rowSublines, companyLinesCache, lineSublineCache]); - // Validate UPCs on initial data load + // Use UPC validation when data changes useEffect(() => { - // Skip if there's no data or we've already done the validation - if (data.length === 0 || initialUpcValidationDoneRef.current) return; + // Skip if there's no data or already validated + if (data.length === 0 || upcValidation.initialValidationDone) return; // Run validation immediately without timeout - validateAllUPCs(); + upcValidation.validateAllUPCs(); // No cleanup needed since we're not using a timer - }, [data, validateAllUPCs]); + }, [data, upcValidation]); // Use AI validation hook const aiValidation = useAiValidation( @@ -1013,11 +803,11 @@ const ValidationContainer = ({ // Handle next button click - memoized const handleNext = useCallback(() => { // Make sure any pending item numbers are applied - applyItemNumbersToData(); + upcValidation.applyItemNumbersToData(); // Call the onNext callback with the validated data onNext?.(data) - }, [onNext, data, applyItemNumbersToData]); + }, [onNext, data, upcValidation.applyItemNumbersToData]); const deleteSelectedRows = useCallback(() => { // Get selected row keys (which may be UUIDs) @@ -1146,12 +936,12 @@ const ValidationContainer = ({ // Memoize the enhanced validation table component const EnhancedValidationTable = useMemo(() => React.memo((props: React.ComponentProps) => { - // Create validatingCells set from validatingUpcRows, but only for item_number fields + // Create validatingCells set from validating rows, but only for item_number fields // This ensures only the item_number column shows loading state during UPC validation const combinedValidatingCells = new Set(); // Add UPC validation cells - validatingUpcRows.forEach(rowIndex => { + upcValidation.validatingRows.forEach(rowIndex => { // Only mark the item_number cells as validating, NOT the UPC or supplier combinedValidatingCells.add(`${rowIndex}-item_number`); }); @@ -1161,15 +951,20 @@ const ValidationContainer = ({ combinedValidatingCells.add(cellKey); }); - // Convert itemNumbers to Map - const itemNumbersMap = new Map(Object.entries(itemNumbers).map(([key, value]) => [parseInt(key), value])); - + // Convert the Map to the expected format for the ValidationTable + // Create a new Map from the item numbers to ensure proper typing + const itemNumbersMap = new Map(); + // Merge the item numbers with the data for display purposes only const enhancedData = props.data.map((row: any, index: number) => { - if (itemNumbers[index]) { + const itemNumber = upcValidation.getItemNumber(index); + if (itemNumber) { + // Add to our map for proper prop passing + itemNumbersMap.set(index, itemNumber); + return { ...row, - item_number: itemNumbers[index] + item_number: itemNumber }; } return row; @@ -1189,7 +984,7 @@ const ValidationContainer = ({ isLoadingSublines={isLoadingSublines} /> ); - }), [validatingUpcRows, itemNumbers, isLoadingTemplates, handleCopyDown, validatingCells, rowProductLines, rowSublines, isLoadingLines, isLoadingSublines]); + }), [upcValidation.validatingRows, upcValidation.getItemNumber, isLoadingTemplates, handleCopyDown, validatingCells, rowProductLines, rowSublines, isLoadingLines, isLoadingSublines]); // Memoize the rendered validation table const renderValidationTable = useMemo(() => ( @@ -1201,7 +996,7 @@ const ValidationContainer = ({ updateRow={handleUpdateRow as (rowIndex: number, key: string, value: any) => void} validationErrors={validationErrors} isValidatingUpc={isRowValidatingUpc} - validatingUpcRows={Array.from(validatingUpcRows)} + validatingUpcRows={Array.from(upcValidation.validatingRows)} filters={filters} templates={templates} applyTemplate={applyTemplate} @@ -1225,7 +1020,7 @@ const ValidationContainer = ({ handleUpdateRow, validationErrors, isRowValidatingUpc, - validatingUpcRows, + upcValidation.validatingRows, filters, templates, applyTemplate, diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx index 9385d76..4e5a472 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx @@ -1,5 +1,6 @@ -import { useState, useCallback, useRef } from 'react' +import { useState, useCallback, useRef, useEffect } from 'react' import config from '@/config' +import { toast } from 'sonner' interface UpcValidationResult { error?: boolean @@ -10,18 +11,29 @@ interface UpcValidationResult { interface ValidationState { validatingCells: Set; // Using rowIndex-fieldKey as identifier itemNumbers: Map; // Using rowIndex as key + validatingRows: Set; // Rows currently being validated } -export const useUpcValidation = () => { +export const useUpcValidation = ( + data: any[], + setData: (updater: any[] | ((prevData: any[]) => any[])) => void +) => { // Use a ref for validation state to avoid triggering re-renders const validationStateRef = useRef({ validatingCells: new Set(), - itemNumbers: new Map() + itemNumbers: new Map(), + validatingRows: new Set() }); // Use state only for forcing re-renders of specific cells const [validatingCellKeys, setValidatingCellKeys] = useState>(new Set()); const [itemNumberUpdates, setItemNumberUpdates] = useState>(new Map()); + const [validatingRows, setValidatingRows] = useState>(new Set()); + const [isValidatingUpc, setIsValidatingUpc] = useState(false); + + // Cache for UPC validation results + const processedUpcMapRef = useRef(new Map()); + const initialUpcValidationDoneRef = useRef(false); // Helper to create cell key const getCellKey = (rowIndex: number, fieldKey: string) => `${rowIndex}-${fieldKey}`; @@ -46,79 +58,251 @@ export const useUpcValidation = () => { setItemNumberUpdates(new Map(validationStateRef.current.itemNumbers)); }, []); + // Mark a row as being validated + const startValidatingRow = useCallback((rowIndex: number) => { + validationStateRef.current.validatingRows.add(rowIndex); + setValidatingRows(new Set(validationStateRef.current.validatingRows)); + }, []); + + // Mark a row as no longer being validated + const stopValidatingRow = useCallback((rowIndex: number) => { + validationStateRef.current.validatingRows.delete(rowIndex); + setValidatingRows(new Set(validationStateRef.current.validatingRows)); + + // If no more rows are being validated, set global validation state to false + if (validationStateRef.current.validatingRows.size === 0) { + setIsValidatingUpc(false); + } + }, []); + // Check if a specific cell is being validated const isValidatingCell = useCallback((rowIndex: number, fieldKey: string): boolean => { return validationStateRef.current.validatingCells.has(getCellKey(rowIndex, fieldKey)); }, []); + // Check if a specific row is being validated + const isRowValidatingUpc = useCallback((rowIndex: number): boolean => { + return validationStateRef.current.validatingRows.has(rowIndex); + }, []); + // Get item number for a row const getItemNumber = useCallback((rowIndex: number): string | undefined => { return validationStateRef.current.itemNumbers.get(rowIndex); }, []); + // Apply all pending updates to the data state + const applyItemNumbersToData = useCallback(() => { + if (validationStateRef.current.itemNumbers.size === 0) return; + + setData((prevData: any[]) => { + const newData = [...prevData]; + + // Apply all item numbers without changing other data + Array.from(validationStateRef.current.itemNumbers.entries()).forEach(([index, itemNumber]) => { + if (index >= 0 && index < newData.length) { + // Only update the item_number field and leave everything else unchanged + newData[index] = { + ...newData[index], + item_number: itemNumber + }; + } + }); + + return newData; + }); + + // Clear the item numbers state after applying + validationStateRef.current.itemNumbers.clear(); + setItemNumberUpdates(new Map()); + }, [setData]); + // Validate a UPC value const validateUpc = useCallback(async ( - upcValue: string, rowIndex: number, - supplier: string - ): Promise => { - // Start validating UPC and item number cells - startValidatingCell(rowIndex, 'upc'); - startValidatingCell(rowIndex, 'item_number'); - + supplierId: string, + upcValue: string + ): Promise<{success: boolean, itemNumber?: string}> => { try { - // Call the UPC validation API - const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplier)}`); + // Skip if either value is missing + if (!supplierId || !upcValue) { + return { success: false }; + } + // Add logging to help debug + console.log(`Validating UPC for row ${rowIndex}. Supplier ID: ${supplierId}, UPC: ${upcValue}`); + + // Start validating both UPC and item_number cells + startValidatingCell(rowIndex, 'upc'); + startValidatingCell(rowIndex, 'item_number'); + + // Also mark the row as being validated + startValidatingRow(rowIndex); + + // Check if we've already validated this UPC/supplier combination + const cacheKey = `${supplierId}-${upcValue}`; + if (processedUpcMapRef.current.has(cacheKey)) { + const cachedItemNumber = processedUpcMapRef.current.get(cacheKey); + + if (cachedItemNumber) { + // Use cached item number + updateItemNumber(rowIndex, cachedItemNumber); + return { success: true, itemNumber: cachedItemNumber }; + } + + return { success: false }; + } + + // Make API call to validate UPC + const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`); + + // Process the response if (response.status === 409) { + // UPC already exists - show validation error const errorData = await response.json(); - return { - error: true, - message: `UPC already exists (${errorData.existingItemNumber})`, - data: errorData - }; + return { success: false }; + } else if (response.ok) { + // Successful validation - update item number + const responseData = await response.json(); + + if (responseData.success && responseData.itemNumber) { + // Store in cache + processedUpcMapRef.current.set(cacheKey, responseData.itemNumber); + + // Update the item numbers state + updateItemNumber(rowIndex, responseData.itemNumber); + + return { success: true, itemNumber: responseData.itemNumber }; + } } - if (!response.ok) { - throw new Error(`API error (${response.status})`); - } - - const result = await response.json(); - - if (result.success && result.itemNumber) { - // Update item number in our state - updateItemNumber(rowIndex, result.itemNumber); - return { - error: false, - data: { - itemNumber: result.itemNumber, - ...result - } - }; - } - - return { - error: true, - message: 'Invalid response from server' - }; + return { success: false }; } catch (error) { - console.error('Error validating UPC:', error); - return { - error: true, - message: 'Failed to validate UPC' - }; + console.error(`Error validating UPC for row ${rowIndex}:`, error); + return { success: false }; } finally { - // Stop validating both cells + // Clear validation state stopValidatingCell(rowIndex, 'upc'); stopValidatingCell(rowIndex, 'item_number'); + stopValidatingRow(rowIndex); } - }, [startValidatingCell, stopValidatingCell, updateItemNumber]); + }, [startValidatingCell, stopValidatingCell, updateItemNumber, startValidatingRow, stopValidatingRow]); + + // Batch validate all UPCs in the data + const validateAllUPCs = useCallback(async () => { + // Skip if we've already done the initial validation + if (initialUpcValidationDoneRef.current) { + return; + } + + // Mark that we've done the initial validation + initialUpcValidationDoneRef.current = true; + + console.log('Starting UPC validation...'); + + // Set validation state + setIsValidatingUpc(true); + + // Find all rows that have both supplier and UPC/barcode + const rowsToValidate = data + .map((row, index) => ({ row, index })) + .filter(({ row }) => { + const rowAny = row as Record; + const hasSupplier = rowAny.supplier; + const hasUpc = rowAny.upc || rowAny.barcode; + return hasSupplier && hasUpc; + }); + + const totalRows = rowsToValidate.length; + console.log(`Found ${totalRows} rows with both supplier and UPC`); + + if (totalRows === 0) { + setIsValidatingUpc(false); + return; + } + + // Mark all rows as being validated + const newValidatingRows = new Set(rowsToValidate.map(({ index }) => index)); + validationStateRef.current.validatingRows = newValidatingRows; + setValidatingRows(newValidatingRows); + + try { + // Process all rows in parallel + await Promise.all( + rowsToValidate.map(async ({ row, index }) => { + try { + const rowAny = row as Record; + const supplierId = rowAny.supplier.toString(); + const upcValue = (rowAny.upc || rowAny.barcode).toString(); + + // Validate the UPC + await validateUpc(index, supplierId, upcValue); + + // Remove this row from the validating set (handled in validateUpc) + } catch (error) { + console.error(`Error processing row ${index}:`, error); + stopValidatingRow(index); + } + }) + ); + } catch (error) { + console.error('Error in batch validation:', error); + } finally { + // Reset validation state + setIsValidatingUpc(false); + validationStateRef.current.validatingRows.clear(); + setValidatingRows(new Set()); + console.log('Completed UPC validation'); + + // Apply item numbers to data + applyItemNumbersToData(); + } + }, [data, validateUpc, stopValidatingRow, applyItemNumbersToData]); + + // Run initial UPC validation when data changes + useEffect(() => { + // Skip if there's no data or we've already done the validation + if (data.length === 0 || initialUpcValidationDoneRef.current) return; + + // Run validation + validateAllUPCs(); + }, [data, validateAllUPCs]); + + // Apply item numbers when they change + useEffect(() => { + // Apply item numbers if there are any + if (validationStateRef.current.itemNumbers.size > 0) { + applyItemNumbersToData(); + } + }, [itemNumberUpdates, applyItemNumbersToData]); + + // Reset validation state when hook is unmounted + useEffect(() => { + return () => { + initialUpcValidationDoneRef.current = false; + processedUpcMapRef.current.clear(); + validationStateRef.current.validatingCells.clear(); + validationStateRef.current.itemNumbers.clear(); + validationStateRef.current.validatingRows.clear(); + }; + }, []); return { validateUpc, + validateAllUPCs, isValidatingCell, + isRowValidatingUpc, + isValidatingUpc, getItemNumber, + applyItemNumbersToData, itemNumbers: itemNumberUpdates, - validatingCells: validatingCellKeys + validatingCells: validatingCellKeys, + validatingRows, + resetInitialValidation: () => { + initialUpcValidationDoneRef.current = false; + }, + // Export the ref for direct access + get initialValidationDone() { + return initialUpcValidationDoneRef.current; + } } } \ No newline at end of file