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