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