@elice/material-survey 1.240718.0-trasncript.0 → 1.240718.0-trasncript.2
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 +399 -0
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-survey/MaterialSurvey.js +82 -57
- package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
- package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
- package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
- package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
- package/cjs/components/material-survey/index.js +9 -0
- package/cjs/components/material-survey/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
- package/cjs/components/material-survey-edit/context.js +8 -2
- package/cjs/components/material-survey-edit/index.js +7 -0
- package/cjs/components/material-survey-edit/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/SurveyContentBox.js +85 -74
- package/cjs/components/shared/index.js +13 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
- package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-survey/MaterialSurvey.js +77 -57
- package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
- package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
- package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
- package/es/components/material-survey/MaterialSurveyText.js +109 -75
- package/es/components/material-survey/SurveyResultBadge.js +13 -10
- package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
- package/es/components/material-survey/index.js +2 -0
- package/es/components/material-survey/locales/index.js +4 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
- package/es/components/material-survey-edit/context.js +4 -2
- package/es/components/material-survey-edit/index.js +1 -0
- package/es/components/material-survey-edit/locales/index.js +4 -0
- package/es/components/material-survey-edit/utils/editValue.js +17 -11
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +81 -74
- package/es/components/shared/index.js +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
- package/package.json +9 -12
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
7
|
var React = require('react');
|
|
6
8
|
var apiClient = require('@elice/api-client');
|
|
7
9
|
var intl = require('@elice/intl');
|
|
@@ -16,51 +18,60 @@ var MaterialSurveyContext = require('./context/MaterialSurveyContext.js');
|
|
|
16
18
|
var SurveyResultBadge = require('./SurveyResultBadge.js');
|
|
17
19
|
var SurveySubmitStatusText = require('./SurveySubmitStatusText.js');
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
22
|
+
|
|
23
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
24
|
+
|
|
25
|
+
var MaterialSurveySelectOne = function MaterialSurveySelectOne() {
|
|
20
26
|
// context
|
|
21
|
-
|
|
22
|
-
course,
|
|
23
|
-
lecture,
|
|
24
|
-
materialSurvey,
|
|
25
|
-
userId
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
refreshOrgMaterialSurvey
|
|
31
|
-
} = MaterialSurveyContext.useMaterialSurveyDispatch();
|
|
27
|
+
var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
|
|
28
|
+
course = _useMaterialSurveySta.course,
|
|
29
|
+
lecture = _useMaterialSurveySta.lecture,
|
|
30
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey,
|
|
31
|
+
userId = _useMaterialSurveySta.userId;
|
|
32
|
+
var _useMaterialSurveyDis = MaterialSurveyContext.useMaterialSurveyDispatch(),
|
|
33
|
+
onSubmit = _useMaterialSurveyDis.onSubmit,
|
|
34
|
+
onNext = _useMaterialSurveyDis.onNext,
|
|
35
|
+
refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
|
|
32
36
|
// state
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
var intl$1 = intl.useRawEliceIntl();
|
|
38
|
+
var _React$useState = React__default.default.useState(),
|
|
39
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
40
|
+
selectedAnswer = _React$useState2[0],
|
|
41
|
+
setSelectedAnswer = _React$useState2[1];
|
|
42
|
+
var _React$useState3 = React__default.default.useState(),
|
|
43
|
+
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
44
|
+
materialSurveyResponse = _React$useState4[0],
|
|
45
|
+
setMaterialSurveyResponse = _React$useState4[1];
|
|
46
|
+
var _React$useState5 = React__default.default.useState('idle'),
|
|
47
|
+
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
48
|
+
submitStatus = _React$useState6[0],
|
|
49
|
+
setSubmitStatus = _React$useState6[1];
|
|
37
50
|
// survey response fetcher
|
|
38
|
-
|
|
51
|
+
React__default.default.useEffect(function () {
|
|
39
52
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
signal
|
|
43
|
-
} = controller;
|
|
53
|
+
var controller = new AbortController();
|
|
54
|
+
var signal = controller.signal;
|
|
44
55
|
apiClient.getOrgMaterialSurveyResponseGet({
|
|
45
56
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
46
57
|
}, {
|
|
47
|
-
signal
|
|
48
|
-
}).then(response
|
|
58
|
+
signal: signal
|
|
59
|
+
}).then(function (response) {
|
|
49
60
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
50
61
|
setSelectedAnswer(typeof response.surveyResponse.answers[0] === 'string' ? undefined : response.surveyResponse.answers[0][0]);
|
|
51
|
-
}).catch(error
|
|
62
|
+
}).catch(function (error) {
|
|
52
63
|
console.error(error);
|
|
53
64
|
});
|
|
54
|
-
return ()
|
|
65
|
+
return function () {
|
|
66
|
+
return controller.abort();
|
|
67
|
+
};
|
|
55
68
|
}
|
|
56
69
|
}, [materialSurvey, userId]);
|
|
57
70
|
// survey response fetcher
|
|
58
|
-
|
|
71
|
+
React__default.default.useEffect(function () {
|
|
59
72
|
if (userId && materialSurvey) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
signal
|
|
63
|
-
} = controller;
|
|
73
|
+
var controller = new AbortController();
|
|
74
|
+
var signal = controller.signal;
|
|
64
75
|
apiClient.getOrgMaterialSurveyResponseList({
|
|
65
76
|
materialSurveyId: materialSurvey.id,
|
|
66
77
|
filterUserIds: [userId],
|
|
@@ -69,55 +80,81 @@ const MaterialSurveySelectOne = () => {
|
|
|
69
80
|
offset: 0,
|
|
70
81
|
count: 1
|
|
71
82
|
}, {
|
|
72
|
-
signal
|
|
73
|
-
}).then(response
|
|
83
|
+
signal: signal
|
|
84
|
+
}).then(function (response) {
|
|
74
85
|
var _a;
|
|
75
|
-
|
|
86
|
+
var surveyResponse = response.surveyResponses[0];
|
|
76
87
|
setMaterialSurveyResponse(surveyResponse);
|
|
77
88
|
setSelectedAnswer(typeof (surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0]) === 'string' ? undefined : (_a = surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0][0]) !== null && _a !== void 0 ? _a : undefined);
|
|
78
|
-
}).catch(error
|
|
89
|
+
}).catch(function (error) {
|
|
79
90
|
console.error(error);
|
|
80
91
|
});
|
|
81
|
-
return ()
|
|
92
|
+
return function () {
|
|
93
|
+
return controller.abort();
|
|
94
|
+
};
|
|
82
95
|
}
|
|
83
96
|
}, [materialSurvey, userId]);
|
|
84
97
|
// submit handler
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
99
|
+
var _ref = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
|
100
|
+
var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
|
|
101
|
+
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
102
|
+
while (1) switch (_context.prev = _context.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
if (!(!materialSurvey || selectedAnswer === undefined)) {
|
|
105
|
+
_context.next = 2;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return _context.abrupt("return");
|
|
109
|
+
case 2:
|
|
110
|
+
setSubmitStatus('pending');
|
|
111
|
+
_context.prev = 3;
|
|
112
|
+
_context.next = 6;
|
|
113
|
+
return apiClient.postOrgMaterialSurveyResponseAdd({
|
|
114
|
+
materialSurveyId: materialSurvey.id,
|
|
115
|
+
answers: [[selectedAnswer]]
|
|
116
|
+
});
|
|
117
|
+
case 6:
|
|
118
|
+
_yield$postOrgMateria = _context.sent;
|
|
119
|
+
surveyResponseId = _yield$postOrgMateria.surveyResponseId;
|
|
120
|
+
_context.next = 10;
|
|
121
|
+
return apiClient.getOrgMaterialSurveyResponseGet({
|
|
122
|
+
surveyResponseId: surveyResponseId
|
|
123
|
+
});
|
|
124
|
+
case 10:
|
|
125
|
+
_yield$getOrgMaterial = _context.sent;
|
|
126
|
+
surveyResponse = _yield$getOrgMaterial.surveyResponse;
|
|
127
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
128
|
+
void refreshOrgMaterialSurvey();
|
|
129
|
+
onSubmit(true);
|
|
130
|
+
setSubmitStatus('resolved');
|
|
131
|
+
_context.next = 23;
|
|
132
|
+
break;
|
|
133
|
+
case 18:
|
|
134
|
+
_context.prev = 18;
|
|
135
|
+
_context.t0 = _context["catch"](3);
|
|
136
|
+
console.error(_context.t0);
|
|
137
|
+
onSubmit(false);
|
|
138
|
+
setSubmitStatus('rejected');
|
|
139
|
+
case 23:
|
|
140
|
+
case "end":
|
|
141
|
+
return _context.stop();
|
|
142
|
+
}
|
|
143
|
+
}, _callee, null, [[3, 18]]);
|
|
144
|
+
}));
|
|
145
|
+
return function handleSubmit() {
|
|
146
|
+
return _ref.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}();
|
|
149
|
+
return jsxRuntime.jsx(SurveyContentBox.default, {
|
|
113
150
|
title: intl$1.formatMessage({
|
|
114
151
|
id: 'materialSurvey.myAnswer'
|
|
115
152
|
}),
|
|
116
153
|
onNext: onNext,
|
|
117
|
-
submitStatus:
|
|
154
|
+
submitStatus: jsxRuntime.jsx(SurveySubmitStatusText.default, {
|
|
118
155
|
status: submitStatus
|
|
119
156
|
}),
|
|
120
|
-
submitResult:
|
|
157
|
+
submitResult: jsxRuntime.jsx(SurveyResultBadge.default, {
|
|
121
158
|
materialSurveyResponse: materialSurveyResponse
|
|
122
159
|
}),
|
|
123
160
|
footerActions: [{
|
|
@@ -131,27 +168,29 @@ const MaterialSurveySelectOne = () => {
|
|
|
131
168
|
children: intl$1.formatMessage({
|
|
132
169
|
id: 'materialSurvey.submit'
|
|
133
170
|
})
|
|
134
|
-
}]
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
171
|
+
}],
|
|
172
|
+
children: jsxRuntime.jsx(QuestionRadio.default, {
|
|
173
|
+
selectedValue: selectedAnswer,
|
|
174
|
+
onSelect: function onSelect(index$1) {
|
|
175
|
+
if (index.checkUserLectureTestEnded(lecture) || !!userId) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setSelectedAnswer(index$1);
|
|
179
|
+
},
|
|
180
|
+
disabled: submitStatus === 'pending' || index.checkUserLectureTestEnded(lecture) || !!userId,
|
|
181
|
+
children: (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0].optionInfo) ? materialSurvey.questionInfoList[0].optionInfo.map(function (option, index) {
|
|
182
|
+
return jsxRuntime.jsx(QuestionRadioOption.default, {
|
|
183
|
+
value: index,
|
|
184
|
+
children: (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? jsxRuntime.jsx(StyledMarkdown.default, {
|
|
185
|
+
dark: false,
|
|
186
|
+
children: option,
|
|
187
|
+
paddingx: 0,
|
|
188
|
+
paddingy: 0
|
|
189
|
+
}) : option
|
|
190
|
+
}, index);
|
|
191
|
+
}) : null
|
|
192
|
+
})
|
|
193
|
+
});
|
|
155
194
|
};
|
|
156
195
|
|
|
157
196
|
exports.default = MaterialSurveySelectOne;
|
|
@@ -2,56 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var blocks = require('@elice/blocks');
|
|
7
7
|
var designTokens = require('@elice/design-tokens');
|
|
8
8
|
var styled = require('styled-components');
|
|
9
9
|
var MaterialSurveyContext = require('./context/MaterialSurveyContext.js');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
14
|
+
|
|
15
|
+
var StyledShimmer = styled__default.default.div.withConfig({
|
|
12
16
|
componentId: "sc-1gtcofd-0"
|
|
13
|
-
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;"], ({
|
|
14
|
-
vertical
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;"], function (_ref) {
|
|
18
|
+
var vertical = _ref.vertical;
|
|
19
|
+
return vertical ? '0' : '8px';
|
|
20
|
+
});
|
|
21
|
+
var StyledShimmerHeader = styled__default.default.div.withConfig({
|
|
17
22
|
componentId: "sc-1gtcofd-1"
|
|
18
23
|
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;height:3.5rem;"], designTokens.base.color.navy6);
|
|
19
|
-
|
|
24
|
+
var StyledShimmerBody = styled__default.default.div.withConfig({
|
|
20
25
|
componentId: "sc-1gtcofd-2"
|
|
21
26
|
})(["padding:1.5rem;background-color:", ";overflow-y:auto;height:100%;"], designTokens.base.color.navy7);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
vertical
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
27
|
+
var MaterialSurveyShimmer = function MaterialSurveyShimmer() {
|
|
28
|
+
var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
|
|
29
|
+
vertical = _useMaterialSurveySta.vertical;
|
|
30
|
+
return jsxRuntime.jsxs(StyledShimmer, {
|
|
31
|
+
vertical: vertical,
|
|
32
|
+
children: [jsxRuntime.jsx(StyledShimmerHeader, {}), jsxRuntime.jsxs(StyledShimmerBody, {
|
|
33
|
+
children: [jsxRuntime.jsx(blocks.Shimmer, {
|
|
34
|
+
dark: true,
|
|
35
|
+
borderRadius: '4px',
|
|
36
|
+
width: "80%",
|
|
37
|
+
height: '40px'
|
|
38
|
+
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
39
|
+
height: 1
|
|
40
|
+
}), jsxRuntime.jsx(blocks.Shimmer, {
|
|
41
|
+
dark: true,
|
|
42
|
+
borderRadius: '4px',
|
|
43
|
+
width: "100%",
|
|
44
|
+
height: '40px'
|
|
45
|
+
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
46
|
+
height: 1
|
|
47
|
+
}), jsxRuntime.jsx(blocks.Shimmer, {
|
|
48
|
+
dark: true,
|
|
49
|
+
borderRadius: '4px',
|
|
50
|
+
width: "100%",
|
|
51
|
+
height: '40px'
|
|
52
|
+
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
53
|
+
height: 1
|
|
54
|
+
}), jsxRuntime.jsx(blocks.Shimmer, {
|
|
55
|
+
dark: true,
|
|
56
|
+
borderRadius: '4px',
|
|
57
|
+
width: "100%",
|
|
58
|
+
height: '40px'
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
exports.default = MaterialSurveyShimmer;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
7
|
var React = require('react');
|
|
6
8
|
var apiClient = require('@elice/api-client');
|
|
7
9
|
var designTokens = require('@elice/design-tokens');
|
|
@@ -13,55 +15,66 @@ var MaterialSurveyContext = require('./context/MaterialSurveyContext.js');
|
|
|
13
15
|
var SurveyResultBadge = require('./SurveyResultBadge.js');
|
|
14
16
|
var SurveySubmitStatusText = require('./SurveySubmitStatusText.js');
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
21
|
+
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
22
|
+
|
|
23
|
+
var StyledTextarea = styled__default.default.textarea.withConfig({
|
|
17
24
|
componentId: "sc-16tkulg-0"
|
|
18
|
-
})(["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, ({
|
|
19
|
-
disabled
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
})(["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) {
|
|
26
|
+
var disabled = _ref.disabled;
|
|
27
|
+
return disabled ? 'not-allowed' : 'text';
|
|
28
|
+
});
|
|
29
|
+
var MaterialSurveyText = function MaterialSurveyText() {
|
|
22
30
|
// context
|
|
23
|
-
|
|
24
|
-
lecture,
|
|
25
|
-
materialSurvey,
|
|
26
|
-
userId
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
refreshOrgMaterialSurvey
|
|
32
|
-
} = MaterialSurveyContext.useMaterialSurveyDispatch();
|
|
31
|
+
var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
|
|
32
|
+
lecture = _useMaterialSurveySta.lecture,
|
|
33
|
+
materialSurvey = _useMaterialSurveySta.materialSurvey,
|
|
34
|
+
userId = _useMaterialSurveySta.userId;
|
|
35
|
+
var _useMaterialSurveyDis = MaterialSurveyContext.useMaterialSurveyDispatch(),
|
|
36
|
+
onSubmit = _useMaterialSurveyDis.onSubmit,
|
|
37
|
+
onNext = _useMaterialSurveyDis.onNext,
|
|
38
|
+
refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
|
|
33
39
|
// state
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
var intl$1 = intl.useRawEliceIntl();
|
|
41
|
+
var _React$useState = React__default.default.useState(),
|
|
42
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
43
|
+
materialSurveyResponse = _React$useState2[0],
|
|
44
|
+
setMaterialSurveyResponse = _React$useState2[1];
|
|
45
|
+
var _React$useState3 = React__default.default.useState('idle'),
|
|
46
|
+
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
47
|
+
submitStatus = _React$useState4[0],
|
|
48
|
+
setSubmitStatus = _React$useState4[1];
|
|
49
|
+
var _React$useState5 = React__default.default.useState(''),
|
|
50
|
+
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
51
|
+
answer = _React$useState6[0],
|
|
52
|
+
setAnswer = _React$useState6[1];
|
|
38
53
|
// survey response fetcher
|
|
39
|
-
|
|
54
|
+
React__default.default.useEffect(function () {
|
|
40
55
|
if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
signal
|
|
44
|
-
} = controller;
|
|
56
|
+
var controller = new AbortController();
|
|
57
|
+
var signal = controller.signal;
|
|
45
58
|
apiClient.getOrgMaterialSurveyResponseGet({
|
|
46
59
|
surveyResponseId: materialSurvey.lastSurveyResponseId
|
|
47
60
|
}, {
|
|
48
|
-
signal
|
|
49
|
-
}).then(response
|
|
61
|
+
signal: signal
|
|
62
|
+
}).then(function (response) {
|
|
50
63
|
setMaterialSurveyResponse(response.surveyResponse);
|
|
51
64
|
setAnswer(response.surveyResponse.answers[0]);
|
|
52
|
-
}).catch(error
|
|
65
|
+
}).catch(function (error) {
|
|
53
66
|
console.error(error);
|
|
54
67
|
});
|
|
55
|
-
return ()
|
|
68
|
+
return function () {
|
|
69
|
+
return controller.abort();
|
|
70
|
+
};
|
|
56
71
|
}
|
|
57
72
|
}, [materialSurvey, userId]);
|
|
58
73
|
// survey response fetcher
|
|
59
|
-
|
|
74
|
+
React__default.default.useEffect(function () {
|
|
60
75
|
if (userId && materialSurvey) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
signal
|
|
64
|
-
} = controller;
|
|
76
|
+
var controller = new AbortController();
|
|
77
|
+
var signal = controller.signal;
|
|
65
78
|
apiClient.getOrgMaterialSurveyResponseList({
|
|
66
79
|
materialSurveyId: materialSurvey.id,
|
|
67
80
|
filterUserIds: [userId],
|
|
@@ -70,47 +83,72 @@ const MaterialSurveyText = () => {
|
|
|
70
83
|
offset: 0,
|
|
71
84
|
count: 1
|
|
72
85
|
}, {
|
|
73
|
-
signal
|
|
74
|
-
}).then(response
|
|
75
|
-
|
|
86
|
+
signal: signal
|
|
87
|
+
}).then(function (response) {
|
|
88
|
+
var surveyResponse = response.surveyResponses[0];
|
|
76
89
|
setMaterialSurveyResponse(surveyResponse);
|
|
77
90
|
setAnswer(typeof (surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0]) === 'string' ? surveyResponse.answers[0] : '');
|
|
78
|
-
}).catch(error
|
|
91
|
+
}).catch(function (error) {
|
|
79
92
|
console.error(error);
|
|
80
93
|
});
|
|
81
|
-
return ()
|
|
94
|
+
return function () {
|
|
95
|
+
return controller.abort();
|
|
96
|
+
};
|
|
82
97
|
}
|
|
83
98
|
}, [materialSurvey, userId]);
|
|
84
99
|
// submit handler
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
101
|
+
var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
|
102
|
+
var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
|
|
103
|
+
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
104
|
+
while (1) switch (_context.prev = _context.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
if (materialSurvey) {
|
|
107
|
+
_context.next = 2;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return _context.abrupt("return");
|
|
111
|
+
case 2:
|
|
112
|
+
setSubmitStatus('pending');
|
|
113
|
+
_context.prev = 3;
|
|
114
|
+
_context.next = 6;
|
|
115
|
+
return apiClient.postOrgMaterialSurveyResponseAdd({
|
|
116
|
+
materialSurveyId: materialSurvey.id,
|
|
117
|
+
answers: [answer] // FIXME: Type mismatch
|
|
118
|
+
});
|
|
119
|
+
case 6:
|
|
120
|
+
_yield$postOrgMateria = _context.sent;
|
|
121
|
+
surveyResponseId = _yield$postOrgMateria.surveyResponseId;
|
|
122
|
+
_context.next = 10;
|
|
123
|
+
return apiClient.getOrgMaterialSurveyResponseGet({
|
|
124
|
+
surveyResponseId: surveyResponseId
|
|
125
|
+
});
|
|
126
|
+
case 10:
|
|
127
|
+
_yield$getOrgMaterial = _context.sent;
|
|
128
|
+
surveyResponse = _yield$getOrgMaterial.surveyResponse;
|
|
129
|
+
setMaterialSurveyResponse(surveyResponse);
|
|
130
|
+
void refreshOrgMaterialSurvey();
|
|
131
|
+
onSubmit(true);
|
|
132
|
+
setSubmitStatus('resolved');
|
|
133
|
+
_context.next = 23;
|
|
134
|
+
break;
|
|
135
|
+
case 18:
|
|
136
|
+
_context.prev = 18;
|
|
137
|
+
_context.t0 = _context["catch"](3);
|
|
138
|
+
console.error(_context.t0);
|
|
139
|
+
onSubmit(false);
|
|
140
|
+
setSubmitStatus('rejected');
|
|
141
|
+
case 23:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee, null, [[3, 18]]);
|
|
146
|
+
}));
|
|
147
|
+
return function handleSubmit() {
|
|
148
|
+
return _ref2.apply(this, arguments);
|
|
149
|
+
};
|
|
150
|
+
}();
|
|
151
|
+
var commonProps = {
|
|
114
152
|
type: 'text',
|
|
115
153
|
autoFocus: answer.length === 0,
|
|
116
154
|
disabled: submitStatus === 'pending' || index.checkUserLectureTestEnded(lecture) || !!userId,
|
|
@@ -118,19 +156,19 @@ const MaterialSurveyText = () => {
|
|
|
118
156
|
id: 'materialSurvey.text.placeholder'
|
|
119
157
|
}),
|
|
120
158
|
value: answer,
|
|
121
|
-
onChange: e
|
|
159
|
+
onChange: function onChange(e) {
|
|
122
160
|
setAnswer(e.target.value);
|
|
123
161
|
}
|
|
124
162
|
};
|
|
125
|
-
return
|
|
163
|
+
return jsxRuntime.jsx(SurveyContentBox.default, {
|
|
126
164
|
title: intl$1.formatMessage({
|
|
127
165
|
id: 'materialSurvey.myAnswer'
|
|
128
166
|
}),
|
|
129
167
|
onNext: onNext,
|
|
130
|
-
submitResult:
|
|
168
|
+
submitResult: jsxRuntime.jsx(SurveyResultBadge.default, {
|
|
131
169
|
materialSurveyResponse: materialSurveyResponse
|
|
132
170
|
}),
|
|
133
|
-
submitStatus:
|
|
171
|
+
submitStatus: jsxRuntime.jsx(SurveySubmitStatusText.default, {
|
|
134
172
|
status: submitStatus
|
|
135
173
|
}),
|
|
136
174
|
footerActions: [{
|
|
@@ -144,10 +182,11 @@ const MaterialSurveyText = () => {
|
|
|
144
182
|
transparent: false,
|
|
145
183
|
role: 'primary',
|
|
146
184
|
onClick: handleSubmit
|
|
147
|
-
}]
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
185
|
+
}],
|
|
186
|
+
children: jsxRuntime.jsx(StyledTextarea, Object.assign({
|
|
187
|
+
id: "survey-text-answer"
|
|
188
|
+
}, commonProps))
|
|
189
|
+
});
|
|
151
190
|
};
|
|
152
191
|
|
|
153
192
|
exports.default = MaterialSurveyText;
|