@coorpacademy/app-review 0.1.14 → 0.1.16
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/es/actions/api/fetch-skills.d.ts +4 -6
- package/es/actions/api/fetch-skills.js +7 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +27 -4
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -9
- package/es/actions/api/test/create-test-store.d.ts +5 -0
- package/es/actions/api/test/create-test-store.js +16 -0
- package/es/actions/api/test/fetch-skills.test.js +54 -0
- package/es/actions/api/test/fetch-slide.test.js +61 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- package/es/actions/ui/is-fetching.js +0 -2
- package/es/actions/ui/slides.d.ts +26 -0
- package/es/actions/ui/slides.js +9 -0
- package/es/common/index.d.ts +3 -1
- package/es/common/index.js +3 -1
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/fixtures/temp-fixture.d.ts +2 -2
- package/es/index.js +22 -92
- package/es/reducers/data/index.d.ts +2 -2
- package/es/reducers/data/progression.d.ts +3 -16
- package/es/reducers/data/progression.js +3 -22
- package/es/reducers/data/slides.d.ts +5 -6
- package/es/reducers/data/slides.js +9 -108
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → answers.js} +3 -3
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/current-slide-ref.js +13 -0
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/test/answers.test.js +11 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +14 -4
- package/es/test/util/services.mock.js +46 -4
- package/es/types/common.d.ts +61 -30
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
- package/es/views/skills/index.js +25 -0
- package/es/views/slides/index.d.ts +79 -0
- package/es/views/slides/index.js +151 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +172 -0
- package/es/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/es/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/views/slides/test/fixtures/slider.d.ts +3 -0
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +4 -6
- package/lib/actions/api/fetch-skills.js +55 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +75 -7
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -10
- package/lib/actions/api/test/create-test-store.d.ts +5 -0
- package/lib/actions/api/test/create-test-store.js +18 -0
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +113 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +120 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +160 -0
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- package/lib/actions/ui/is-fetching.js +0 -2
- package/lib/actions/ui/slides.d.ts +26 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.js +3 -1
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/fixtures/temp-fixture.d.ts +2 -2
- package/lib/index.js +33 -94
- package/lib/reducers/data/index.d.ts +2 -2
- package/lib/reducers/data/progression.d.ts +3 -16
- package/lib/reducers/data/progression.js +3 -22
- package/lib/reducers/data/slides.d.ts +5 -6
- package/lib/reducers/data/slides.js +9 -114
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → answers.js} +3 -3
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/current-slide-ref.js +14 -0
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +11 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +14 -4
- package/lib/test/util/services.mock.js +46 -4
- package/lib/types/common.d.ts +61 -30
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
- package/lib/views/skills/index.js +25 -0
- package/lib/views/slides/index.d.ts +79 -0
- package/lib/views/slides/index.js +155 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +178 -0
- package/lib/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/lib/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/views/slides/test/fixtures/slider.d.ts +3 -0
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +4 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +38 -13
- package/src/actions/api/post-progression.ts +18 -22
- package/src/actions/api/test/create-test-store.ts +25 -0
- package/src/actions/api/test/fetch-skills.test.ts +70 -0
- package/src/actions/api/test/fetch-slide.test.ts +77 -0
- package/src/actions/api/test/post-progression.test.ts +119 -0
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/answers.ts +16 -0
- package/src/actions/ui/is-fetching.ts +0 -6
- package/src/actions/ui/slides.ts +35 -0
- package/src/common/index.ts +7 -1
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/fixtures/temp-fixture.ts +2 -2
- package/src/index.tsx +26 -110
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +17 -125
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +19 -0
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/test/answers.test.ts +13 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +14 -4
- package/src/test/util/services.mock.ts +46 -4
- package/src/types/common.ts +77 -40
- package/src/types/slides.ts +0 -5
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +251 -0
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +43 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +111 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +94 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +43 -33
- package/src/views/slides/test/fixtures/select-template.ts +98 -0
- package/src/views/slides/test/fixtures/slider.ts +41 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +23 -14
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -20
- package/es/actions/data/slides.d.ts +0 -37
- package/es/actions/data/slides.js +0 -16
- package/es/actions/ui/finished-slides.d.ts +0 -10
- package/es/actions/ui/finished-slides.js +0 -8
- package/es/actions/ui/review-status.d.ts +0 -7
- package/es/actions/ui/review-status.js +0 -7
- package/es/actions/ui/step-items.d.ts +0 -24
- package/es/actions/ui/step-items.js +0 -11
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/es/helpers/map-api-slide-to-ui.js +0 -175
- package/es/helpers/test/fixtures/free-text.d.ts +0 -4
- package/es/helpers/test/fixtures/free-text.js +0 -24
- package/es/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-drag.js +0 -106
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/es/helpers/test/fixtures/qcm.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.js +0 -88
- package/es/helpers/test/fixtures/slider.d.ts +0 -4
- package/es/helpers/test/fixtures/slider.js +0 -27
- package/es/helpers/test/fixtures/text-template.d.ts +0 -4
- package/es/reducers/ui/finished-slides.d.ts +0 -7
- package/es/reducers/ui/finished-slides.js +0 -33
- package/es/reducers/ui/review-status.d.ts +0 -4
- package/es/reducers/ui/step-items.d.ts +0 -14
- package/es/reducers/ui/step-items.js +0 -74
- package/es/types/ui-progression.d.ts +0 -10
- package/es/types/views/slides.d.ts +0 -60
- package/lib/actions/data/slides.d.ts +0 -37
- package/lib/actions/data/slides.js +0 -16
- package/lib/actions/ui/finished-slides.d.ts +0 -10
- package/lib/actions/ui/finished-slides.js +0 -8
- package/lib/actions/ui/review-status.d.ts +0 -7
- package/lib/actions/ui/review-status.js +0 -7
- package/lib/actions/ui/step-items.d.ts +0 -24
- package/lib/actions/ui/step-items.js +0 -11
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/lib/helpers/map-api-slide-to-ui.js +0 -181
- package/lib/helpers/test/fixtures/free-text.d.ts +0 -4
- package/lib/helpers/test/fixtures/free-text.js +0 -24
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -106
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/lib/helpers/test/fixtures/qcm.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.js +0 -88
- package/lib/helpers/test/fixtures/slider.d.ts +0 -4
- package/lib/helpers/test/fixtures/slider.js +0 -27
- package/lib/helpers/test/fixtures/text-template.d.ts +0 -4
- package/lib/reducers/ui/finished-slides.d.ts +0 -7
- package/lib/reducers/ui/finished-slides.js +0 -45
- package/lib/reducers/ui/review-status.d.ts +0 -4
- package/lib/reducers/ui/step-items.d.ts +0 -14
- package/lib/reducers/ui/step-items.js +0 -86
- package/lib/types/ui-progression.d.ts +0 -10
- package/lib/types/views/slides.d.ts +0 -60
- package/src/actions/data/slides.ts +0 -65
- package/src/actions/ui/finished-slides.ts +0 -21
- package/src/actions/ui/review-status.ts +0 -19
- package/src/actions/ui/step-items.ts +0 -45
- package/src/helpers/map-api-slide-to-ui.ts +0 -253
- package/src/helpers/test/fixtures/free-text.ts +0 -28
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -110
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -74
- package/src/helpers/test/fixtures/select-template.ts +0 -92
- package/src/helpers/test/fixtures/slider.ts +0 -31
- package/src/reducers/ui/finished-slides.ts +0 -52
- package/src/reducers/ui/review-status.ts +0 -19
- package/src/reducers/ui/step-items.ts +0 -116
- package/src/types/ui-progression.ts +0 -25
- package/src/types/views/skills.ts +0 -27
- package/src/types/views/slides.ts +0 -65
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/es/{types/ui-progression.js → actions/api/test/fetch-slide.test.d.ts} +0 -0
- /package/es/{types/views/skills.js → actions/api/test/post-progression.test.d.ts} +0 -0
- /package/es/{types/views/slides.js → reducers/data/test/progression.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/reducers/data/test/skills.test.d.ts} +0 -0
- /package/{lib/types/ui-progression.js → es/reducers/data/test/slides.test.d.ts} +0 -0
- /package/{lib/types/views/skills.js → es/reducers/data/test/token.test.d.ts} +0 -0
- /package/{lib/types/views/slides.js → es/reducers/ui/test/answers.test.d.ts} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import test from 'ava';
|
|
49
|
+
import { fetchSlide, SLIDE_FETCH_FAILURE, SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
50
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
51
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
52
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
53
|
+
import { createTestStore } from './create-test-store';
|
|
54
|
+
var initialState = {
|
|
55
|
+
data: {
|
|
56
|
+
progression: null,
|
|
57
|
+
slides: {},
|
|
58
|
+
skills: [],
|
|
59
|
+
token: '1234'
|
|
60
|
+
},
|
|
61
|
+
ui: {
|
|
62
|
+
currentSlideRef: '',
|
|
63
|
+
navigation: [],
|
|
64
|
+
answers: []
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlide return a slide', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var services, expectedActions, dispatch;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
services = __assign(__assign({}, mockedServices), { fetchSlide: function (slideRef, token) {
|
|
73
|
+
t.is(token, '1234');
|
|
74
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
75
|
+
return Promise.resolve(freeTextSlide);
|
|
76
|
+
} });
|
|
77
|
+
expectedActions = [
|
|
78
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'sli_VJYjJnJhg' } },
|
|
79
|
+
{
|
|
80
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
81
|
+
meta: { slideRef: 'sli_VJYjJnJhg' },
|
|
82
|
+
payload: freeTextSlide
|
|
83
|
+
},
|
|
84
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
85
|
+
];
|
|
86
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
87
|
+
return [4 /*yield*/, dispatch(fetchSlide('sli_VJYjJnJhg', '1234'))];
|
|
88
|
+
case 1:
|
|
89
|
+
_a.sent();
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); });
|
|
94
|
+
test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var services, expectedActions, dispatch;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
services = __assign(__assign({}, mockedServices), { fetchSlide: function (slideRef, token) {
|
|
100
|
+
t.is(token, '1234');
|
|
101
|
+
t.is(slideRef, 'slide_ref');
|
|
102
|
+
return Promise.reject(new Error('error'));
|
|
103
|
+
} });
|
|
104
|
+
expectedActions = [
|
|
105
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'slide_ref' } },
|
|
106
|
+
{
|
|
107
|
+
type: SLIDE_FETCH_FAILURE,
|
|
108
|
+
meta: { slideRef: 'slide_ref' },
|
|
109
|
+
payload: new Error('error'),
|
|
110
|
+
error: true
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
114
|
+
return [4 /*yield*/, dispatch(fetchSlide('slide_ref', '1234'))];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import test from 'ava';
|
|
49
|
+
import { postProgression, POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE } from '../post-progression';
|
|
50
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
51
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
52
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
53
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
54
|
+
import { createTestStore } from './create-test-store';
|
|
55
|
+
var initialState = {
|
|
56
|
+
data: {
|
|
57
|
+
progression: null,
|
|
58
|
+
slides: {},
|
|
59
|
+
skills: [],
|
|
60
|
+
token: '1234'
|
|
61
|
+
},
|
|
62
|
+
ui: {
|
|
63
|
+
currentSlideRef: '',
|
|
64
|
+
navigation: [],
|
|
65
|
+
answers: []
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions when postProgression return a progression', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var progression, services, expectedActions, dispatch;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
progression = {
|
|
74
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
75
|
+
content: {
|
|
76
|
+
ref: '_skill-ref',
|
|
77
|
+
type: 'skill'
|
|
78
|
+
},
|
|
79
|
+
engine: {
|
|
80
|
+
ref: 'review'
|
|
81
|
+
},
|
|
82
|
+
state: {
|
|
83
|
+
allAnswers: [],
|
|
84
|
+
isCorrect: true,
|
|
85
|
+
nextContent: {
|
|
86
|
+
ref: 'sli_VJYjJnJhg',
|
|
87
|
+
type: 'slide'
|
|
88
|
+
},
|
|
89
|
+
pendingSlides: [],
|
|
90
|
+
slides: [],
|
|
91
|
+
step: {
|
|
92
|
+
current: 1
|
|
93
|
+
},
|
|
94
|
+
stars: 0
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
services = __assign(__assign({}, mockedServices), { postProgression: function (skillRef, token) {
|
|
98
|
+
t.is(token, '1234');
|
|
99
|
+
t.is(skillRef, 'skill_12345');
|
|
100
|
+
return Promise.resolve(progression);
|
|
101
|
+
}, fetchSlide: function (slideRef, token) {
|
|
102
|
+
t.is(token, '1234');
|
|
103
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
104
|
+
return Promise.resolve(freeTextSlide);
|
|
105
|
+
} });
|
|
106
|
+
expectedActions = [
|
|
107
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
108
|
+
{
|
|
109
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
110
|
+
payload: progression
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: SLIDE_FETCH_REQUEST,
|
|
114
|
+
meta: {
|
|
115
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
120
|
+
meta: {
|
|
121
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
122
|
+
},
|
|
123
|
+
payload: freeTextSlide
|
|
124
|
+
},
|
|
125
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
126
|
+
];
|
|
127
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
128
|
+
return [4 /*yield*/, dispatch(postProgression('skill_12345', '1234'))];
|
|
129
|
+
case 1:
|
|
130
|
+
_a.sent();
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}); });
|
|
135
|
+
test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
|
+
var services, expectedActions, dispatch;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
services = __assign(__assign({}, mockedServices), { postProgression: function (skillRef, token) {
|
|
141
|
+
t.is(token, '1234');
|
|
142
|
+
t.is(skillRef, 'skill_12345');
|
|
143
|
+
return Promise.reject(new Error('error'));
|
|
144
|
+
} });
|
|
145
|
+
expectedActions = [
|
|
146
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
147
|
+
{
|
|
148
|
+
type: POST_PROGRESSION_FAILURE,
|
|
149
|
+
payload: new Error('error'),
|
|
150
|
+
error: true
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
154
|
+
return [4 /*yield*/, dispatch(postProgression('skill_12345', '1234'))];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); });
|
package/lib/actions/index.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
|
|
2
1
|
import { StoreToken } from './data/token';
|
|
3
|
-
import { updateFinishedSlides } from './ui/finished-slides';
|
|
4
2
|
import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
|
|
5
|
-
import { updateReviewStatus } from './ui/review-status';
|
|
6
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
|
|
7
3
|
import { ReceivedSlide } from './api/fetch-slide';
|
|
8
4
|
import { ReceiveProgression } from './api/post-progression';
|
|
9
5
|
import { ReceivedSkills } from './api/fetch-skills';
|
|
6
|
+
import { validateSlide } from './ui/slides';
|
|
10
7
|
export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
|
|
11
8
|
export declare type Dispatchers = {
|
|
12
9
|
navigateTo: typeof navigateTo;
|
|
13
10
|
navigateBack: typeof navigateBack;
|
|
14
11
|
validateSlide: typeof validateSlide;
|
|
15
|
-
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
16
|
-
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
17
|
-
updateReviewStatus: typeof updateReviewStatus;
|
|
18
|
-
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
19
|
-
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
20
|
-
updateFinishedSlides: typeof updateFinishedSlides;
|
|
21
12
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
export declare const EDIT_BASIC: "@@answer/EDIT_BASIC";
|
|
3
|
+
export declare type EditBasicAction = {
|
|
4
|
+
type: typeof EDIT_BASIC;
|
|
5
|
+
payload: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const editAnswer: (answer: string) => (dispatch: Dispatch) => EditBasicAction;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
1
|
export var START_FETCHING = '@@ui/START_FETCHING';
|
|
3
2
|
export var STOP_FETCHING = '@@ui/STOP_FETCHING';
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
3
|
export var startFetching = function () { return ({ type: START_FETCHING }); };
|
|
6
4
|
export var stopFetching = function () { return ({ type: STOP_FETCHING }); };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SlideFromAPI } from '../../types/common';
|
|
2
|
+
import { AnswerUI } from '../../types/slides';
|
|
3
|
+
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
|
+
export declare type Slide = {
|
|
5
|
+
questionText?: string;
|
|
6
|
+
answerUI?: AnswerUI;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
position: number;
|
|
9
|
+
animationType?: SlideUIAnimations;
|
|
10
|
+
isCorrect?: boolean;
|
|
11
|
+
endReview?: boolean;
|
|
12
|
+
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
13
|
+
};
|
|
14
|
+
export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
|
|
15
|
+
export declare type SetCurrentSlide = {
|
|
16
|
+
type: typeof SET_CURRENT_SLIDE;
|
|
17
|
+
payload: SlideFromAPI;
|
|
18
|
+
};
|
|
19
|
+
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlide;
|
|
20
|
+
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
21
|
+
export declare type ValidateSlide = {
|
|
22
|
+
type: typeof VALIDATE_SLIDE;
|
|
23
|
+
};
|
|
24
|
+
export declare const validateSlide: () => ValidateSlide;
|
|
25
|
+
export declare type UISlidesAction = SetCurrentSlide;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE';
|
|
2
|
+
export var setCurrentSlide = function (payload) { return ({
|
|
3
|
+
type: SET_CURRENT_SLIDE,
|
|
4
|
+
payload: payload
|
|
5
|
+
}); };
|
|
6
|
+
export var VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
7
|
+
export var validateSlide = function () { return ({
|
|
8
|
+
type: VALIDATE_SLIDE
|
|
9
|
+
}); };
|
package/lib/common/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export declare const VIEWS: {
|
|
|
5
5
|
readonly onboarding: 'onboarding';
|
|
6
6
|
readonly slides: 'slides';
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
9
|
+
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
10
|
+
export declare const indexToString: (index: number) => SlideIndexes;
|
package/lib/common/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toString from 'lodash/fp/toString';
|
|
1
2
|
export var TOTAL_SLIDES_STACK = 5;
|
|
2
3
|
export var HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
3
4
|
export var VIEWS = {
|
|
@@ -5,4 +6,5 @@ export var VIEWS = {
|
|
|
5
6
|
onboarding: 'onboarding',
|
|
6
7
|
slides: 'slides'
|
|
7
8
|
};
|
|
8
|
-
export var
|
|
9
|
+
export var slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
+
export var indexToString = function (index) { return _toString(index); };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UISlide } from '../types/
|
|
2
|
-
export declare const slide: UISlide
|
|
1
|
+
import { UISlide } from '../types/common';
|
|
2
|
+
export declare const slide: Pick<UISlide, 'questionText' | 'answerUI'>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SlidesViewProps } from '../
|
|
2
|
-
export declare const correctionPopinProps:
|
|
1
|
+
import { SlidesViewProps, CorrectionPopinProps } from '../views/slides';
|
|
2
|
+
export declare const correctionPopinProps: CorrectionPopinProps;
|
|
3
3
|
export declare const congratsProps: SlidesViewProps['congratsProps'];
|
package/lib/index.js
CHANGED
|
@@ -1,98 +1,41 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
13
|
+
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
3
14
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
4
15
|
import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
|
|
5
16
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
17
|
import get from 'lodash/fp/get';
|
|
7
18
|
import configureStore from './configure-store';
|
|
8
|
-
import {
|
|
9
|
-
import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
|
|
10
|
-
import { navigateTo, navigateBack } from './actions/ui/navigation';
|
|
19
|
+
import { navigateTo } from './actions/ui/navigation';
|
|
11
20
|
import { storeToken } from './actions/data/token';
|
|
12
|
-
import { updateFinishedSlides } from './actions/ui/finished-slides';
|
|
13
|
-
import { updateReviewStatus } from './actions/ui/review-status';
|
|
14
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui/step-items';
|
|
15
21
|
import { fetchSkills } from './actions/api/fetch-skills';
|
|
16
22
|
import { postProgression } from './actions/api/post-progression';
|
|
17
23
|
import { VIEWS } from './common';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
updateStepItemsOnNext: updateStepItemsOnNext,
|
|
27
|
-
updateFinishedSlides: updateFinishedSlides
|
|
28
|
-
};
|
|
29
|
-
var getCurrentViewName = function (storeState) {
|
|
30
|
-
return storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
31
|
-
};
|
|
32
|
-
var mapStateToSkillsProps = function (state) {
|
|
33
|
-
if (!state.data.skills) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
title: '@todo title',
|
|
38
|
-
titleNoSkills: '@todo titleNoSkills',
|
|
39
|
-
textNoSkills: '@todo textNoSkills',
|
|
40
|
-
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
41
|
-
isLoading: false,
|
|
42
|
-
isLoadingAriaLabel: '@todo loading',
|
|
43
|
-
listSkills: state.data.skills.map(function (skill) { return ({
|
|
44
|
-
'aria-label': '',
|
|
45
|
-
isCustom: skill.custom,
|
|
46
|
-
skillTitle: skill.name,
|
|
47
|
-
skillAriaLabel: '@todo skill aria label',
|
|
48
|
-
buttonLabel: '@todo button',
|
|
49
|
-
buttonAriaLabel: '@todo button aria label',
|
|
50
|
-
reviseLabel: '@todo revise',
|
|
51
|
-
reviseAriaLabel: '@todo revise aria label',
|
|
52
|
-
// eslint-disable-next-line no-console
|
|
53
|
-
onClick: function () { return console.log('@todo plug dispatcher select skill'); }
|
|
54
|
-
}); })
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
var mapStateToSlidesProps = function (state) {
|
|
58
|
-
if (!state.data.slides) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
headerProps: {
|
|
63
|
-
mode: '__revision_mode',
|
|
64
|
-
skillName: '__agility',
|
|
65
|
-
onQuitClick: function () {
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.log('onQuitClick');
|
|
68
|
-
},
|
|
69
|
-
'aria-label': 'aria-header-wrapper',
|
|
70
|
-
closeButtonAriaLabel: 'aria-close-button'
|
|
71
|
-
},
|
|
72
|
-
slides: state.data.slides,
|
|
73
|
-
validate: {
|
|
74
|
-
label: '__validate'
|
|
75
|
-
},
|
|
76
|
-
finishedSlides: state.ui.finishedSlides,
|
|
77
|
-
stepItems: state.ui.stepItems,
|
|
78
|
-
reviewStatus: state.ui.reviewStatus,
|
|
79
|
-
correctionPopinProps: correctionPopinProps,
|
|
80
|
-
congratsProps: congratsProps,
|
|
81
|
-
progression: state.data.progression
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
var mapStateToProps = function (state) {
|
|
85
|
-
return {
|
|
86
|
-
viewName: getCurrentViewName(state),
|
|
87
|
-
slides: mapStateToSlidesProps(state),
|
|
88
|
-
skills: mapStateToSkillsProps(state)
|
|
24
|
+
import { mapStateToSlidesProps } from './views/slides';
|
|
25
|
+
import { mapStateToSkillsProps } from './views/skills';
|
|
26
|
+
var ConnectedApp = function () {
|
|
27
|
+
var dispatch = useDispatch();
|
|
28
|
+
var props = {
|
|
29
|
+
viewName: useSelector(function (state) { return state.ui.navigation[state.ui.navigation.length - 1]; }),
|
|
30
|
+
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch); }),
|
|
31
|
+
skills: useSelector(function (state) { return mapStateToSkillsProps(state); })
|
|
89
32
|
};
|
|
33
|
+
return React.createElement(AppReviewTemplate, __assign({}, props));
|
|
90
34
|
};
|
|
91
|
-
var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
92
35
|
var AppReview = function (_a) {
|
|
93
36
|
var options = _a.options;
|
|
94
37
|
var _b = useState(null), store = _b[0], setStore = _b[1];
|
|
95
|
-
var _c = useState(false),
|
|
38
|
+
var _c = useState(false), isProgressionCreated = _c[0], setIsProgressionCreated = _c[1];
|
|
96
39
|
useEffect(function () {
|
|
97
40
|
if (store)
|
|
98
41
|
return;
|
|
@@ -100,14 +43,13 @@ var AppReview = function (_a) {
|
|
|
100
43
|
setStore(newStore);
|
|
101
44
|
}, [options, store]);
|
|
102
45
|
useEffect(function () {
|
|
103
|
-
if (!store ||
|
|
46
|
+
if (!store || isProgressionCreated)
|
|
104
47
|
return;
|
|
105
48
|
return store.subscribe(function () {
|
|
106
|
-
var
|
|
107
|
-
return
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
}, [isSlideFetched, options, store]);
|
|
49
|
+
var isProgressionPresent = !isEmpty(store.getState().data.progression);
|
|
50
|
+
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
51
|
+
});
|
|
52
|
+
}, [isProgressionCreated, options, store]);
|
|
111
53
|
useEffect(function () {
|
|
112
54
|
var token = get('token', options);
|
|
113
55
|
if (store === null || isEmpty(token))
|
|
@@ -119,8 +61,8 @@ var AppReview = function (_a) {
|
|
|
119
61
|
if (store === null || isEmpty(token))
|
|
120
62
|
return;
|
|
121
63
|
var skillRef = get('skillRef', options);
|
|
122
|
-
|
|
123
|
-
|
|
64
|
+
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
65
|
+
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
124
66
|
skillRef
|
|
125
67
|
? store.dispatch(postProgression(skillRef, token))
|
|
126
68
|
: store.dispatch(fetchSkills(token));
|
|
@@ -129,21 +71,18 @@ var AppReview = function (_a) {
|
|
|
129
71
|
if (store === null)
|
|
130
72
|
return;
|
|
131
73
|
var skillRef = options.skillRef;
|
|
132
|
-
if (skillRef && !
|
|
74
|
+
if (skillRef && !isProgressionCreated) {
|
|
133
75
|
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
134
76
|
return;
|
|
135
77
|
}
|
|
136
|
-
// TODO: when slides state is refactored (data + mapping),
|
|
137
|
-
// use loader in case a skillRef is found && no slides from the API
|
|
138
|
-
// are found
|
|
139
78
|
var initialView = skillRef ? VIEWS.slides : VIEWS.skills;
|
|
140
79
|
store.dispatch(navigateTo(initialView));
|
|
141
|
-
}, [
|
|
80
|
+
}, [isProgressionCreated, options, store]);
|
|
142
81
|
if (!store)
|
|
143
82
|
return null;
|
|
144
83
|
var values = options.templateContext;
|
|
145
84
|
return (React.createElement(Provider, { store: store },
|
|
146
85
|
React.createElement(TemplateContext, { values: values },
|
|
147
|
-
React.createElement(
|
|
86
|
+
React.createElement(ConnectedApp, null))));
|
|
148
87
|
};
|
|
149
88
|
export default AppReview;
|
|
@@ -4,7 +4,7 @@ import { SlidesState } from './slides';
|
|
|
4
4
|
import { TokenState } from './token';
|
|
5
5
|
export declare type DataState = {
|
|
6
6
|
isFetching?: boolean;
|
|
7
|
-
progression
|
|
7
|
+
progression: ProgressionState;
|
|
8
8
|
skills: SkillsState;
|
|
9
9
|
slides: SlidesState;
|
|
10
10
|
token?: TokenState;
|
|
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
skills: SkillsState;
|
|
15
15
|
slides: SlidesState;
|
|
16
16
|
token: TokenState;
|
|
17
|
-
}>, import("../../actions/
|
|
17
|
+
}>, import("../../actions/api/post-progression").ReceiveProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
18
18
|
export default _default;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { ValidateSlide } from '../../actions/
|
|
1
|
+
import { ValidateSlide } from '../../actions/ui/slides';
|
|
2
2
|
import { ReceiveProgression } from '../../actions/api/post-progression';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
state: {
|
|
6
|
-
isCorrect: boolean;
|
|
7
|
-
nextContent: {
|
|
8
|
-
ref: 'successExitNode' | string;
|
|
9
|
-
type: 'success' | 'slide';
|
|
10
|
-
};
|
|
11
|
-
pendingSlides: string[];
|
|
12
|
-
step: {
|
|
13
|
-
current: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
slideNumber?: number;
|
|
17
|
-
} | null;
|
|
3
|
+
import { ProgressionFromAPI } from '../../types/common';
|
|
4
|
+
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
18
5
|
declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
|
|
19
6
|
export default reducer;
|