@micromag/data 0.3.698 → 0.3.699

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.
Files changed (2) hide show
  1. package/es/index.js +26 -11
  2. package/package.json +2 -2
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) : null;
407
- }, [api, screenId]);
408
- var _ref2 = api !== null ? useData(loader, opts) : {
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 = _ref2.data,
412
- request = _objectWithoutProperties(_ref2, _excluded$3);
419
+ data = _ref3.data,
420
+ request = _objectWithoutProperties(_ref3, _excluded$3);
413
421
  return _objectSpread({
414
422
  contributions: data || defaultContributions
415
423
  }, request);
@@ -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) : null;
998
- }, [api, screenId]);
999
- var _ref2 = api !== null ? useData(loader, opts) : {
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 = _ref2.data,
1003
- request = _objectWithoutProperties(_ref2, _excluded);
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.698",
3
+ "version": "0.3.699",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -68,5 +68,5 @@
68
68
  "access": "public",
69
69
  "registry": "https://registry.npmjs.org/"
70
70
  },
71
- "gitHead": "902961f5ef5773bee063b6e6405ea37eac10fa7d"
71
+ "gitHead": "8d69620bde11630e19004ac76f6ed1454fc33516"
72
72
  }