@elice/material-survey 1.230328.0 → 1.230418.0
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/cjs/_virtual/_rollupPluginBabelHelpers.js +409 -0
- package/cjs/components/material-survey/MaterialSurvey.i18n.js +2 -2
- package/cjs/components/material-survey/MaterialSurvey.js +56 -51
- package/cjs/components/material-survey/MaterialSurveyInfo.js +6 -5
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +117 -91
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +110 -81
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +13 -12
- package/cjs/components/material-survey/MaterialSurveyText.js +111 -80
- package/cjs/components/material-survey/SurveyResultBadge.js +9 -8
- package/cjs/components/material-survey/SurveySubmitStatusText.js +6 -8
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +102 -79
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +45 -38
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +79 -83
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +71 -76
- package/cjs/components/material-survey-edit/context.js +4 -2
- package/cjs/components/material-survey-edit/locales.js +2 -2
- package/cjs/components/material-survey-edit/utils/editValue.js +17 -16
- package/cjs/components/shared/StyledMarkdown.js +4 -2
- package/cjs/components/shared/SurveyContentBox.js +48 -54
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +15 -18
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +48 -103
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -9
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +15 -18
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +41 -87
- package/cjs/helpers/index.js +0 -3
- package/cjs/index.js +7 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +394 -0
- package/es/components/material-survey/MaterialSurvey.i18n.js +2 -2
- package/es/components/material-survey/MaterialSurvey.js +51 -46
- package/es/components/material-survey/MaterialSurveyInfo.js +3 -4
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +109 -85
- package/es/components/material-survey/MaterialSurveySelectOne.js +102 -75
- package/es/components/material-survey/MaterialSurveyShimmer.js +10 -11
- package/es/components/material-survey/MaterialSurveyText.js +106 -77
- package/es/components/material-survey/SurveyResultBadge.js +6 -7
- package/es/components/material-survey/SurveySubmitStatusText.js +3 -7
- package/es/components/material-survey/context/MaterialSurveyContext.js +103 -80
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +41 -36
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +75 -81
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +68 -75
- package/es/components/material-survey-edit/context.js +4 -2
- package/es/components/material-survey-edit/locales.js +2 -2
- package/es/components/material-survey-edit/utils/editValue.js +17 -16
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +48 -54
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +4 -8
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +15 -18
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +45 -102
- package/es/components/shared/question-radio/QuestionRadio.js +4 -8
- package/es/components/shared/question-radio/QuestionRadioContext.js +15 -18
- package/es/components/shared/question-radio/QuestionRadioOption.js +38 -86
- package/es/helpers/index.js +0 -3
- package/package.json +8 -8
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
3
6
|
var React = require('react');
|
|
4
7
|
var reactIntl = require('react-intl');
|
|
5
8
|
var apiClient = require('@elice/api-client');
|
|
@@ -16,56 +19,61 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
19
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
20
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
var StyledTextarea = styled__default["default"].textarea.withConfig({
|
|
20
23
|
componentId: "sc-16tkulg-0"
|
|
21
|
-
})(["min-height:12rem;width:100%;padding:1rem 1.375rem;font-size:1rem;color:", ";border-radius:4px;resize:vertical;line-height:1.5rem;outline:none;background-color:", ";&::placeholder{color:", ";}&:hover{cursor:", ";}"], designTokens.base.color.navy2, designTokens.base.color.navy5, designTokens.base.color.navy2, ({
|
|
22
|
-
disabled
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
})(["min-height:12rem;width:100%;padding:1rem 1.375rem;font-size:1rem;color:", ";border-radius:4px;resize:vertical;line-height:1.5rem;outline:none;background-color:", ";&::placeholder{color:", ";}&:hover{cursor:", ";}"], designTokens.base.color.navy2, designTokens.base.color.navy5, designTokens.base.color.navy2, function (_ref) {
|
|
25
|
+
var disabled = _ref.disabled;
|
|
26
|
+
return disabled ? 'not-allowed' : 'text';
|
|
27
|
+
});
|
|
28
|
+
var MaterialSurveyText = function MaterialSurveyText() {
|
|
26
29
|
// context
|
|
27
|
-
|
|
28
|
-
lecture,
|
|
29
|
-
materialSurvey,
|
|
30
|
-
userId
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
|
|
31
|
+
lecture = _useMaterialSurveySta.lecture,
|
|
32
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey,
|
|
33
|
+
userId = _useMaterialSurveySta.userId;
|
|
34
|
+
var _useMaterialSurveyDis = MaterialSurveyContext.useMaterialSurveyDispatch(),
|
|
35
|
+
onSubmit = _useMaterialSurveyDis.onSubmit,
|
|
36
|
+
onNext = _useMaterialSurveyDis.onNext,
|
|
37
|
+
refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
|
|
38
|
+
// state
|
|
39
|
+
var intl = reactIntl.useIntl();
|
|
40
|
+
var _React$useState = React__default["default"].useState(),
|
|
41
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
42
|
+
materialSurveyResponse = _React$useState2[0],
|
|
43
|
+
setMaterialSurveyResponse = _React$useState2[1];
|
|
44
|
+
var _React$useState3 = React__default["default"].useState('idle'),
|
|
45
|
+
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
46
|
+
submitStatus = _React$useState4[0],
|
|
47
|
+
setSubmitStatus = _React$useState4[1];
|
|
48
|
+
var _React$useState5 = React__default["default"].useState(''),
|
|
49
|
+
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
50
|
+
answer = _React$useState6[0],
|
|
51
|
+
setAnswer = _React$useState6[1];
|
|
52
|
+
// survey response fetcher
|
|
53
|
+
React__default["default"].useEffect(function () {
|
|
44
54
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
signal
|
|
48
|
-
} = controller;
|
|
55
|
+
var controller = new AbortController();
|
|
56
|
+
var signal = controller.signal;
|
|
49
57
|
apiClient.getOrgMaterialSurveyResponseGet({
|
|
50
58
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
51
59
|
}, {
|
|
52
|
-
signal
|
|
53
|
-
}).then(response
|
|
60
|
+
signal: signal
|
|
61
|
+
}).then(function (response) {
|
|
54
62
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
55
63
|
setAnswer(response.surveyResponse.answers[0]);
|
|
56
|
-
}).catch(error
|
|
64
|
+
}).catch(function (error) {
|
|
57
65
|
console.error(error);
|
|
58
66
|
});
|
|
59
|
-
return ()
|
|
67
|
+
return function () {
|
|
68
|
+
return controller.abort();
|
|
69
|
+
};
|
|
60
70
|
}
|
|
61
|
-
}, [materialSurvey, userId]);
|
|
62
|
-
|
|
63
|
-
React__default["default"].useEffect(()
|
|
71
|
+
}, [materialSurvey, userId]);
|
|
72
|
+
// survey response fetcher
|
|
73
|
+
React__default["default"].useEffect(function () {
|
|
64
74
|
if (userId && materialSurvey) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
signal
|
|
68
|
-
} = controller;
|
|
75
|
+
var controller = new AbortController();
|
|
76
|
+
var signal = controller.signal;
|
|
69
77
|
apiClient.getOrgMaterialSurveyResponseList({
|
|
70
78
|
materialSurveyId: materialSurvey.id,
|
|
71
79
|
filterUserIds: [userId],
|
|
@@ -74,49 +82,72 @@ const MaterialSurveyText = () => {
|
|
|
74
82
|
offset: 0,
|
|
75
83
|
count: 1
|
|
76
84
|
}, {
|
|
77
|
-
signal
|
|
78
|
-
}).then(response
|
|
79
|
-
|
|
85
|
+
signal: signal
|
|
86
|
+
}).then(function (response) {
|
|
87
|
+
var surveyResponse = response.surveyResponses[0];
|
|
80
88
|
setMaterialSurveyResponse(surveyResponse);
|
|
81
89
|
setAnswer(typeof (surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0]) === 'string' ? surveyResponse.answers[0] : '');
|
|
82
|
-
}).catch(error
|
|
90
|
+
}).catch(function (error) {
|
|
83
91
|
console.error(error);
|
|
84
92
|
});
|
|
85
|
-
return ()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const handleSubmit = async () => {
|
|
90
|
-
if (!materialSurvey) {
|
|
91
|
-
return;
|
|
93
|
+
return function () {
|
|
94
|
+
return controller.abort();
|
|
95
|
+
};
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
97
|
+
}, [materialSurvey, userId]);
|
|
98
|
+
// submit handler
|
|
99
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
100
|
+
var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
|
101
|
+
var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
|
|
102
|
+
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
103
|
+
while (1) switch (_context.prev = _context.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (materialSurvey) {
|
|
106
|
+
_context.next = 2;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return _context.abrupt("return");
|
|
110
|
+
case 2:
|
|
111
|
+
setSubmitStatus('pending');
|
|
112
|
+
_context.prev = 3;
|
|
113
|
+
_context.next = 6;
|
|
114
|
+
return apiClient.postOrgMaterialSurveyResponseAdd({
|
|
115
|
+
materialSurveyId: materialSurvey.id,
|
|
116
|
+
answers: [answer]
|
|
117
|
+
});
|
|
118
|
+
case 6:
|
|
119
|
+
_yield$postOrgMateria = _context.sent;
|
|
120
|
+
surveyResponseId = _yield$postOrgMateria.surveyResponseId;
|
|
121
|
+
_context.next = 10;
|
|
122
|
+
return apiClient.getOrgMaterialSurveyResponseGet({
|
|
123
|
+
surveyResponseId: surveyResponseId
|
|
124
|
+
});
|
|
125
|
+
case 10:
|
|
126
|
+
_yield$getOrgMaterial = _context.sent;
|
|
127
|
+
surveyResponse = _yield$getOrgMaterial.surveyResponse;
|
|
128
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
129
|
+
void refreshOrgMaterialSurvey();
|
|
130
|
+
onSubmit(true);
|
|
131
|
+
setSubmitStatus('resolved');
|
|
132
|
+
_context.next = 23;
|
|
133
|
+
break;
|
|
134
|
+
case 18:
|
|
135
|
+
_context.prev = 18;
|
|
136
|
+
_context.t0 = _context["catch"](3);
|
|
137
|
+
console.error(_context.t0);
|
|
138
|
+
onSubmit(false);
|
|
139
|
+
setSubmitStatus('rejected');
|
|
140
|
+
case 23:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context.stop();
|
|
143
|
+
}
|
|
144
|
+
}, _callee, null, [[3, 18]]);
|
|
145
|
+
}));
|
|
146
|
+
return function handleSubmit() {
|
|
147
|
+
return _ref2.apply(this, arguments);
|
|
148
|
+
};
|
|
149
|
+
}();
|
|
150
|
+
var commonProps = {
|
|
120
151
|
type: 'text',
|
|
121
152
|
autoFocus: answer.length === 0,
|
|
122
153
|
disabled: submitStatus === 'pending' || index.checkUserLectureTestEnded(lecture) || !!userId,
|
|
@@ -124,7 +155,7 @@ const MaterialSurveyText = () => {
|
|
|
124
155
|
id: 'materialSurvey.text.placeholder'
|
|
125
156
|
}),
|
|
126
157
|
value: answer,
|
|
127
|
-
onChange: e
|
|
158
|
+
onChange: function onChange(e) {
|
|
128
159
|
setAnswer(e.target.value);
|
|
129
160
|
}
|
|
130
161
|
};
|
|
@@ -133,10 +164,10 @@ const MaterialSurveyText = () => {
|
|
|
133
164
|
id: 'materialSurvey.myAnswer'
|
|
134
165
|
}),
|
|
135
166
|
onNext: onNext,
|
|
136
|
-
submitResult: React__default["default"].createElement(SurveyResultBadge, {
|
|
167
|
+
submitResult: React__default["default"].createElement(SurveyResultBadge["default"], {
|
|
137
168
|
materialSurveyResponse: materialSurveyResponse
|
|
138
169
|
}),
|
|
139
|
-
submitStatus: React__default["default"].createElement(SurveySubmitStatusText, {
|
|
170
|
+
submitStatus: React__default["default"].createElement(SurveySubmitStatusText["default"], {
|
|
140
171
|
status: submitStatus
|
|
141
172
|
}),
|
|
142
173
|
footerActions: [{
|
|
@@ -156,4 +187,4 @@ const MaterialSurveyText = () => {
|
|
|
156
187
|
}, commonProps)));
|
|
157
188
|
};
|
|
158
189
|
|
|
159
|
-
|
|
190
|
+
exports["default"] = MaterialSurveyText;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var React = require('react');
|
|
4
6
|
var reactIntl = require('react-intl');
|
|
5
7
|
var blocks = require('@elice/blocks');
|
|
@@ -9,12 +11,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
11
|
|
|
10
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
materialSurveyResponse
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
var SurveyResultBadge = function SurveyResultBadge(_ref) {
|
|
15
|
+
var materialSurveyResponse = _ref.materialSurveyResponse;
|
|
16
|
+
var intl = reactIntl.useIntl();
|
|
17
|
+
var status = React__default["default"].useMemo(function () {
|
|
18
|
+
return index.getSurveyResultStatus(materialSurveyResponse);
|
|
19
|
+
}, [materialSurveyResponse]);
|
|
18
20
|
switch (status) {
|
|
19
21
|
case index.SurveyResultStatus.Submitted:
|
|
20
22
|
return React__default["default"].createElement(blocks.BadgeNext, {
|
|
@@ -23,10 +25,9 @@ const SurveyResultBadge = ({
|
|
|
23
25
|
}, intl.formatMessage({
|
|
24
26
|
id: 'materialSurvey.resultStatus.submitted'
|
|
25
27
|
}));
|
|
26
|
-
|
|
27
28
|
default:
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
exports["default"] = SurveyResultBadge;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var React = require('react');
|
|
4
6
|
var reactIntl = require('react-intl');
|
|
5
7
|
var blocks = require('@elice/blocks');
|
|
@@ -8,11 +10,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
10
|
|
|
9
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
status
|
|
13
|
-
|
|
14
|
-
const intl = reactIntl.useIntl();
|
|
15
|
-
|
|
13
|
+
var SurveySubmitStatusText = function SurveySubmitStatusText(_ref) {
|
|
14
|
+
var status = _ref.status;
|
|
15
|
+
var intl = reactIntl.useIntl();
|
|
16
16
|
switch (status) {
|
|
17
17
|
case 'resolved':
|
|
18
18
|
return React__default["default"].createElement(blocks.StatusText, {
|
|
@@ -21,7 +21,6 @@ const SurveySubmitStatusText = ({
|
|
|
21
21
|
}, intl.formatMessage({
|
|
22
22
|
id: 'materialSurvey.submitStatus.success'
|
|
23
23
|
}));
|
|
24
|
-
|
|
25
24
|
case 'rejected':
|
|
26
25
|
return React__default["default"].createElement(blocks.StatusText, {
|
|
27
26
|
role: "danger",
|
|
@@ -29,10 +28,9 @@ const SurveySubmitStatusText = ({
|
|
|
29
28
|
}, intl.formatMessage({
|
|
30
29
|
id: 'materialSurvey.submitStatus.failure'
|
|
31
30
|
}));
|
|
32
|
-
|
|
33
31
|
default:
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
exports["default"] = SurveySubmitStatusText;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var apiClient = require('@elice/api-client');
|
|
7
8
|
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
@@ -11,112 +12,134 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
12
|
|
|
12
13
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
var StateContext = React__default["default"].createContext(undefined);
|
|
16
|
+
var DispatchContext = React__default["default"].createContext(undefined);
|
|
16
17
|
StateContext.displayName = 'MaterialSurveyStateContext';
|
|
17
18
|
DispatchContext.displayName = 'MaterialSurveyDispatchContext';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setInitStatus('pending');
|
|
48
|
-
|
|
49
|
-
if (!materialLecturePage) {
|
|
50
|
-
throw new Error('materialSurvey is not ready');
|
|
51
|
-
} // fetch course
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const {
|
|
55
|
-
course
|
|
56
|
-
} = await apiClient.getOrgCourseGet({
|
|
57
|
-
courseId: materialLecturePage.courseId
|
|
58
|
-
}, {
|
|
59
|
-
signal
|
|
60
|
-
}); // fetch lecture
|
|
61
|
-
|
|
62
|
-
const {
|
|
63
|
-
lecture
|
|
64
|
-
} = await apiClient.getOrgLectureGet({
|
|
65
|
-
lectureId: materialLecturePage.lectureId
|
|
19
|
+
function MaterialSurveyProvider(_ref) {
|
|
20
|
+
var materialSurveyId = _ref.materialSurveyId,
|
|
21
|
+
userId = _ref.userId,
|
|
22
|
+
_ref$onSubmit = _ref.onSubmit,
|
|
23
|
+
onSubmit = _ref$onSubmit === void 0 ? function () {
|
|
24
|
+
return void 0;
|
|
25
|
+
} : _ref$onSubmit,
|
|
26
|
+
onNext = _ref.onNext,
|
|
27
|
+
children = _ref.children;
|
|
28
|
+
var _React$useState = React__default["default"].useState(),
|
|
29
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
30
|
+
course = _React$useState2[0],
|
|
31
|
+
setCourse = _React$useState2[1];
|
|
32
|
+
var _React$useState3 = React__default["default"].useState(),
|
|
33
|
+
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
34
|
+
lecture = _React$useState4[0],
|
|
35
|
+
setLecture = _React$useState4[1];
|
|
36
|
+
var _React$useState5 = React__default["default"].useState('idle'),
|
|
37
|
+
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
38
|
+
initStatus = _React$useState6[0],
|
|
39
|
+
setInitStatus = _React$useState6[1];
|
|
40
|
+
var _React$useState7 = React__default["default"].useState(false),
|
|
41
|
+
_React$useState8 = _rollupPluginBabelHelpers.slicedToArray(_React$useState7, 2),
|
|
42
|
+
vertical = _React$useState8[0],
|
|
43
|
+
setVertical = _React$useState8[1];
|
|
44
|
+
var canInit = materialSharedUtils.useMaterialConfigApiClientUpdate(apiClient.config.init);
|
|
45
|
+
var _useMaterialFetchRaw = materialSharedUtils.useMaterialFetchRaw(types.enums.LectureMaterialType.Survey, React__default["default"].useCallback(function (signal) {
|
|
46
|
+
return apiClient.getOrgMaterialSurveyGet({
|
|
47
|
+
materialSurveyId: materialSurveyId
|
|
66
48
|
}, {
|
|
67
|
-
signal
|
|
49
|
+
signal: signal
|
|
68
50
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
51
|
+
}, [materialSurveyId]), canInit),
|
|
52
|
+
materialSurvey = _useMaterialFetchRaw.materialSurvey,
|
|
53
|
+
materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
|
|
54
|
+
refreshOrgMaterialSurvey = _useMaterialFetchRaw.refetch;
|
|
55
|
+
var doInitilize = React__default["default"].useCallback( /*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
|
56
|
+
var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
|
|
57
|
+
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
controller = new AbortController();
|
|
61
|
+
signal = controller.signal;
|
|
62
|
+
_context.prev = 2;
|
|
63
|
+
setInitStatus('pending');
|
|
64
|
+
if (materialLecturePage) {
|
|
65
|
+
_context.next = 6;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
throw new Error('materialSurvey is not ready');
|
|
69
|
+
case 6:
|
|
70
|
+
_context.next = 8;
|
|
71
|
+
return apiClient.getOrgCourseGet({
|
|
72
|
+
courseId: materialLecturePage.courseId
|
|
73
|
+
}, {
|
|
74
|
+
signal: signal
|
|
75
|
+
});
|
|
76
|
+
case 8:
|
|
77
|
+
_yield$getOrgCourseGe = _context.sent;
|
|
78
|
+
_course = _yield$getOrgCourseGe.course;
|
|
79
|
+
_context.next = 12;
|
|
80
|
+
return apiClient.getOrgLectureGet({
|
|
81
|
+
lectureId: materialLecturePage.lectureId
|
|
82
|
+
}, {
|
|
83
|
+
signal: signal
|
|
84
|
+
});
|
|
85
|
+
case 12:
|
|
86
|
+
_yield$getOrgLectureG = _context.sent;
|
|
87
|
+
_lecture = _yield$getOrgLectureG.lecture;
|
|
88
|
+
setCourse(_course);
|
|
89
|
+
setLecture(_lecture);
|
|
90
|
+
setInitStatus('resolved');
|
|
91
|
+
_context.next = 23;
|
|
92
|
+
break;
|
|
93
|
+
case 19:
|
|
94
|
+
_context.prev = 19;
|
|
95
|
+
_context.t0 = _context["catch"](2);
|
|
96
|
+
console.error(_context.t0);
|
|
97
|
+
setInitStatus('rejected');
|
|
98
|
+
case 23:
|
|
99
|
+
return _context.abrupt("return", function () {
|
|
100
|
+
return controller.abort();
|
|
101
|
+
});
|
|
102
|
+
case 24:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee, null, [[2, 19]]);
|
|
107
|
+
})), [materialLecturePage]);
|
|
108
|
+
React__default["default"].useEffect(function () {
|
|
80
109
|
if (canInit && materialLecturePage) {
|
|
81
110
|
void doInitilize();
|
|
82
111
|
}
|
|
83
112
|
}, [canInit, materialLecturePage, doInitilize]);
|
|
84
113
|
return React__default["default"].createElement(StateContext.Provider, {
|
|
85
114
|
value: {
|
|
86
|
-
course,
|
|
87
|
-
lecture,
|
|
115
|
+
course: course,
|
|
116
|
+
lecture: lecture,
|
|
88
117
|
materialSurvey: materialSurvey !== null && materialSurvey !== void 0 ? materialSurvey : undefined,
|
|
89
|
-
userId,
|
|
90
|
-
vertical,
|
|
91
|
-
initStatus
|
|
118
|
+
userId: userId,
|
|
119
|
+
vertical: vertical,
|
|
120
|
+
initStatus: initStatus
|
|
92
121
|
}
|
|
93
122
|
}, React__default["default"].createElement(DispatchContext.Provider, {
|
|
94
123
|
value: {
|
|
95
|
-
onSubmit,
|
|
96
|
-
onNext,
|
|
97
|
-
refreshOrgMaterialSurvey,
|
|
98
|
-
setVertical
|
|
124
|
+
onSubmit: onSubmit,
|
|
125
|
+
onNext: onNext,
|
|
126
|
+
refreshOrgMaterialSurvey: refreshOrgMaterialSurvey,
|
|
127
|
+
setVertical: setVertical
|
|
99
128
|
}
|
|
100
129
|
}, children));
|
|
101
130
|
}
|
|
102
|
-
|
|
103
131
|
function useMaterialSurveyState() {
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
var context = React__default["default"].useContext(StateContext);
|
|
106
133
|
if (context === undefined) {
|
|
107
134
|
throw new Error('useMaterialSurveyState must be used within a MaterialSurveyProvider');
|
|
108
135
|
}
|
|
109
|
-
|
|
110
136
|
return context;
|
|
111
137
|
}
|
|
112
|
-
|
|
113
138
|
function useMaterialSurveyDispatch() {
|
|
114
|
-
|
|
115
|
-
|
|
139
|
+
var context = React__default["default"].useContext(DispatchContext);
|
|
116
140
|
if (context === undefined) {
|
|
117
141
|
throw new Error('useMaterialSurveyDispatch must be used within a MaterialSurveyProvider');
|
|
118
142
|
}
|
|
119
|
-
|
|
120
143
|
return context;
|
|
121
144
|
}
|
|
122
145
|
|