@micromag/data 0.3.251 → 0.3.252
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 +13 -3
- package/lib/index.js +13 -3
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { generatePath } from 'react-router';
|
|
|
11
11
|
import { stringify } from 'query-string';
|
|
12
12
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
13
13
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
14
|
+
import { useVisitor, useStory } from '@micromag/core/contexts';
|
|
14
15
|
|
|
15
16
|
var Base = /*#__PURE__*/function () {
|
|
16
17
|
function Base() {
|
|
@@ -878,7 +879,9 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
878
879
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
879
880
|
screenId = _ref.screenId,
|
|
880
881
|
_ref$visitorId = _ref.visitorId,
|
|
881
|
-
|
|
882
|
+
providedVisitorId = _ref$visitorId === void 0 ? null : _ref$visitorId,
|
|
883
|
+
_ref$storyId = _ref.storyId,
|
|
884
|
+
providedStoryId = _ref$storyId === void 0 ? null : _ref$storyId,
|
|
882
885
|
_ref$onSuccess = _ref.onSuccess,
|
|
883
886
|
onSuccess = _ref$onSuccess === void 0 ? null : _ref$onSuccess;
|
|
884
887
|
|
|
@@ -889,6 +892,12 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
889
892
|
creating = _useState2[0],
|
|
890
893
|
setCreating = _useState2[1];
|
|
891
894
|
|
|
895
|
+
var _ref2 = useVisitor() || {},
|
|
896
|
+
visitorId = _ref2.id;
|
|
897
|
+
|
|
898
|
+
var _ref3 = useStory() || {},
|
|
899
|
+
storyId = _ref3.id;
|
|
900
|
+
|
|
892
901
|
var create = useCallback(function (data) {
|
|
893
902
|
if (api === null) {
|
|
894
903
|
return null;
|
|
@@ -897,7 +906,8 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
897
906
|
setCreating(true);
|
|
898
907
|
return api.quiz.create(_objectSpread({
|
|
899
908
|
screen_id: screenId,
|
|
900
|
-
visitor_id: visitorId
|
|
909
|
+
visitor_id: providedVisitorId || visitorId,
|
|
910
|
+
story_id: providedStoryId || storyId
|
|
901
911
|
}, data)).then(function (response) {
|
|
902
912
|
setCreating(false);
|
|
903
913
|
|
|
@@ -907,7 +917,7 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
907
917
|
|
|
908
918
|
return response;
|
|
909
919
|
});
|
|
910
|
-
}, [api, setCreating, onSuccess, screenId, visitorId]);
|
|
920
|
+
}, [api, setCreating, onSuccess, screenId, visitorId, storyId, providedVisitorId, providedStoryId]);
|
|
911
921
|
return {
|
|
912
922
|
create: create,
|
|
913
923
|
creating: creating
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var reactRouter = require('react-router');
|
|
|
15
15
|
var queryString = require('query-string');
|
|
16
16
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
17
17
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
18
|
+
var contexts = require('@micromag/core/contexts');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -895,7 +896,9 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
895
896
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
896
897
|
screenId = _ref.screenId,
|
|
897
898
|
_ref$visitorId = _ref.visitorId,
|
|
898
|
-
|
|
899
|
+
providedVisitorId = _ref$visitorId === void 0 ? null : _ref$visitorId,
|
|
900
|
+
_ref$storyId = _ref.storyId,
|
|
901
|
+
providedStoryId = _ref$storyId === void 0 ? null : _ref$storyId,
|
|
899
902
|
_ref$onSuccess = _ref.onSuccess,
|
|
900
903
|
onSuccess = _ref$onSuccess === void 0 ? null : _ref$onSuccess;
|
|
901
904
|
|
|
@@ -906,6 +909,12 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
906
909
|
creating = _useState2[0],
|
|
907
910
|
setCreating = _useState2[1];
|
|
908
911
|
|
|
912
|
+
var _ref2 = contexts.useVisitor() || {},
|
|
913
|
+
visitorId = _ref2.id;
|
|
914
|
+
|
|
915
|
+
var _ref3 = contexts.useStory() || {},
|
|
916
|
+
storyId = _ref3.id;
|
|
917
|
+
|
|
909
918
|
var create = React.useCallback(function (data) {
|
|
910
919
|
if (api === null) {
|
|
911
920
|
return null;
|
|
@@ -914,7 +923,8 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
914
923
|
setCreating(true);
|
|
915
924
|
return api.quiz.create(_objectSpread__default["default"]({
|
|
916
925
|
screen_id: screenId,
|
|
917
|
-
visitor_id: visitorId
|
|
926
|
+
visitor_id: providedVisitorId || visitorId,
|
|
927
|
+
story_id: providedStoryId || storyId
|
|
918
928
|
}, data)).then(function (response) {
|
|
919
929
|
setCreating(false);
|
|
920
930
|
|
|
@@ -924,7 +934,7 @@ var useQuizCreate = function useQuizCreate() {
|
|
|
924
934
|
|
|
925
935
|
return response;
|
|
926
936
|
});
|
|
927
|
-
}, [api, setCreating, onSuccess, screenId, visitorId]);
|
|
937
|
+
}, [api, setCreating, onSuccess, screenId, visitorId, storyId, providedVisitorId, providedStoryId]);
|
|
928
938
|
return {
|
|
929
939
|
create: create,
|
|
930
940
|
creating: creating
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/data",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.252",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.13.10",
|
|
52
52
|
"@folklore/fetch": "^0.1.15",
|
|
53
|
-
"@micromag/core": "^0.3.
|
|
53
|
+
"@micromag/core": "^0.3.252",
|
|
54
54
|
"prop-types": "^15.7.2",
|
|
55
55
|
"query-string": "^6.13.7",
|
|
56
56
|
"react-router": "^5.2.0"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "67a8b8144a40086a6dfd98c9eb8c4b6b8ebb05b0"
|
|
62
62
|
}
|