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