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