@portnet/ui 0.1.14 → 0.1.15
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.
|
@@ -105,7 +105,7 @@ const PuiSpecificReferentielField = _ref2 => {
|
|
|
105
105
|
getRenderedValue,
|
|
106
106
|
onChange,
|
|
107
107
|
onError,
|
|
108
|
-
|
|
108
|
+
fetchDataFunction
|
|
109
109
|
} = _ref2;
|
|
110
110
|
const {
|
|
111
111
|
token,
|
|
@@ -154,8 +154,33 @@ const PuiSpecificReferentielField = _ref2 => {
|
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
const submitHandler = async (values, formikBag) => {
|
|
157
|
-
if
|
|
158
|
-
|
|
157
|
+
// Check if dataFetchingDispatch is not null and a custom submit handler function is provided
|
|
158
|
+
if (dataFetchingDispatch && fetchDataFunction) {
|
|
159
|
+
try {
|
|
160
|
+
dataFetchingDispatch({
|
|
161
|
+
type: "GET_DATA"
|
|
162
|
+
});
|
|
163
|
+
const data = await fetchDataFunction(searchKey, specifications, dataFetchingState.pageNumber, dataFetchingState.pageSize, values);
|
|
164
|
+
if (data.success) {
|
|
165
|
+
dataFetchingDispatch({
|
|
166
|
+
type: "SUCCESSED",
|
|
167
|
+
payload: {
|
|
168
|
+
data: data.results,
|
|
169
|
+
totalElements: data.totalElements
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error(data.message);
|
|
174
|
+
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
dataFetchingDispatch({
|
|
177
|
+
type: "FAILED",
|
|
178
|
+
payload: error.message
|
|
179
|
+
});
|
|
180
|
+
if (onError) {
|
|
181
|
+
onError(error);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
159
184
|
} else {
|
|
160
185
|
return defaultSubmitHandler(values, formikBag);
|
|
161
186
|
}
|
|
@@ -316,7 +341,7 @@ PuiSpecificReferentielField.propTypes = {
|
|
|
316
341
|
getReturnedValue: _propTypes.default.func,
|
|
317
342
|
onChange: _propTypes.default.func,
|
|
318
343
|
onError: _propTypes.default.func,
|
|
319
|
-
|
|
344
|
+
fetchDataFunction: _propTypes.default.func
|
|
320
345
|
};
|
|
321
346
|
PuiSpecificReferentielField.defaultProps = {
|
|
322
347
|
disabled: false,
|
|
@@ -330,6 +355,6 @@ PuiSpecificReferentielField.defaultProps = {
|
|
|
330
355
|
getReturnedValue: row => row,
|
|
331
356
|
onError: () => {},
|
|
332
357
|
onChange: () => {},
|
|
333
|
-
|
|
358
|
+
fetchDataFunction: null
|
|
334
359
|
};
|
|
335
360
|
var _default = exports.default = PuiSpecificReferentielField;
|