@micromag/data 0.3.698 → 0.3.703
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/es/index.js +29 -14
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -230,9 +230,10 @@ var QuizApi = /*#__PURE__*/function (_Base) {
|
|
|
230
230
|
return _createClass(QuizApi, [{
|
|
231
231
|
key: "results",
|
|
232
232
|
value: function results(screenId) {
|
|
233
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
233
234
|
return this.requestGet(this.route('results', {
|
|
234
235
|
screen: screenId
|
|
235
|
-
}));
|
|
236
|
+
}), query);
|
|
236
237
|
}
|
|
237
238
|
}, {
|
|
238
239
|
key: "create",
|
|
@@ -391,9 +392,14 @@ var _excluded$3 = ["data"];
|
|
|
391
392
|
var useContributions = function useContributions() {
|
|
392
393
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
393
394
|
screenId = _ref.screenId,
|
|
395
|
+
_ref$storyId = _ref.storyId,
|
|
396
|
+
providedStoryId = _ref$storyId === void 0 ? null : _ref$storyId,
|
|
394
397
|
_ref$opts = _ref.opts,
|
|
395
398
|
opts = _ref$opts === void 0 ? {} : _ref$opts;
|
|
396
399
|
var api = useApi();
|
|
400
|
+
var _ref2 = useStory() || {},
|
|
401
|
+
storyId = _ref2.id,
|
|
402
|
+
documentId = _ref2.document_id;
|
|
397
403
|
var _useState = useState(_toConsumableArray(new Array(10)).map(function (el, i) {
|
|
398
404
|
return {
|
|
399
405
|
name: "Nom ".concat(i + 1),
|
|
@@ -403,13 +409,15 @@ var useContributions = function useContributions() {
|
|
|
403
409
|
_useState2 = _slicedToArray(_useState, 1),
|
|
404
410
|
defaultContributions = _useState2[0];
|
|
405
411
|
var loader = useCallback(function () {
|
|
406
|
-
return api !== null ? api.contributions.get(screenId
|
|
407
|
-
|
|
408
|
-
|
|
412
|
+
return api !== null ? api.contributions.get(screenId, {
|
|
413
|
+
story_id: documentId || providedStoryId || storyId
|
|
414
|
+
}) : null;
|
|
415
|
+
}, [api, screenId, documentId, providedStoryId, storyId]);
|
|
416
|
+
var _ref3 = api !== null ? useData(loader, opts) : {
|
|
409
417
|
data: null
|
|
410
418
|
},
|
|
411
|
-
data =
|
|
412
|
-
request = _objectWithoutProperties(
|
|
419
|
+
data = _ref3.data,
|
|
420
|
+
request = _objectWithoutProperties(_ref3, _excluded$3);
|
|
413
421
|
return _objectSpread({
|
|
414
422
|
contributions: data || defaultContributions
|
|
415
423
|
}, request);
|
|
@@ -765,9 +773,9 @@ var useItems = function useItems(_ref) {
|
|
|
765
773
|
|
|
766
774
|
// Items
|
|
767
775
|
var _useState9 = useState(null),
|
|
768
|
-
|
|
769
|
-
items =
|
|
770
|
-
setItems =
|
|
776
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
777
|
+
items = _useState0[0],
|
|
778
|
+
setItems = _useState0[1];
|
|
771
779
|
var getPages = useCallback(function (newQuery, newPageNumber, newPageCount) {
|
|
772
780
|
return getPage(newQuery, newPageNumber, newPageCount);
|
|
773
781
|
}, [getPage]);
|
|
@@ -990,17 +998,24 @@ var _excluded = ["data"];
|
|
|
990
998
|
var useQuiz = function useQuiz() {
|
|
991
999
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
992
1000
|
screenId = _ref.screenId,
|
|
1001
|
+
_ref$storyId = _ref.storyId,
|
|
1002
|
+
providedStoryId = _ref$storyId === void 0 ? null : _ref$storyId,
|
|
993
1003
|
_ref$opts = _ref.opts,
|
|
994
1004
|
opts = _ref$opts === void 0 ? {} : _ref$opts;
|
|
995
1005
|
var api = useApi();
|
|
1006
|
+
var _ref2 = useStory() || {},
|
|
1007
|
+
storyId = _ref2.id,
|
|
1008
|
+
documentId = _ref2.document_id;
|
|
996
1009
|
var loader = useCallback(function () {
|
|
997
|
-
return api !== null ? api.quiz.results(screenId
|
|
998
|
-
|
|
999
|
-
|
|
1010
|
+
return api !== null ? api.quiz.results(screenId, {
|
|
1011
|
+
story_id: documentId || providedStoryId || storyId
|
|
1012
|
+
}) : null;
|
|
1013
|
+
}, [api, screenId, documentId, providedStoryId, storyId]);
|
|
1014
|
+
var _ref3 = api !== null ? useData(loader, opts) : {
|
|
1000
1015
|
data: null
|
|
1001
1016
|
},
|
|
1002
|
-
data =
|
|
1003
|
-
request = _objectWithoutProperties(
|
|
1017
|
+
data = _ref3.data,
|
|
1018
|
+
request = _objectWithoutProperties(_ref3, _excluded);
|
|
1004
1019
|
return _objectSpread({
|
|
1005
1020
|
quiz: data || []
|
|
1006
1021
|
}, request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/data",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.703",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@babel/runtime": "^7.13.10",
|
|
60
60
|
"@folklore/fetch": "^0.1.17",
|
|
61
61
|
"@folklore/routes": "^0.2.36",
|
|
62
|
-
"@micromag/core": "^0.3.
|
|
62
|
+
"@micromag/core": "^0.3.703",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"prop-types": "^15.7.2",
|
|
65
65
|
"query-string": "^9.0.0"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"access": "public",
|
|
69
69
|
"registry": "https://registry.npmjs.org/"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "15a0df01ed9d05f47a056fb2ff078aded803d33d"
|
|
72
72
|
}
|