@coorpacademy/app-review 0.1.9 → 0.1.10

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 (70) hide show
  1. package/es/actions/ui/navigation.d.ts +1 -1
  2. package/es/fixtures/qcm-slide.js +1 -1
  3. package/es/helpers/map-api-slide-to-ui.d.ts +8 -0
  4. package/es/helpers/map-api-slide-to-ui.js +175 -0
  5. package/es/helpers/test/fixtures/free-text.d.ts +4 -0
  6. package/es/helpers/test/fixtures/free-text.js +24 -0
  7. package/es/helpers/test/fixtures/qcm-drag.d.ts +4 -0
  8. package/es/helpers/test/fixtures/qcm-drag.js +106 -0
  9. package/es/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
  10. package/es/helpers/test/fixtures/qcm-graphic.js +70 -0
  11. package/es/helpers/test/fixtures/qcm.d.ts +4 -0
  12. package/es/helpers/test/fixtures/qcm.js +99 -0
  13. package/es/helpers/test/fixtures/select-template.d.ts +4 -0
  14. package/es/helpers/test/fixtures/select-template.js +88 -0
  15. package/es/helpers/test/fixtures/slider.d.ts +4 -0
  16. package/es/helpers/test/fixtures/slider.js +27 -0
  17. package/es/helpers/test/fixtures/text-template.d.ts +4 -0
  18. package/es/helpers/test/fixtures/text-template.js +48 -0
  19. package/es/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
  20. package/es/helpers/test/map-api-slide-to-ui.test.js +32 -0
  21. package/es/index.js +29 -9
  22. package/es/reducers/ui/navigation.d.ts +1 -1
  23. package/es/test/index.test.js +18 -15
  24. package/es/test/util/services.mock.js +2 -32
  25. package/es/types/common.d.ts +62 -5
  26. package/es/types/slides.d.ts +27 -16
  27. package/lib/actions/ui/navigation.d.ts +1 -1
  28. package/lib/fixtures/qcm-slide.js +1 -1
  29. package/lib/helpers/map-api-slide-to-ui.d.ts +8 -0
  30. package/lib/helpers/map-api-slide-to-ui.js +181 -0
  31. package/lib/helpers/test/fixtures/free-text.d.ts +4 -0
  32. package/lib/helpers/test/fixtures/free-text.js +24 -0
  33. package/lib/helpers/test/fixtures/qcm-drag.d.ts +4 -0
  34. package/lib/helpers/test/fixtures/qcm-drag.js +106 -0
  35. package/lib/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
  36. package/lib/helpers/test/fixtures/qcm-graphic.js +70 -0
  37. package/lib/helpers/test/fixtures/qcm.d.ts +4 -0
  38. package/lib/helpers/test/fixtures/qcm.js +99 -0
  39. package/lib/helpers/test/fixtures/select-template.d.ts +4 -0
  40. package/lib/helpers/test/fixtures/select-template.js +88 -0
  41. package/lib/helpers/test/fixtures/slider.d.ts +4 -0
  42. package/lib/helpers/test/fixtures/slider.js +27 -0
  43. package/lib/helpers/test/fixtures/text-template.d.ts +4 -0
  44. package/lib/helpers/test/fixtures/text-template.js +48 -0
  45. package/lib/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
  46. package/lib/helpers/test/map-api-slide-to-ui.test.js +43 -0
  47. package/lib/index.js +29 -9
  48. package/lib/reducers/ui/navigation.d.ts +1 -1
  49. package/lib/test/index.test.js +19 -16
  50. package/lib/test/util/services.mock.js +13 -32
  51. package/lib/types/common.d.ts +62 -5
  52. package/lib/types/slides.d.ts +27 -16
  53. package/package.json +4 -3
  54. package/src/actions/ui/navigation.ts +1 -1
  55. package/src/fixtures/qcm-slide.ts +1 -1
  56. package/src/helpers/map-api-slide-to-ui.ts +253 -0
  57. package/src/helpers/test/fixtures/free-text.ts +28 -0
  58. package/src/helpers/test/fixtures/qcm-drag.ts +110 -0
  59. package/src/helpers/test/fixtures/qcm-graphic.ts +74 -0
  60. package/src/helpers/test/fixtures/qcm.ts +108 -0
  61. package/src/helpers/test/fixtures/select-template.ts +92 -0
  62. package/src/helpers/test/fixtures/slider.ts +31 -0
  63. package/src/helpers/test/fixtures/text-template.ts +52 -0
  64. package/src/helpers/test/map-api-slide-to-ui.test.ts +55 -0
  65. package/src/index.tsx +35 -11
  66. package/src/reducers/ui/navigation.ts +1 -1
  67. package/src/test/index.test.tsx +23 -12
  68. package/src/test/util/services.mock.ts +2 -32
  69. package/src/types/common.ts +74 -5
  70. package/src/types/slides.ts +29 -12
@@ -7,14 +7,83 @@ type TemplateContextValues = {
7
7
  translations?: unknown; // TODO type Translations
8
8
  };
9
9
 
10
- export type SlideFromAPI = {
11
- question: {
12
- content: {
13
- choices: Record<string, unknown>[];
14
- };
10
+ // TODO: EDIT_CHOICES -> specify typing
11
+ export type ChoiceFromAPI = {
12
+ _id: string;
13
+ id?: string;
14
+ value?: string;
15
+ name?: string;
16
+ type?: 'text' | 'select';
17
+ label?: string;
18
+ items: {text: string; value: string; _id: string}[];
19
+ media?: unknown;
20
+ };
21
+
22
+ type BaseContent = {
23
+ media?: unknown;
24
+ choices: ChoiceFromAPI[];
25
+ };
26
+
27
+ type Question = {
28
+ header?: string;
29
+ content: BaseContent;
30
+ explanation?: string;
31
+ };
32
+
33
+ export type QcmQuestion = Question & {
34
+ type: 'qcm';
35
+ };
36
+
37
+ export type QcmGraphicQuestion = Question & {
38
+ type: 'qcmGraphic';
39
+ };
40
+
41
+ export type QcmDragQuestion = Question & {
42
+ type: 'qcmDrag';
43
+ };
44
+
45
+ export type BasicQuestion = Omit<Question, 'content'> & {
46
+ type: 'basic';
47
+ content: {
48
+ media?: unknown;
49
+ label?: string;
50
+ placeholder?: string;
51
+ id: string;
52
+ };
53
+ };
54
+
55
+ export type SliderQuestion = Omit<Question, 'content'> & {
56
+ content: {
57
+ media?: unknown;
58
+ unitLabel: string;
59
+ min: number;
60
+ max: number;
61
+ step?: number;
15
62
  };
63
+ type: 'slider';
64
+ };
65
+
66
+ export type TemplateQuestion = Omit<Question, 'content'> & {
67
+ content: BaseContent & {
68
+ template: string;
69
+ };
70
+ type: 'template';
71
+ };
72
+
73
+ export type SlideFromAPI = {
74
+ question:
75
+ | QcmQuestion
76
+ | QcmGraphicQuestion
77
+ | QcmDragQuestion
78
+ | BasicQuestion
79
+ | SliderQuestion
80
+ | TemplateQuestion;
16
81
  klf: string;
17
82
  universalRef: string;
83
+ tips?: string;
84
+ clue?: string;
85
+ hasClue?: boolean;
86
+ id?: string;
18
87
  };
19
88
 
20
89
  export type ProgressionFromAPI = {
@@ -1,9 +1,10 @@
1
1
  export type Choice = {
2
2
  order?: number;
3
3
  selected: boolean;
4
- title: string;
5
- help: string;
4
+ title?: string;
5
+ help?: string;
6
6
  onClick: Function;
7
+ ariaLabel?: string;
7
8
  };
8
9
 
9
10
  export type QcmDrag = {
@@ -14,20 +15,20 @@ export type QcmDrag = {
14
15
 
15
16
  export type Qcm = {
16
17
  type: 'qcm';
17
- choices: (Choice & {ariaLabel: string})[];
18
+ answers: Choice[];
18
19
  };
19
20
 
20
21
  export type QcmGraphic = {
21
22
  type: 'qcmGraphic';
22
- choices: (Choice & {image: string})[];
23
+ answers: (Choice & {image: string})[];
23
24
  };
24
25
 
25
26
  export type FreeText = {
26
27
  type: 'freeText';
27
28
  placeholder: string;
28
- value: string;
29
+ value?: string;
29
30
  onChange: Function;
30
- ariaLabel: string;
31
+ ariaLabel?: string;
31
32
  };
32
33
 
33
34
  export type DropDownOption = {
@@ -39,9 +40,9 @@ export type DropDownOption = {
39
40
 
40
41
  export type DropDown = {
41
42
  type: 'dropDown';
42
- onChange: Function;
43
+ onChange?: Function;
43
44
  options: DropDownOption[];
44
- theme:
45
+ theme?:
45
46
  | 'filter'
46
47
  | 'invalid'
47
48
  | 'header'
@@ -56,19 +57,35 @@ export type DropDown = {
56
57
 
57
58
  export type QuestionRange = {
58
59
  type: 'slider';
59
- onChange: Function;
60
- onChangeEnd: Function;
61
- multi: boolean;
60
+ placeholder?: string;
61
+ onChange?: Function;
62
+ onChangeEnd?: Function;
63
+ multi?: boolean;
62
64
  value: number | number[];
63
65
  title: string;
64
66
  minLabel: string;
65
67
  maxLabel: string;
66
68
  };
67
69
 
70
+ export type TextTemplate = {
71
+ type: 'text';
72
+ name: string;
73
+ placeholder: string;
74
+ value?: string;
75
+ onChange: Function;
76
+ };
77
+
78
+ export type SelectionTemplate = {
79
+ type: 'select';
80
+ name: string;
81
+ onChange?: Function;
82
+ options?: DropDownOption[];
83
+ };
84
+
68
85
  export type Template = {
69
86
  type: 'template';
70
87
  template: string;
71
- choices: (DropDown & {type?: string})[];
88
+ answers: (TextTemplate | SelectionTemplate)[];
72
89
  };
73
90
 
74
91
  export type AnswerUI = {