fuse-importer 0.25.2 → 0.25.4

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.
@@ -59,6 +59,7 @@ var ImporterDropzone = function () {
59
59
  reader.onabort = function () { return console.log("file reading was aborted"); };
60
60
  reader.onerror = function () { return console.log("file reading has failed"); };
61
61
  reader.onload = function (event) {
62
+ var _a;
62
63
  var results = event.target.result;
63
64
  var getDataFromFile = function (fileResults) {
64
65
  var workBook = XLSX.read(fileResults, {
@@ -71,14 +72,9 @@ var ImporterDropzone = function () {
71
72
  return XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false });
72
73
  };
73
74
  var fileData = getDataFromFile(results);
74
- var filteredArray = fileData
75
- .map(function (subArray) {
76
- return subArray.filter(function (value) { return value || value === 0 || value === false; });
77
- })
78
- .filter(function (subArray) { return subArray.length > 0; });
79
- var headersCount = filteredArray[0].length;
75
+ var headersCount = (_a = fileData[0]) === null || _a === void 0 ? void 0 : _a.length;
80
76
  if (validHeadersCount(headersCount)) {
81
- setUploadedData(filteredArray);
77
+ setUploadedData(fileData);
82
78
  }
83
79
  setIsUploading(false);
84
80
  };
@@ -81,11 +81,10 @@ export var ImporterContextProvider = function (_a) {
81
81
  ]);
82
82
  var uploadedDataHeaders = useMemo(function () {
83
83
  var _a;
84
- var initialParsing = (_a = uploadedData === null || uploadedData === void 0 ? void 0 : uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
85
- return typeof ud === "number" ? ud.toString() : ud;
86
- });
87
- var onlyValidValues = initialParsing === null || initialParsing === void 0 ? void 0 : initialParsing.filter(function (val) { return val; });
88
- return (onlyValidValues === null || onlyValidValues === void 0 ? void 0 : onlyValidValues.length) ? onlyValidValues : [];
84
+ return uploadedData &&
85
+ ((_a = uploadedData[0]) === null || _a === void 0 ? void 0 : _a.map(function (ud) {
86
+ return typeof ud === "number" ? ud.toString() : ud;
87
+ }));
89
88
  }, [uploadedData]);
90
89
  useEffect(function () {
91
90
  if (!templateHeaderMatchings)
@@ -122,7 +121,7 @@ export var ImporterContextProvider = function (_a) {
122
121
  };
123
122
  useEffect(function () {
124
123
  (function () { return __awaiter(void 0, void 0, void 0, function () {
125
- var _a, organization_1, columns, importer_style_preferences, integrations_1, preview_first_time, error_1, errorMsg;
124
+ var _a, organization_1, columns, importer_style_preferences, integrations_1, preview_first_time, columnsOrderedByPosition, error_1, errorMsg;
126
125
  var _b, _c;
127
126
  return __generator(this, function (_d) {
128
127
  switch (_d.label) {
@@ -131,8 +130,9 @@ export var ImporterContextProvider = function (_a) {
131
130
  return [4 /*yield*/, fuseApi.get("/api/v1/importer/templates/".concat(templateSlug))];
132
131
  case 1:
133
132
  _a = (_d.sent()).data, organization_1 = _a.organization, columns = _a.columns, importer_style_preferences = _a.importer_style_preferences, integrations_1 = _a.integrations, preview_first_time = _a.preview_first_time;
133
+ columnsOrderedByPosition = columns.sort(function (a, b) { return a.position - b.position; });
134
134
  setOrganization(organization_1);
135
- setTemplateHeaders(columns);
135
+ setTemplateHeaders(columnsOrderedByPosition);
136
136
  setIntegrations(integrations_1);
137
137
  setPreviewFirstTime(preview_first_time);
138
138
  if (organization_1.plan && organization_1.plan.allow_style_customization) {
@@ -63,7 +63,7 @@ export var TableDataProvider = function (_a) {
63
63
  var _j = useState(null), totalPages = _j[0], setTotalPages = _j[1];
64
64
  var _k = useState(defaultSortBy), sortBy = _k[0], setSortBy = _k[1];
65
65
  var _l = useState(0), totalCount = _l[0], setTotalCount = _l[1];
66
- var _m = useState(7), pageSize = _m[0], setPageSize = _m[1];
66
+ var _m = useState(50), pageSize = _m[0], setPageSize = _m[1];
67
67
  var getData = function () { return __awaiter(void 0, void 0, void 0, function () {
68
68
  var payload, e_1;
69
69
  var _a, _b, _c;
@@ -49,7 +49,7 @@ var ClickableArea = styled(Div)(function (_a) {
49
49
  var Autocomplete = function (_a) {
50
50
  var _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isInputDisabled, isInputDisabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "general:autocomplete.placeholder" : _e, value = _a.value, icon = _a.icon, onChange = _a.onChange, placement = _a.placement, options = _a.options, onToggle = _a.onToggle, id = _a.id, labelTooltip = _a.labelTooltip, props = __rest(_a, ["label", "isDisabled", "isInputDisabled", "placeholder", "value", "icon", "onChange", "placement", "options", "onToggle", "id", "labelTooltip"]);
51
51
  var _f = useState(false), updatedText = _f[0], setUpdatedText = _f[1];
52
- var selectedLabel = useMemo(function () { var _a; return ((_a = options.find(function (o) { return o.value === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
52
+ var selectedLabel = useMemo(function () { var _a; return ((_a = options === null || options === void 0 ? void 0 : options.find(function (o) { return (o === null || o === void 0 ? void 0 : o.value) === value; })) === null || _a === void 0 ? void 0 : _a.label) || ""; }, [value]);
53
53
  var _g = useState(selectedLabel), text = _g[0], setText = _g[1];
54
54
  var _h = useState(false), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
55
55
  var _j = useState(null), referenceElement = _j[0], setReferenceElement = _j[1];
@@ -70,7 +70,8 @@ var Autocomplete = function (_a) {
70
70
  onToggle(isMenuOpen);
71
71
  }, [isMenuOpen]);
72
72
  var onSelect = function (v) {
73
- setText(options.find(function (o) { return o.value === v; }).label);
73
+ var _a;
74
+ setText((_a = options.find(function (o) { return (o === null || o === void 0 ? void 0 : o.value) === v; })) === null || _a === void 0 ? void 0 : _a.label);
74
75
  onChange(v);
75
76
  setIsMenuOpen(false);
76
77
  };
@@ -91,7 +92,7 @@ var Autocomplete = function (_a) {
91
92
  setText(selectedLabel);
92
93
  setIsMenuOpen(false);
93
94
  }
94
- }, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === o.value, onClick: function () { return onSelect(o.value); } }, { children: o.label })) }, index)); }) })))] })));
95
+ }, label: label, isDisabled: isDisabled || isInputDisabled, placeholder: t(placeholder), value: text, onChange: function (v) { return setText(v); }, icon: isDisabled ? null : inputIconUI, labelTooltip: labelTooltip }) })), !isDisabled && filteredOptions.length > 0 && (_jsx(SelectMenu, __assign({ referenceElement: referenceElement, placement: placement, isOpen: isMenuOpen, onClose: function () { return setIsMenuOpen(false); } }, { children: filteredOptions.map(function (o, index) { return (_jsx(Div, { children: _jsx(MenuItem, __assign({ id: id ? "".concat(id, "-option-").concat(o.label) : null, isSelected: value === (o === null || o === void 0 ? void 0 : o.value), onClick: function () { return onSelect(o === null || o === void 0 ? void 0 : o.value); } }, { children: o.label })) }, index)); }) })))] })));
95
96
  };
96
97
  var chevronDownIcon = (_jsx("svg", __assign({ width: "16", height: "9", viewBox: "0 0 16 9", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M14.9263 1L7.9631 7.96317L0.999928 1", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })));
97
98
  var clearIcon = (_jsxs("svg", __assign({ width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "M4 4L12.5161 12.5161", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M4 12.5161L12.5161 3.99998", stroke: "#333333", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
@@ -86,6 +86,7 @@ export type TemplateHeader = {
86
86
  values: string[];
87
87
  pattern: string;
88
88
  validations: FieldValidation[];
89
+ position: number;
89
90
  };
90
91
  export type Organization = {
91
92
  id: number;