fuse-importer 0.0.8-testing → 0.0.9-testing
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Importer/ImporterWithContext.js +63 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/index.js +68 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcher/tableColumns.js +58 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/EnumFieldMatcherContext.js +21 -0
- package/lib/esm/Importer/Matcher/EnumFieldsMatchers/index.js +23 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/index.js +61 -0
- package/lib/esm/Importer/Matcher/HeaderMatcher/tableColumns.js +55 -0
- package/lib/esm/Importer/Matcher/common/icons/index.js +14 -0
- package/lib/esm/Importer/Matcher/common/index.js +39 -0
- package/lib/esm/Importer/Matcher/common/types.js +9 -0
- package/lib/esm/Importer/Matcher/index.js +22 -0
- package/lib/esm/Importer/PreviewFirstTime.js +81 -0
- package/lib/esm/Importer/PreviewModeBanner.js +19 -0
- package/lib/esm/Importer/Review/AppResponseModal.js +35 -0
- package/lib/esm/Importer/Review/ReviewContextProvider.js +315 -0
- package/lib/esm/Importer/Review/ReviewWithContext.js +33 -0
- package/lib/esm/Importer/Review/index.js +4 -0
- package/lib/esm/Importer/Stepper/ConfirmCloseModal.js +24 -0
- package/lib/esm/Importer/Stepper/Step.js +19 -0
- package/lib/esm/Importer/Stepper/StepIndex.js +27 -0
- package/lib/esm/Importer/Stepper/StepperSubmitModal.js +24 -0
- package/lib/esm/Importer/Stepper/UnmatchedHeadersModal.js +31 -0
- package/lib/esm/Importer/Stepper/common/getEnumFieldValueMatchingsInitialValue.js +33 -0
- package/lib/esm/Importer/Stepper/common/icons.js +18 -0
- package/lib/esm/Importer/Stepper/index.js +118 -0
- package/lib/esm/Importer/TrialModeBanner.js +22 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/DragAndDropImporter.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterDropzone.js +123 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/ImporterSectionHeader.styles.js +11 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/ImporterSectionHeader/index.js +44 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/backgrounds.js +14 -0
- package/lib/esm/Importer/Uploader/DragAndDropImporter/index.js +45 -0
- package/lib/esm/Importer/Uploader/HeaderButtons.js +28 -0
- package/lib/esm/Importer/Uploader/HeadersPreview.js +44 -0
- package/lib/esm/Importer/Uploader/UploaderContextProvider.js +27 -0
- package/lib/esm/Importer/Uploader/index.js +13 -0
- package/lib/esm/Importer/common/AppLoading.js +24 -0
- package/lib/esm/Importer/common/Footer.js +17 -0
- package/lib/esm/Importer/common/FuseApi.js +48 -0
- package/lib/esm/Importer/common/GlobalStyle.js +7 -0
- package/lib/esm/Importer/common/ImporterFonts.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/filterMethods.js +56 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/index.js +176 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/useSpreadsheetFilter.js +45 -0
- package/lib/esm/Importer/common/Spreadsheet/SpreadsheetContextProvider/utils.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/common/index.js +63 -0
- package/lib/esm/Importer/common/Spreadsheet/common/types.js +5 -0
- package/lib/esm/Importer/common/Spreadsheet/components/FieldHeader.js +66 -0
- package/lib/esm/Importer/common/Spreadsheet/components/GlobalStyle.js +9 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetData.js +110 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowCheckboxes.js +186 -0
- package/lib/esm/Importer/common/Spreadsheet/components/SpreadsheetRowNumbers.js +55 -0
- package/lib/esm/Importer/common/Spreadsheet/components/ValidationProgress.js +19 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpeadsheetAutocomplete.js +43 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/SpreadsheetInput.js +70 -0
- package/lib/esm/Importer/common/Spreadsheet/components/fields/index.js +108 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/Boolean.js +18 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EmailInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/EnumInput.js +30 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/FloatInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/IntegerInput.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/StringInput.js +14 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.d.ts +1 -0
- package/lib/esm/Importer/common/Spreadsheet/components/inputs/index.js +20 -0
- package/lib/esm/Importer/common/Spreadsheet/hooks.js +245 -0
- package/lib/esm/Importer/common/Spreadsheet/index.js +119 -0
- package/lib/esm/Importer/common/Spreadsheet/styles.js +16 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/index.js +47 -0
- package/lib/esm/Importer/common/Spreadsheet/transformation/transformators.js +204 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/index.js +202 -0
- package/lib/esm/Importer/common/Spreadsheet/validation/validators.js +181 -0
- package/lib/esm/Importer/common/icons/index.js +18 -0
- package/lib/esm/Importer/common/index.js +13 -0
- package/lib/esm/Importer/common/theme.js +19 -0
- package/lib/esm/Importer/common/utils.js +100 -0
- package/lib/esm/Importer/contexts/ImporterContextProvider.js +247 -0
- package/lib/esm/Importer/data/index.js +152 -0
- package/lib/esm/Importer/index.js +28 -0
- package/lib/esm/api/index.js +93 -0
- package/lib/esm/api/responseHandlers.js +49 -0
- package/lib/esm/common/AppLoadingContextProvider/AppLoadingUI.js +26 -0
- package/lib/esm/common/AppLoadingContextProvider/index.js +25 -0
- package/lib/esm/common/ConfirmationModal.js +19 -0
- package/lib/esm/common/Modal.js +31 -0
- package/lib/esm/common/Spinner.js +41 -0
- package/lib/esm/common/Table/Pagination/icons.js +42 -0
- package/lib/esm/common/Table/Pagination/index.js +32 -0
- package/lib/esm/common/Table/TableActions/DeleteSelectedRows.js +50 -0
- package/lib/esm/common/Table/TableActions/ExportData.js +23 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.js +47 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/FilterByErrors.styles.js +24 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/functions.js +35 -0
- package/lib/esm/common/Table/TableActions/FilterByErrors/index.js +1 -0
- package/lib/esm/common/Table/TableActions/RowFilters.js +42 -0
- package/lib/esm/common/Table/TableActions/SearchRows.js +72 -0
- package/lib/esm/common/Table/TableActions/TableActions.js +35 -0
- package/lib/esm/common/Table/TableActions/TableActions.styles.js +18 -0
- package/lib/esm/common/Table/TableActions/TransformedRecordsCount.js +71 -0
- package/lib/esm/common/Table/TableActions/common.js +1 -0
- package/lib/esm/common/Table/TableActions/hooks.js +41 -0
- package/lib/esm/common/Table/TableActions/icons.js +17 -0
- package/lib/esm/common/Table/TableActions/index.js +1 -0
- package/lib/esm/common/Table/TableDataProvider.js +127 -0
- package/lib/esm/common/Table/TableView/TableHeaders.js +69 -0
- package/lib/esm/common/Table/TableView/TableRows/TableRow.js +57 -0
- package/lib/esm/common/Table/TableView/TableRows/index.js +48 -0
- package/lib/esm/common/Table/TableView/common/index.js +37 -0
- package/lib/esm/common/Table/TableView/index.js +132 -0
- package/lib/esm/common/Table/TableView/types.js +1 -0
- package/lib/esm/common/Table/icons.js +15 -0
- package/lib/esm/common/Table/index.js +140 -0
- package/lib/esm/common/Table/useReorderRows.js +83 -0
- package/lib/esm/common/Toast.js +69 -0
- package/lib/esm/common/TooltipProvider.js +57 -0
- package/lib/esm/common/buttons.js +97 -0
- package/lib/esm/common/columnsTransformations.js +94 -0
- package/lib/esm/common/columnsValidations.d.ts +1 -1
- package/lib/esm/common/columnsValidations.js +687 -0
- package/lib/esm/common/icons/index.js +30 -0
- package/lib/esm/common/index.js +45 -0
- package/lib/esm/common/inputs/Autocomplete.js +110 -0
- package/lib/esm/common/inputs/Checkbox.js +53 -0
- package/lib/esm/common/inputs/SelectMenu.js +67 -0
- package/lib/esm/common/inputs/TextInput.js +89 -0
- package/lib/esm/common/inputs/index.js +5 -0
- package/lib/esm/common/inputs/tooltip.js +38 -0
- package/lib/esm/common/logo.js +13 -0
- package/lib/esm/hooks/index.d.ts +1 -0
- package/lib/esm/hooks/index.js +16 -0
- package/lib/esm/index.js +218 -0
- package/lib/esm/locales/de.js +126 -0
- package/lib/esm/locales/en.js +126 -0
- package/lib/esm/locales/es.js +126 -0
- package/lib/esm/locales/fr.js +126 -0
- package/lib/esm/locales/index.js +4 -0
- package/lib/esm/styled/fontsURL.js +27 -0
- package/lib/esm/styled/index.js +3 -0
- package/lib/esm/styled/theme/animations.js +9 -0
- package/lib/esm/styled/theme/colorPalette.js +109 -0
- package/lib/esm/styled/theme/debugCss.js +16 -0
- package/lib/esm/styled/theme/dimensionsCss.js +20 -0
- package/lib/esm/styled/theme/fontCss.js +17 -0
- package/lib/esm/styled/theme/globalCss.js +26 -0
- package/lib/esm/styled/theme/index.js +33 -0
- package/lib/esm/styled/theme/layoutCss.js +26 -0
- package/lib/esm/styled/theme/mediaQueries.js +4 -0
- package/lib/esm/styled/theme/positionCss.js +27 -0
- package/lib/esm/styled/theme/textCss.js +18 -0
- package/lib/esm/styled/theme/textStyles.js +27 -0
- package/lib/esm/styled/themeType.js +6 -0
- package/lib/esm/styled/utils.js +17 -0
- package/lib/esm/types.d.ts +2 -2
- package/lib/esm/types.js +65 -0
- package/lib/esm/utils/hooks/useWindowSize.js +23 -0
- package/lib/esm/utils/hooks.js +1 -0
- package/lib/esm/utils/index.js +37 -0
- package/lib/main.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
59
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
+
if (ar || !(i in from)) {
|
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
+
ar[i] = from[i];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
+
};
|
|
68
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
69
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
70
|
+
import Papa from "papaparse";
|
|
71
|
+
import { AppLoading } from "../common/AppLoading";
|
|
72
|
+
import { isRecordEmpty } from "../common/Spreadsheet/common";
|
|
73
|
+
import { sendRecordsToIntegrations } from "../common/utils";
|
|
74
|
+
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
75
|
+
import { transformToRecords } from "../data/index";
|
|
76
|
+
import { getPreviewDataSet, getReviewDataSet, getTemplateFields, recordListToDataSet, } from "../data";
|
|
77
|
+
import { useAppLoadingContext } from "../../common/AppLoadingContextProvider";
|
|
78
|
+
var ReviewContext = createContext({});
|
|
79
|
+
var trackImportedRowsCount = function (fuseApi, templateSlug, rowCount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var error_1, errorMessage;
|
|
81
|
+
var _a, _b;
|
|
82
|
+
return __generator(this, function (_c) {
|
|
83
|
+
switch (_c.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
_c.trys.push([0, 2, , 3]);
|
|
86
|
+
return [4 /*yield*/, fuseApi.post("/api/v1/importer/templates/".concat(templateSlug, "/imports"), {
|
|
87
|
+
row_count: rowCount,
|
|
88
|
+
})];
|
|
89
|
+
case 1:
|
|
90
|
+
_c.sent();
|
|
91
|
+
return [3 /*break*/, 3];
|
|
92
|
+
case 2:
|
|
93
|
+
error_1 = _c.sent();
|
|
94
|
+
errorMessage = ((_b = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) ||
|
|
95
|
+
"There was an error submitting your dataset";
|
|
96
|
+
throw new Error(errorMessage);
|
|
97
|
+
case 3: return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); };
|
|
101
|
+
var getImportWasSuccessful = function (response) {
|
|
102
|
+
return !response.errors || !Object.keys(response.errors).length;
|
|
103
|
+
};
|
|
104
|
+
var filterAndMapWithBackendErrors = function (dataSet, errors) {
|
|
105
|
+
return Object.keys(errors).map(function (rId) {
|
|
106
|
+
var record = dataSet[rId];
|
|
107
|
+
var meta = record === null || record === void 0 ? void 0 : record._meta;
|
|
108
|
+
return __assign(__assign({}, record), { _meta: __assign(__assign({}, meta), { isInvalid: true, backendErrors: errors[rId] }) });
|
|
109
|
+
}, []);
|
|
110
|
+
};
|
|
111
|
+
function downloadCsv(data, fileName) {
|
|
112
|
+
var blob = new Blob([data], { type: "text/csv;charset=utf-8;" });
|
|
113
|
+
var link = document.createElement("a");
|
|
114
|
+
link.href = URL.createObjectURL(blob);
|
|
115
|
+
link.download = fileName;
|
|
116
|
+
document.body.appendChild(link);
|
|
117
|
+
link.click();
|
|
118
|
+
document.body.removeChild(link);
|
|
119
|
+
}
|
|
120
|
+
function csvExport(data) {
|
|
121
|
+
var valuesWithQuotesWhenNecessary = data.map(function (obj) {
|
|
122
|
+
var newObj = {};
|
|
123
|
+
for (var key in obj) {
|
|
124
|
+
var value = obj[key];
|
|
125
|
+
newObj[key] =
|
|
126
|
+
typeof value === "string" && value.includes(",") ? "\"".concat(value, "\"") : value;
|
|
127
|
+
}
|
|
128
|
+
return newObj;
|
|
129
|
+
});
|
|
130
|
+
var csv = Papa.unparse(valuesWithQuotesWhenNecessary);
|
|
131
|
+
downloadCsv(csv, "export.csv");
|
|
132
|
+
}
|
|
133
|
+
export var ReviewContextProvider = function (_a) {
|
|
134
|
+
var initialRecords = _a.initialRecords, children = _a.children;
|
|
135
|
+
var _b = useImporterContext(), templateHeaderMatchings = _b.templateHeaderMatchings, enumFieldValueMatchings = _b.enumFieldValueMatchings, templateHeaders = _b.templateHeaders, uploadedDataHeaders = _b.uploadedDataHeaders, headerRowIndex = _b.headerRowIndex, uploadedData = _b.uploadedData, currentStepIndex = _b.currentStepIndex, integrations = _b.integrations, templateSlug = _b.templateSlug, fuseApi = _b.fuseApi, setSelectedRows = _b.setSelectedRows, _c = _b.importerOptions, disableSubmitIfInvalid = _c.disableSubmitIfInvalid, batchValidationDelayMs = _c.batchValidationDelayMs, batchValidationSize = _c.batchValidationSize, previewMode = _c.previewMode, loadingComponent = _c.loadingComponent, onSubmit = _b.onSubmit, onValidateRecord = _b.onValidateRecord, formatRecord = _b.formatRecord, selectedRows = _b.selectedRows;
|
|
136
|
+
var setIsLoadingApp = useAppLoadingContext().setIsLoadingApp;
|
|
137
|
+
var _d = useState(false), isSubmitting = _d[0], setIsSubmitting = _d[1];
|
|
138
|
+
var _e = useState(false), isSubmitDisabled = _e[0], setIsSubmitDisabled = _e[1];
|
|
139
|
+
var _f = useState(false), importWasSuccessful = _f[0], setImportWasSuccessful = _f[1];
|
|
140
|
+
var _g = useState(null), appResponse = _g[0], setAppResponse = _g[1];
|
|
141
|
+
var _h = useState([]), previewFields = _h[0], setPreviewFields = _h[1];
|
|
142
|
+
var _j = useState(null), previewInitialDataSet = _j[0], setPreviewInitialDataSet = _j[1];
|
|
143
|
+
var _k = useState([]), reviewFields = _k[0], setReviewFields = _k[1];
|
|
144
|
+
var _l = useState(null), reviewInitialDataSet = _l[0], setReviewInitialDataSet = _l[1];
|
|
145
|
+
var _m = useState(null), initialDataSetUpdatedAt = _m[0], setInitialDataSetUpdatedAt = _m[1];
|
|
146
|
+
useEffect(function () {
|
|
147
|
+
if (currentStepIndex === 1)
|
|
148
|
+
setReviewInitialDataSet(null);
|
|
149
|
+
}, [currentStepIndex]);
|
|
150
|
+
var reviewDataSetRef = useRef(null);
|
|
151
|
+
var options = useMemo(function () { return ({
|
|
152
|
+
batchValidationDelayMs: batchValidationDelayMs,
|
|
153
|
+
batchValidationSize: batchValidationSize,
|
|
154
|
+
}); }, [batchValidationDelayMs, batchValidationSize]);
|
|
155
|
+
var onExport = useCallback(function (dataType) {
|
|
156
|
+
if (!reviewDataSetRef.current)
|
|
157
|
+
return;
|
|
158
|
+
var dataSet = reviewDataSetRef.current;
|
|
159
|
+
var dataSetValues = Object.values(dataSet);
|
|
160
|
+
if (dataType === "csv") {
|
|
161
|
+
var valuesWithoutMeta = dataSetValues.map(function (_a) {
|
|
162
|
+
var _meta = _a._meta, rest = __rest(_a, ["_meta"]);
|
|
163
|
+
return rest;
|
|
164
|
+
});
|
|
165
|
+
csvExport(valuesWithoutMeta);
|
|
166
|
+
}
|
|
167
|
+
}, [reviewFields, selectedRows]);
|
|
168
|
+
var onSubmitData = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var dataSet, dataSetValues, validDataSetValues, validDataSetLength, invalidRecords_1, applicationResponse, isAppResponseSuccessful, _a, errors, isDataValid, recordsToDisplayFiltered, invalidDataSet, error_2;
|
|
170
|
+
return __generator(this, function (_b) {
|
|
171
|
+
switch (_b.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
_b.trys.push([0, 5, 6, 7]);
|
|
174
|
+
if (!reviewDataSetRef.current)
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
setIsSubmitting(true);
|
|
177
|
+
dataSet = reviewDataSetRef.current;
|
|
178
|
+
dataSetValues = Object.values(dataSet);
|
|
179
|
+
validDataSetValues = dataSetValues.filter(function (record) {
|
|
180
|
+
return !record._meta.isInvalid && !isRecordEmpty(record, reviewFields);
|
|
181
|
+
});
|
|
182
|
+
validDataSetLength = validDataSetValues.length;
|
|
183
|
+
invalidRecords_1 = dataSetValues.filter(function (v) { return v._meta.isInvalid; });
|
|
184
|
+
return [4 /*yield*/, onSubmit(validDataSetValues)];
|
|
185
|
+
case 1:
|
|
186
|
+
applicationResponse = _b.sent();
|
|
187
|
+
isAppResponseSuccessful = getImportWasSuccessful(applicationResponse);
|
|
188
|
+
if (!isAppResponseSuccessful) {
|
|
189
|
+
_a = (applicationResponse !== null && applicationResponse !== void 0 ? applicationResponse : {}).errors, errors = _a === void 0 ? {} : _a;
|
|
190
|
+
invalidRecords_1 = __spreadArray(__spreadArray([], filterAndMapWithBackendErrors(dataSet, errors), true), invalidRecords_1, true);
|
|
191
|
+
}
|
|
192
|
+
isDataValid = invalidRecords_1.length === 0;
|
|
193
|
+
setImportWasSuccessful(isDataValid && isAppResponseSuccessful);
|
|
194
|
+
setAppResponse(applicationResponse);
|
|
195
|
+
if (applicationResponse.recordsToDisplay) {
|
|
196
|
+
recordsToDisplayFiltered = applicationResponse.recordsToDisplay.filter(function (record) {
|
|
197
|
+
var recordId = record._meta.id;
|
|
198
|
+
return !invalidRecords_1.some(function (invalidRecord) { return invalidRecord._meta.id === recordId; });
|
|
199
|
+
});
|
|
200
|
+
invalidRecords_1 = __spreadArray(__spreadArray([], invalidRecords_1, true), (recordsToDisplayFiltered || []), true);
|
|
201
|
+
}
|
|
202
|
+
invalidDataSet = recordListToDataSet(invalidRecords_1, reviewFields);
|
|
203
|
+
setReviewInitialDataSet(invalidDataSet);
|
|
204
|
+
if (!!previewMode) return [3 /*break*/, 4];
|
|
205
|
+
return [4 /*yield*/, trackImportedRowsCount(fuseApi, templateSlug, validDataSetLength)];
|
|
206
|
+
case 2:
|
|
207
|
+
_b.sent();
|
|
208
|
+
return [4 /*yield*/, sendRecordsToIntegrations(dataSetValues, integrations)];
|
|
209
|
+
case 3:
|
|
210
|
+
_b.sent();
|
|
211
|
+
_b.label = 4;
|
|
212
|
+
case 4: return [3 /*break*/, 7];
|
|
213
|
+
case 5:
|
|
214
|
+
error_2 = _b.sent();
|
|
215
|
+
console.error(error_2);
|
|
216
|
+
return [3 /*break*/, 7];
|
|
217
|
+
case 6:
|
|
218
|
+
setIsSubmitting(false);
|
|
219
|
+
return [7 /*endfinally*/];
|
|
220
|
+
case 7: return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); }, [reviewFields, onSubmit]);
|
|
224
|
+
var onDataSetChanged = useCallback(function (dataSet) {
|
|
225
|
+
reviewDataSetRef.current = dataSet;
|
|
226
|
+
}, []);
|
|
227
|
+
var onValidationStateChanged = useCallback(function (state) {
|
|
228
|
+
var isInvalid = !state.isValid;
|
|
229
|
+
var isValidating = !state.isValidationCompleted;
|
|
230
|
+
var disableSubmitIfInvalidFromOption = disableSubmitIfInvalid === undefined ? true : false;
|
|
231
|
+
var isDisabled = (disableSubmitIfInvalidFromOption && isInvalid) || isValidating;
|
|
232
|
+
setIsSubmitDisabled(isDisabled);
|
|
233
|
+
}, [disableSubmitIfInvalid]);
|
|
234
|
+
useEffect(function () {
|
|
235
|
+
if (!uploadedData && currentStepIndex === 0) {
|
|
236
|
+
//Reset data to clean the memory
|
|
237
|
+
setPreviewFields([]);
|
|
238
|
+
setPreviewInitialDataSet(null);
|
|
239
|
+
setReviewFields([]);
|
|
240
|
+
setReviewInitialDataSet(null);
|
|
241
|
+
reviewDataSetRef.current = null;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
var sleep = function (n) { return new Promise(function (resolve) { return setTimeout(resolve, n); }); };
|
|
245
|
+
if (currentStepIndex === 0) {
|
|
246
|
+
if (!previewInitialDataSet) {
|
|
247
|
+
//Uploader spreadsheet data
|
|
248
|
+
var _a = getPreviewDataSet({ uploadedData: uploadedData }), fields = _a.fields, initialDataSet = _a.initialDataSet;
|
|
249
|
+
setPreviewFields(fields);
|
|
250
|
+
setPreviewInitialDataSet(initialDataSet);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (currentStepIndex === 2) {
|
|
254
|
+
setIsLoadingApp(true);
|
|
255
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
256
|
+
var fields, _records, initialDataSet;
|
|
257
|
+
return __generator(this, function (_a) {
|
|
258
|
+
switch (_a.label) {
|
|
259
|
+
case 0:
|
|
260
|
+
if (!(uploadedData.length > 10000)) return [3 /*break*/, 2];
|
|
261
|
+
// wait for the first render to complete before blocking main thread with review step logic
|
|
262
|
+
return [4 /*yield*/, sleep(200)];
|
|
263
|
+
case 1:
|
|
264
|
+
// wait for the first render to complete before blocking main thread with review step logic
|
|
265
|
+
_a.sent();
|
|
266
|
+
_a.label = 2;
|
|
267
|
+
case 2:
|
|
268
|
+
fields = getTemplateFields({ templateHeaders: templateHeaders });
|
|
269
|
+
_records = initialRecords ||
|
|
270
|
+
transformToRecords({
|
|
271
|
+
templateHeaderMatchings: templateHeaderMatchings,
|
|
272
|
+
enumFieldValueMatchings: enumFieldValueMatchings,
|
|
273
|
+
templateHeaders: templateHeaders,
|
|
274
|
+
uploadedDataHeaders: uploadedDataHeaders,
|
|
275
|
+
uploadedData: uploadedData.slice(headerRowIndex + 1),
|
|
276
|
+
formatRecord: formatRecord,
|
|
277
|
+
});
|
|
278
|
+
initialDataSet = getReviewDataSet({
|
|
279
|
+
records: _records,
|
|
280
|
+
fields: fields,
|
|
281
|
+
}).initialDataSet;
|
|
282
|
+
setSelectedRows([]);
|
|
283
|
+
setReviewFields(fields);
|
|
284
|
+
setReviewInitialDataSet(initialDataSet);
|
|
285
|
+
setInitialDataSetUpdatedAt(Date.now());
|
|
286
|
+
setIsLoadingApp(false);
|
|
287
|
+
return [2 /*return*/];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}); })();
|
|
291
|
+
}
|
|
292
|
+
}, [uploadedData, currentStepIndex, templateHeaders, uploadedData]);
|
|
293
|
+
var value = {
|
|
294
|
+
previewInitialDataSet: previewInitialDataSet,
|
|
295
|
+
previewFields: previewFields,
|
|
296
|
+
reviewInitialDataSet: reviewInitialDataSet,
|
|
297
|
+
reviewFields: reviewFields,
|
|
298
|
+
isSubmitDisabled: isSubmitDisabled,
|
|
299
|
+
importWasSuccessful: importWasSuccessful,
|
|
300
|
+
appResponse: appResponse,
|
|
301
|
+
isSubmitting: isSubmitting,
|
|
302
|
+
options: options,
|
|
303
|
+
initialDataSetUpdatedAt: initialDataSetUpdatedAt,
|
|
304
|
+
onSubmit: onSubmitData,
|
|
305
|
+
onExport: onExport,
|
|
306
|
+
onValidateRecord: onValidateRecord,
|
|
307
|
+
onDataSetChanged: onDataSetChanged,
|
|
308
|
+
onValidationStateChanged: onValidationStateChanged,
|
|
309
|
+
};
|
|
310
|
+
function renderLoading() {
|
|
311
|
+
return isSubmitting ? (loadingComponent ? (loadingComponent()) : (_jsx(AppLoading, {}))) : null;
|
|
312
|
+
}
|
|
313
|
+
return (_jsxs(ReviewContext.Provider, __assign({ value: value }, { children: [renderLoading(), children] })));
|
|
314
|
+
};
|
|
315
|
+
export var useReviewContext = function () { return useContext(ReviewContext); };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { useTranslation } from "react-i18next";
|
|
18
|
+
import styled from "styled-components";
|
|
19
|
+
import { Div } from "../../styled/utils";
|
|
20
|
+
import Spreadsheet from "../common/Spreadsheet";
|
|
21
|
+
import { useImporterContext } from "../contexts/ImporterContextProvider";
|
|
22
|
+
import { AppResponseModal } from "./AppResponseModal";
|
|
23
|
+
import { useReviewContext } from "./ReviewContextProvider";
|
|
24
|
+
var TitleContainer = styled(Div)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
25
|
+
var ReviewWithContext = function () {
|
|
26
|
+
var _a = useReviewContext(), fields = _a.reviewFields, initialDataSet = _a.reviewInitialDataSet, options = _a.options, initialDataSetUpdatedAt = _a.initialDataSetUpdatedAt, onValidateRecord = _a.onValidateRecord, onDataSetChanged = _a.onDataSetChanged, onValidationStateChanged = _a.onValidationStateChanged;
|
|
27
|
+
var _b = useImporterContext(), selectedRows = _b.selectedRows, setSelectedRows = _b.setSelectedRows, isUsingManualImport = _b.isUsingManualImport;
|
|
28
|
+
var t = useTranslation("review").t;
|
|
29
|
+
var spreadsheetUI = initialDataSet && (_jsx(Spreadsheet, { initialDataSetUpdatedAt: initialDataSetUpdatedAt, options: __assign(__assign({}, options), { showCheckboxColumn: true }), selectedRows: selectedRows, setSelectedRows: setSelectedRows, initialDataSet: initialDataSet, fields: fields, onDataSetChanged: onDataSetChanged, onValidateRecord: onValidateRecord, onValidationStateChanged: onValidationStateChanged }));
|
|
30
|
+
return (_jsxs(Div, __assign({ centered: true, flexColumn: true, h100: true }, { children: [_jsx(AppResponseModal, {}), _jsxs(Div, __assign({ w100: true, h100: true, flexColumn: true }, { children: [_jsx(TitleContainer, __assign({ flexColumn: true, ml: 32 }, { children: _jsx(Div, __assign({ h2: true, mt: 40, mb: 40 }, { children: t(isUsingManualImport.current ? "manual_importer_title" : "title") })) })), _jsx(Div, __assign({ h100: true, w100: true, justifyCenter: true }, { children: spreadsheetUI }))] }))] })));
|
|
31
|
+
};
|
|
32
|
+
export default ReviewWithContext;
|
|
33
|
+
var templateObject_1;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Div } from "../../styled";
|
|
14
|
+
import { Button, Modal } from "../../common";
|
|
15
|
+
import { errorIcon } from "./common/icons";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
17
|
+
export var ConfirmCloseModal = function (_a) {
|
|
18
|
+
var isOpen = _a.isOpen, onClose = _a.onClose, onCloseImporter = _a.onCloseImporter;
|
|
19
|
+
var t = useTranslation("general").t;
|
|
20
|
+
return (_jsx(Modal, __assign({ isOpen: isOpen, onClose: onClose }, { children: _jsxs(Div, __assign({ centered: true, flexColumn: true, p: 60 }, { children: [_jsx(Div, __assign({ textAlignCenter: true, mb: 10, mt: 5 }, { children: errorIcon })), _jsx(Div, __assign({ h5: true, mt: 10 }, { children: t("confirm_close_modal.title") })), _jsx(Div, __assign({ body1: true, mt: 12, w: 448, textAlignCenter: true }, { children: t("confirm_close_modal.description") })), _jsxs(Div, __assign({ dflex: true, mt: 40, w100: true, centered: true }, { children: [_jsx(Button, __assign({ w: 115, variant: "secondary", mr: 10, onClick: onClose, "data-test-id": "confirm-close-modal-cancel" }, { children: t("confirm_close_modal.cancel") })), _jsx(Button, __assign({ w: 140, ml: 10, onClick: function () {
|
|
21
|
+
onCloseImporter();
|
|
22
|
+
onClose();
|
|
23
|
+
} }, { children: t("confirm_close_modal.close") }))] }))] })) })));
|
|
24
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { colors, Div } from "../../styled";
|
|
14
|
+
import { StepIndex } from "./StepIndex";
|
|
15
|
+
export var Step = function (_a) {
|
|
16
|
+
var index = _a.index, label = _a.label, isSelected = _a.isSelected, isCompleted = _a.isCompleted;
|
|
17
|
+
var isActive = isCompleted || isSelected;
|
|
18
|
+
return (_jsxs(Div, __assign({ centered: true, buttonText: true, c: isActive ? colors.text : colors.gray400 }, { children: [_jsx(StepIndex, { index: index + 1, isSelected: isSelected, isCompleted: isCompleted }), label] })));
|
|
19
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
import styled, { css } from "styled-components";
|
|
18
|
+
import { WhiteCheckIcon } from "../../common";
|
|
19
|
+
import { Div } from "../../styled";
|
|
20
|
+
var StepIndexWrapper = styled(Div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 22px;\n width: 22px;\n color: ", ";\n border-radius: 50%;\n background-color: none;\n border: 1px solid ", ";\n\n ", ";\n"], ["\n height: 22px;\n width: 22px;\n color: ", ";\n border-radius: 50%;\n background-color: none;\n border: 1px solid ", ";\n\n ", ";\n"])), function (p) { return p.theme.colors.gray400; }, function (p) { return p.theme.colors.gray400; }, function (p) {
|
|
21
|
+
return p.isSelected && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 32px;\n width: 32px;\n border: solid 1px ", ";\n color: ", ";\n background-color: ", ";\n "], ["\n height: 32px;\n width: 32px;\n border: solid 1px ", ";\n color: ", ";\n background-color: ", ";\n "])), function (p) { return p.theme.colors.blue500; }, function (p) { return p.theme.colors.white; }, function (p) { return p.theme.colors.blue500; });
|
|
22
|
+
});
|
|
23
|
+
export var StepIndex = function (_a) {
|
|
24
|
+
var index = _a.index, isSelected = _a.isSelected, isCompleted = _a.isCompleted;
|
|
25
|
+
return (_jsx(_Fragment, { children: isCompleted ? (_jsx(Div, __assign({ centered: true, body2: true, bold: true, mr: 8 }, { children: _jsx(WhiteCheckIcon, {}) }))) : (_jsx(StepIndexWrapper, __assign({ centered: true, body2: true, bold: true, mr: 8, isSelected: isSelected }, { children: index }))) }));
|
|
26
|
+
};
|
|
27
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Div } from "../../styled";
|
|
14
|
+
import { Button, Modal } from "../../common";
|
|
15
|
+
import { submitIcon } from "./common/icons";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
17
|
+
export var StepperSubmitModal = function (_a) {
|
|
18
|
+
var isSubmitModalOpen = _a.isSubmitModalOpen, onCloseModal = _a.onCloseModal, onSubmit = _a.onSubmit;
|
|
19
|
+
var t = useTranslation("general").t;
|
|
20
|
+
return (_jsx(Modal, __assign({ isOpen: isSubmitModalOpen, onClose: function () { return onCloseModal(); } }, { children: _jsxs(Div, __assign({ centered: true, flexColumn: true, p: 60 }, { children: [_jsx(Div, { children: submitIcon }), _jsx(Div, __assign({ h5: true, mt: 20 }, { children: t("submit_modal.title") })), _jsx(Div, __assign({ body1: true, mt: 12, w: 448, textAlignCenter: true }, { children: t("submit_modal.description") })), _jsxs(Div, __assign({ dflex: true, mt: 40, w100: true, centered: true }, { children: [_jsx(Button, __assign({ w: 115, variant: "secondary", mr: 10, onClick: function () { return onCloseModal(); }, "data-test-id": "submit-modal-go-back" }, { children: t("submit_modal.cancel") })), _jsx(Button, __assign({ w: 140, ml: 10, onClick: function () {
|
|
21
|
+
onSubmit();
|
|
22
|
+
onCloseModal();
|
|
23
|
+
} }, { children: t("submit_modal.submit") }))] }))] })) })));
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Div } from "../../styled";
|
|
14
|
+
import { Button, Modal } from "../../common";
|
|
15
|
+
import { errorIcon } from "./common/icons";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
17
|
+
export var UnmatchedHeadersModal = function (_a) {
|
|
18
|
+
var isUnmatchedHeadersModalOpen = _a.isUnmatchedHeadersModalOpen, unmatchedHeadersCount = _a.unmatchedHeadersCount, onSetStep = _a.onSetStep, onCloseUnmatchedHeadersModal = _a.onCloseUnmatchedHeadersModal;
|
|
19
|
+
var skipStep = function () {
|
|
20
|
+
onSetStep();
|
|
21
|
+
onCloseUnmatchedHeadersModal();
|
|
22
|
+
};
|
|
23
|
+
var t = useTranslation("general").t;
|
|
24
|
+
return (_jsx(Modal, __assign({ isOpen: isUnmatchedHeadersModalOpen, onClose: function () { return onCloseUnmatchedHeadersModal(); } }, { children: _jsxs(Div, __assign({ p: "17px 20px" }, { children: [_jsx(Div, __assign({ textAlignCenter: true, mb: 24, mt: 5 }, { children: errorIcon })), _jsx(Div, __assign({ textAlignCenter: true, h5: true }, { children: t("unmatched_headers_modal.title") })), _jsx(Div, __assign({ w: 448, mt: 12, textAlignCenter: true, body1: true }, { children: unmatchedHeadersCount === 1
|
|
25
|
+
? t("unmatched_headers_modal.description_singular", {
|
|
26
|
+
count: unmatchedHeadersCount,
|
|
27
|
+
})
|
|
28
|
+
: t("unmatched_headers_modal.description_plural", {
|
|
29
|
+
count: unmatchedHeadersCount,
|
|
30
|
+
}) })), _jsxs(Div, __assign({ dflex: true, centered: true, mt: 40 }, { children: [_jsx(Button, __assign({ variant: "secondary", onClick: function () { return onCloseUnmatchedHeadersModal(); }, w: 160, mr: 16 }, { children: t("unmatched_headers_modal.assign_headers") })), _jsx(Button, __assign({ variant: "primary", onClick: skipStep }, { children: t("unmatched_headers_modal.skip") }))] }))] })) })));
|
|
31
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import Fuse from "fuse.js";
|
|
13
|
+
import { fusejsOptions, } from "../../contexts/ImporterContextProvider";
|
|
14
|
+
export var getEnumFieldValueMatchingsInitialValue = function (_a) {
|
|
15
|
+
var uploadedDataEnumFieldValues = _a.uploadedDataEnumFieldValues, templateHeaders = _a.templateHeaders;
|
|
16
|
+
var res = {};
|
|
17
|
+
var setEnumFieldValueMathings = function (templateLabel) {
|
|
18
|
+
uploadedDataEnumFieldValues[templateLabel].forEach(function (uploadedValue, _index) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var templateOptions = (_a = templateHeaders.find(function (th) { return th.label === templateLabel; })) === null || _a === void 0 ? void 0 : _a.values;
|
|
21
|
+
var fuse = new Fuse(templateOptions, fusejsOptions);
|
|
22
|
+
var fuseResults = fuse.search(uploadedValue);
|
|
23
|
+
var previousRes = __assign({}, (res[templateLabel] || {}));
|
|
24
|
+
res[templateLabel] = previousRes;
|
|
25
|
+
res[templateLabel][uploadedValue] = (_b = fuseResults[0]) === null || _b === void 0 ? void 0 : _b.item;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var templateLabels = Object.keys(uploadedDataEnumFieldValues);
|
|
29
|
+
templateLabels.forEach(function (templateLabel) {
|
|
30
|
+
setEnumFieldValueMathings(templateLabel);
|
|
31
|
+
});
|
|
32
|
+
return res;
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export var submitIcon = (_jsxs("svg", __assign({ width: 64, height: 64, fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { fill: "#fff", d: "M0 0h64v64H0z" }), _jsx("path", { d: "M49.306 6.195a2 2 0 0 1 2.824-.16l10.379 9.27a2 2 0 0 1 .16 2.824L28.148 56.78a2 2 0 0 1-2.824.16l-10.379-9.27a2 2 0 0 1-.16-2.823l34.52-38.652Z", fill: "url(#a)", style: {
|
|
14
|
+
mixBlendMode: "multiply",
|
|
15
|
+
} }), _jsx("rect", { x: 38.727, y: 44.871, width: 17.915, height: 35.878, rx: 2, transform: "rotate(131.582 38.727 44.87)", fill: "url(#b)", style: {
|
|
16
|
+
mixBlendMode: "darken",
|
|
17
|
+
} }), _jsxs("defs", { children: [_jsxs("linearGradient", __assign({ id: "a", x1: 18.672, y1: 47.198, x2: 37.603, y2: 58.473, gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#D0A617" }), _jsx("stop", { offset: 1, stopColor: "#FEE18F" })] })), _jsxs("linearGradient", __assign({ id: "b", x1: 47.684, y1: 44.871, x2: 36.123, y2: 89.527, gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#6BEEFF" }), _jsx("stop", { offset: 1, stopColor: "#08CABE" })] }))] })] })));
|
|
18
|
+
export var errorIcon = (_jsxs("svg", __assign({ width: "68", height: "68", viewBox: "0 0 68 68", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsxs("g", __assign({ clipPath: "url(#clip0_1052_34495)" }, { children: [_jsx("rect", { width: "68", height: "68", fill: "white" }), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M28.5668 8.05854C29.6943 6.10577 32.5129 6.10576 33.6403 8.05854L59.1466 52.2368C60.274 54.1895 58.8648 56.6305 56.6099 56.6305H5.59726C3.34239 56.6305 1.93309 54.1895 3.06053 52.2368L28.5668 8.05854Z", fill: "url(#paint0_linear_1052_34495)" }) })), _jsx("g", __assign({ style: { mixBlendMode: "multiply" } }, { children: _jsx("path", { d: "M34.4375 9.68867C35.5649 7.73589 38.3835 7.73589 39.511 9.68867L65.816 55.2503C66.9434 57.2031 65.5341 59.6441 63.2793 59.6441H10.6692C8.41432 59.6441 7.00502 57.2031 8.13246 55.2503L34.4375 9.68867Z", fill: "url(#paint1_linear_1052_34495)" }) })), _jsx("rect", { x: "29.0371", y: "21.2632", width: "6.43183", height: "21.3972", rx: "2.92916", fill: "#FFFDF8" }), _jsx("rect", { x: "29.0371", y: "44.7898", width: "6.43183", height: "5.61436", rx: "2.80718", fill: "#FFFDF8" })] })), _jsxs("defs", { children: [_jsxs("linearGradient", __assign({ id: "paint0_linear_1052_34495", x1: "10.0099", y1: "28.8136", x2: "30.2646", y2: "54.4823", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#FD5C39" }), _jsx("stop", { offset: "1", stopColor: "#FFB869" })] })), _jsxs("linearGradient", __assign({ id: "paint1_linear_1052_34495", x1: "18.8007", y1: "74.0811", x2: "85.2567", y2: "33.8684", gradientUnits: "userSpaceOnUse" }, { children: [_jsx("stop", { stopColor: "#E7C551" }), _jsx("stop", { offset: "1", stopColor: "#FEE18F" })] })), _jsx("clipPath", __assign({ id: "clip0_1052_34495" }, { children: _jsx("rect", { width: "68", height: "68", fill: "white" }) }))] })] })));
|