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