@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
@@ -1,3 +1,5 @@
1
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
1
3
  import React from 'react';
2
4
  import { useMeasure } from 'react-use';
3
5
  import { base } from '@elice/design-tokens';
@@ -10,83 +12,101 @@ import messageKo from './locales/ko.json.js';
10
12
  import MaterialSurveyShimmer from './MaterialSurveyShimmer.js';
11
13
  import MaterialSurveyInfo from './MaterialSurveyInfo.js';
12
14
 
13
- const AsyncMaterialSurveySelectMultiple = React.lazy(() => import('./MaterialSurveySelectMultiple.js'));
14
- const AsyncMaterialSurveyText = React.lazy(() => import('./MaterialSurveyText.js'));
15
- const AsyncMaterialSurveySelectOne = React.lazy(() => import('./MaterialSurveySelectOne.js'));
16
- const StyledMaterialSurveyInfo = styled.div.withConfig({
15
+ var AsyncMaterialSurveySelectMultiple = React.lazy(function () {
16
+ return import('./MaterialSurveySelectMultiple.js');
17
+ });
18
+ var AsyncMaterialSurveyText = React.lazy(function () {
19
+ return import('./MaterialSurveyText.js');
20
+ });
21
+ var AsyncMaterialSurveySelectOne = React.lazy(function () {
22
+ return import('./MaterialSurveySelectOne.js');
23
+ });
24
+ var StyledMaterialSurveyInfo = styled.div.withConfig({
17
25
  componentId: "sc-1fyzkvm-0"
18
26
  })([""]);
19
- const StyledMaterialSurveyContent = styled.div.withConfig({
27
+ var StyledMaterialSurveyContent = styled.div.withConfig({
20
28
  componentId: "sc-1fyzkvm-1"
21
29
  })([""]);
22
- const StyledMaterialSurveyWrapper = styled.div.withConfig({
30
+ var StyledMaterialSurveyWrapper = styled.div.withConfig({
23
31
  componentId: "sc-1fyzkvm-2"
24
- })(["display:flex;height:100%;flex-direction:", ";& > *{flex:", ";}& > *:first-child{margin-right:", ";margin-bottom:", ";}", "{height:", ";overflow-y:", ";}"], ({
25
- vertical
26
- }) => vertical ? 'column' : 'row', ({
27
- vertical
28
- }) => vertical ? 'auto' : '1 0 calc(50% - 1rem);', ({
29
- vertical
30
- }) => vertical ? '0' : '1rem', ({
31
- vertical
32
- }) => vertical ? '1rem' : '0', StyledMaterialSurveyInfo, ({
33
- vertical
34
- }) => vertical ? 'auto' : '100%', ({
35
- vertical
36
- }) => vertical ? 'intial' : 'auto');
37
- const MaterialSurvey = () => {
38
- const {
39
- materialSurvey,
40
- vertical
41
- } = useMaterialSurveyState();
42
- const {
43
- setVertical
44
- } = useMaterialSurveyDispatch();
45
- const [ref, {
46
- width
47
- }] = useMeasure();
48
- React.useEffect(() => {
32
+ })(["display:flex;height:100%;flex-direction:", ";& > *{flex:", ";}& > *:first-child{margin-right:", ";margin-bottom:", ";}", "{height:", ";overflow-y:", ";}"], function (_ref) {
33
+ var vertical = _ref.vertical;
34
+ return vertical ? 'column' : 'row';
35
+ }, function (_ref2) {
36
+ var vertical = _ref2.vertical;
37
+ return vertical ? 'auto' : '1 0 calc(50% - 1rem);';
38
+ }, function (_ref3) {
39
+ var vertical = _ref3.vertical;
40
+ return vertical ? '0' : '1rem';
41
+ }, function (_ref4) {
42
+ var vertical = _ref4.vertical;
43
+ return vertical ? '1rem' : '0';
44
+ }, StyledMaterialSurveyInfo, function (_ref5) {
45
+ var vertical = _ref5.vertical;
46
+ return vertical ? 'auto' : '100%';
47
+ }, function (_ref6) {
48
+ var vertical = _ref6.vertical;
49
+ return vertical ? 'intial' : 'auto';
50
+ });
51
+ var MaterialSurvey = function MaterialSurvey() {
52
+ var _useMaterialSurveySta = useMaterialSurveyState(),
53
+ materialSurvey = _useMaterialSurveySta.materialSurvey,
54
+ vertical = _useMaterialSurveySta.vertical;
55
+ var _useMaterialSurveyDis = useMaterialSurveyDispatch(),
56
+ setVertical = _useMaterialSurveyDis.setVertical;
57
+ var _useMeasure = useMeasure(),
58
+ _useMeasure2 = _slicedToArray(_useMeasure, 2),
59
+ ref = _useMeasure2[0],
60
+ width = _useMeasure2[1].width;
61
+ React.useEffect(function () {
49
62
  if (width > 0) {
50
63
  setVertical(width <= base.screen.medium);
51
64
  }
52
65
  }, [width, setVertical]);
53
- let Component = null;
66
+ var Component = null;
54
67
  switch (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0].optionType) {
55
68
  case enums.SurveyOptionType.SelectOne:
56
- Component = React.createElement(AsyncMaterialSurveySelectOne, null);
69
+ Component = jsx(AsyncMaterialSurveySelectOne, {});
57
70
  break;
58
71
  case enums.SurveyOptionType.SelectMultiple:
59
- Component = React.createElement(AsyncMaterialSurveySelectMultiple, null);
72
+ Component = jsx(AsyncMaterialSurveySelectMultiple, {});
60
73
  break;
61
74
  case enums.SurveyOptionType.Text:
62
- Component = React.createElement(AsyncMaterialSurveyText, null);
75
+ Component = jsx(AsyncMaterialSurveyText, {});
63
76
  break;
64
77
  default:
65
- Component = React.createElement(MaterialSurveyShimmer, null);
78
+ Component = jsx(MaterialSurveyShimmer, {});
66
79
  break;
67
80
  }
68
- return React.createElement(React.Suspense, {
69
- fallback: null
70
- }, React.createElement(StyledMaterialSurveyWrapper, {
71
- ref: ref,
72
- vertical: vertical
73
- }, React.createElement(StyledMaterialSurveyInfo, null, React.createElement(MaterialSurveyInfo, null)), React.createElement(StyledMaterialSurveyContent, null, Component)));
81
+ return jsx(React.Suspense, {
82
+ fallback: null,
83
+ children: jsxs(StyledMaterialSurveyWrapper, {
84
+ ref: ref,
85
+ vertical: vertical,
86
+ children: [jsx(StyledMaterialSurveyInfo, {
87
+ children: jsx(MaterialSurveyInfo, {})
88
+ }), jsx(StyledMaterialSurveyContent, {
89
+ children: Component
90
+ })]
91
+ })
92
+ });
74
93
  };
75
- const MaterialSurveyContainer = ({
76
- materialSurveyId,
77
- userId,
78
- onSubmit,
79
- onNext,
80
- __intl
81
- }) => {
82
- return React.createElement(RawEliceIntlProvider, {
83
- value: __intl
84
- }, React.createElement(MaterialSurveyProvider, {
85
- materialSurveyId: materialSurveyId,
86
- userId: userId,
87
- onSubmit: onSubmit,
88
- onNext: onNext
89
- }, React.createElement(MaterialSurvey, null)));
94
+ var MaterialSurveyContainer = function MaterialSurveyContainer(_ref7) {
95
+ var materialSurveyId = _ref7.materialSurveyId,
96
+ userId = _ref7.userId,
97
+ onSubmit = _ref7.onSubmit,
98
+ onNext = _ref7.onNext,
99
+ __intl = _ref7.__intl;
100
+ return jsx(RawEliceIntlProvider, {
101
+ value: __intl,
102
+ children: jsx(MaterialSurveyProvider, {
103
+ materialSurveyId: materialSurveyId,
104
+ userId: userId,
105
+ onSubmit: onSubmit,
106
+ onNext: onNext,
107
+ children: jsx(MaterialSurvey, {})
108
+ })
109
+ });
90
110
  };
91
111
  var MaterialSurvey$1 = new IntlComponentBuilder(MaterialSurveyContainer).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
92
112
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { Flex, Text, Shimmer, Vspace } from '@elice/blocks';
3
3
  import { base } from '@elice/design-tokens';
4
4
  import { MarkdownSSR } from '@elice/markdown';
@@ -7,66 +7,72 @@ import styled from 'styled-components';
7
7
  import SurveyContentBox from '../shared/SurveyContentBox.js';
8
8
  import { useMaterialSurveyState } from './context/MaterialSurveyContext.js';
9
9
 
10
- const StyledMarkdownSSR = styled(MarkdownSSR).withConfig({
10
+ var StyledMarkdownSSR = styled(MarkdownSSR).withConfig({
11
11
  componentId: "sc-1b9l43w-0"
12
12
  })(["", ""], EliceWysiwygEditorTheme.resetMarkdownSSR);
13
- const MaterialSurveyInfo = () => {
14
- const {
15
- materialSurvey
16
- } = useMaterialSurveyState();
17
- return React.createElement(SurveyContentBox, {
18
- title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title
19
- }, materialSurvey ? React.createElement(Flex, null, React.createElement(Text, {
20
- bold: true,
21
- size: "large",
22
- customStyles: {
23
- color: base.color.primary3,
24
- marginRight: '0.5rem'
25
- }
26
- }, 'Q.'), React.createElement(Text, {
27
- bold: true,
28
- role: "white",
29
- size: "large",
30
- wordBreak: "break-word"
31
- }, materialSurvey.questionInfoList[0].questionTitle)) : React.createElement(Shimmer, {
32
- dark: true,
33
- borderRadius: '4px',
34
- width: "80%",
35
- height: '40px'
36
- }), React.createElement(Vspace, {
37
- height: 1
38
- }), materialSurvey ? React.createElement(StyledMarkdownSSR, {
39
- children: materialSurvey.questionInfoList[0].questionDescription,
40
- dark: true,
41
- paddingx: 0,
42
- paddingy: 0
43
- }) : React.createElement(React.Fragment, null, React.createElement(Shimmer, {
44
- dark: true,
45
- borderRadius: '4px',
46
- width: "80%",
47
- height: '40px'
48
- }), React.createElement(Vspace, {
49
- height: 1
50
- }), React.createElement(Shimmer, {
51
- dark: true,
52
- borderRadius: '4px',
53
- width: "100%",
54
- height: '40px'
55
- }), React.createElement(Vspace, {
56
- height: 1
57
- }), React.createElement(Shimmer, {
58
- dark: true,
59
- borderRadius: '4px',
60
- width: "100%",
61
- height: '40px'
62
- }), React.createElement(Vspace, {
63
- height: 1
64
- }), React.createElement(Shimmer, {
65
- dark: true,
66
- borderRadius: '4px',
67
- width: "100%",
68
- height: '40px'
69
- })));
13
+ var MaterialSurveyInfo = function MaterialSurveyInfo() {
14
+ var _useMaterialSurveySta = useMaterialSurveyState(),
15
+ materialSurvey = _useMaterialSurveySta.materialSurvey;
16
+ return jsxs(SurveyContentBox, {
17
+ title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title,
18
+ children: [materialSurvey ? jsxs(Flex, {
19
+ children: [jsx(Text, {
20
+ bold: true,
21
+ size: "large",
22
+ customStyles: {
23
+ color: base.color.primary3,
24
+ marginRight: '0.5rem'
25
+ },
26
+ children: 'Q.'
27
+ }), jsx(Text, {
28
+ bold: true,
29
+ role: "white",
30
+ size: "large",
31
+ wordBreak: "break-word",
32
+ children: materialSurvey.questionInfoList[0].questionTitle
33
+ })]
34
+ }) : jsx(Shimmer, {
35
+ dark: true,
36
+ borderRadius: '4px',
37
+ width: "80%",
38
+ height: '40px'
39
+ }), jsx(Vspace, {
40
+ height: 1
41
+ }), materialSurvey ? jsx(StyledMarkdownSSR, {
42
+ children: materialSurvey.questionInfoList[0].questionDescription,
43
+ dark: true,
44
+ paddingx: 0,
45
+ paddingy: 0
46
+ }) : jsxs(Fragment, {
47
+ children: [jsx(Shimmer, {
48
+ dark: true,
49
+ borderRadius: '4px',
50
+ width: "80%",
51
+ height: '40px'
52
+ }), jsx(Vspace, {
53
+ height: 1
54
+ }), jsx(Shimmer, {
55
+ dark: true,
56
+ borderRadius: '4px',
57
+ width: "100%",
58
+ height: '40px'
59
+ }), jsx(Vspace, {
60
+ height: 1
61
+ }), jsx(Shimmer, {
62
+ dark: true,
63
+ borderRadius: '4px',
64
+ width: "100%",
65
+ height: '40px'
66
+ }), jsx(Vspace, {
67
+ height: 1
68
+ }), jsx(Shimmer, {
69
+ dark: true,
70
+ borderRadius: '4px',
71
+ width: "100%",
72
+ height: '40px'
73
+ })]
74
+ })]
75
+ });
70
76
  };
71
77
 
72
78
  export { MaterialSurveyInfo as default };
@@ -1,3 +1,5 @@
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';
1
3
  import React from 'react';
2
4
  import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
3
5
  import { useRawEliceIntl } from '@elice/intl';
@@ -12,52 +14,57 @@ import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/Mat
12
14
  import SurveyResultBadge from './SurveyResultBadge.js';
13
15
  import SurveySubmitStatusText from './SurveySubmitStatusText.js';
14
16
 
15
- const MaterialSurveySelectMultiple = () => {
17
+ var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
16
18
  var _a;
17
19
  // context
18
- const {
19
- course,
20
- lecture,
21
- materialSurvey,
22
- userId
23
- } = useMaterialSurveyState();
24
- const {
25
- onSubmit,
26
- onNext,
27
- refreshOrgMaterialSurvey
28
- } = useMaterialSurveyDispatch();
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;
29
29
  // state
30
- const intl = useRawEliceIntl();
31
- const [selectedAnswer, setSelectedAnswer] = React.useState([]);
32
- const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
33
- const [submitStatus, setSubmitStatus] = React.useState('idle');
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];
34
43
  // survey response fetcher
35
- React.useEffect(() => {
44
+ React.useEffect(function () {
36
45
  if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
37
- const controller = new AbortController();
38
- const {
39
- signal
40
- } = controller;
46
+ var controller = new AbortController();
47
+ var signal = controller.signal;
41
48
  getOrgMaterialSurveyResponseGet({
42
49
  surveyResponseId: materialSurvey.lastSurveyResponseId
43
50
  }, {
44
- signal
45
- }).then(response => {
51
+ signal: signal
52
+ }).then(function (response) {
46
53
  setMaterialSurveyResponse(response.surveyResponse);
47
54
  setSelectedAnswer(response.surveyResponse.answers[0]);
48
- }).catch(error => {
55
+ }).catch(function (error) {
49
56
  console.error(error);
50
57
  });
51
- return () => controller.abort();
58
+ return function () {
59
+ return controller.abort();
60
+ };
52
61
  }
53
62
  }, [materialSurvey, userId]);
54
63
  // survey response fetcher
55
- React.useEffect(() => {
64
+ React.useEffect(function () {
56
65
  if (userId && materialSurvey) {
57
- const controller = new AbortController();
58
- const {
59
- signal
60
- } = controller;
66
+ var controller = new AbortController();
67
+ var signal = controller.signal;
61
68
  getOrgMaterialSurveyResponseList({
62
69
  materialSurveyId: materialSurvey.id,
63
70
  filterUserIds: [userId],
@@ -66,10 +73,10 @@ const MaterialSurveySelectMultiple = () => {
66
73
  offset: 0,
67
74
  count: 1
68
75
  }, {
69
- signal
70
- }).then(response => {
71
- const surveyResponse = response.surveyResponses[0];
72
- const getAnswer = () => {
76
+ signal: signal
77
+ }).then(function (response) {
78
+ var surveyResponse = response.surveyResponses[0];
79
+ var getAnswer = function getAnswer() {
73
80
  if (!surveyResponse) {
74
81
  return [];
75
82
  }
@@ -83,49 +90,75 @@ const MaterialSurveySelectMultiple = () => {
83
90
  };
84
91
  setMaterialSurveyResponse(surveyResponse);
85
92
  setSelectedAnswer(getAnswer());
86
- }).catch(error => {
93
+ }).catch(function (error) {
87
94
  console.error(error);
88
95
  });
89
- return () => controller.abort();
96
+ return function () {
97
+ return controller.abort();
98
+ };
90
99
  }
91
100
  }, [materialSurvey, userId]);
92
101
  // submit handler
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, {
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, {
121
154
  title: intl.formatMessage({
122
155
  id: 'materialSurvey.myAnswer'
123
156
  }),
124
157
  onNext: onNext,
125
- submitResult: React.createElement(SurveyResultBadge, {
158
+ submitResult: jsx(SurveyResultBadge, {
126
159
  materialSurveyResponse: materialSurveyResponse
127
160
  }),
128
- submitStatus: React.createElement(SurveySubmitStatusText, {
161
+ submitStatus: jsx(SurveySubmitStatusText, {
129
162
  status: submitStatus
130
163
  }),
131
164
  footerActions: [{
@@ -139,30 +172,34 @@ const MaterialSurveySelectMultiple = () => {
139
172
  children: intl.formatMessage({
140
173
  id: 'materialSurvey.submit'
141
174
  })
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));
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
+ });
166
203
  };
167
204
 
168
205
  export { MaterialSurveySelectMultiple as default };