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