-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmockConfig.ts
More file actions
366 lines (365 loc) · 15.2 KB
/
mockConfig.ts
File metadata and controls
366 lines (365 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
import { ConfigType } from "../types/ConfigTypes";
import { ExternalMessageType } from "../types/MessageTypes";
import { questionTypes } from "../types/QuestionTypes";
import { AnswerDataUrl, resultContentTypes } from "../types/ResultTypes";
export const mockConfig: Partial<ConfigType> = {
id: "mock",
groups: [
{
title: "Questions",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Erat enim Polemonis. Iam contemni non poteris.\nEquidem etiam Epicurum, in physicis quidem, Democriteum puto. An quod ita callida est, ut optime possit architectari voluptates? Iam quae corporis sunt, ea nec auctoritatem cum animi partibus.",
accentColor: "#db3f37",
questions: [
{
id: "interested",
type: questionTypes.single,
title: "Are you interested{hint} in eating an ice cream?{hint}",
hints: [
"It's a word",
{
label: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Erat enim Polemonis. ",
imageUrl: "https://via.placeholder.com/100x100",
imageAlt: "100x100",
imageWidth: 300,
},
],
},
{
id: "flavour",
type: questionTypes.multiple,
title: "What flavour do you want?",
inputType: "radio",
options: [
{ id: "0", title: "Vanilla" },
{ id: "1", title: "Banana" },
{
id: "2",
title: "Ben & Jerry's{hint} Imagine\nWhirled Peace{hint}",
hints: ["(TM)", "Yes this is a real flavour."],
},
{ id: "3", title: "Chocolat" },
],
required: true,
image: {
url: "https://via.placeholder.com/350x65",
alt: "Placeholder 1",
alignment: "left",
},
},
{
id: "flavour-shared",
type: questionTypes.text,
inputType: "number",
title: "How many other people would you estimate that share your favourite flavour?",
required: true,
},
{
id: "amount",
type: questionTypes.range,
title: "How many do you want?",
inputType: "slider",
min: 0,
max: 10,
required: true,
tickLabels: ["Min", "", "Two\nItem"],
image: {
url: "https://via.placeholder.com/350x65",
size: 0.3,
alt: "Placeholder 2",
},
},
],
},
{
accentColor: "#1E88E5",
description:
"Lorem <strong>ipsum dolor sit amet</strong>, consectetur adipiscing elit. Erat enim Polemonis. Iam contemni non poteris.\nEquidem etiam Epicurum, in physicis quidem, Democriteum puto. An quod ita callida est, ut optime possit architectari voluptates? Iam quae corporis sunt, ea nec auctoritatem cum animi partibus.",
image: {
url: "https://via.placeholder.com/200x200",
alt: "Placeholder 3",
alignment: "right",
},
questions: [
{
id: "mailaddress",
type: questionTypes.text,
inputType: "email",
placeholder: "ben@jerry.com",
title: "On which address do you want to receive your digital{hint} ice cream?",
hints: ["Do not worry it won't melt."],
},
{
id: "location",
type: questionTypes.multiple,
title: "Where do you live?",
inputType: "select",
options: [
{ id: "0", title: "US{hint}", hints: ["United States"] },
{ id: "1", title: "Somewhere else" },
],
calcFunction: (question: any, answer: any, allAnswers: any[]) => {
const emailAnswer = allAnswers.find((answer) => answer.questionIdHash.includes("mailaddress"));
if (emailAnswer?.value.includes(".com")) return 0;
return answer.values.includes("0") ? -99 : 10.6;
},
},
{
id: "toppings",
type: questionTypes.multiple,
title: "Which toppings do you want?",
inputType: "check",
options: [
{ id: "0", title: "Sprinkels" },
{ id: "1", title: "Crumbs" },
{ id: "2", title: "Chocolat sauce" },
],
defaultIds: ["1", "2"],
},
{
id: "name",
type: questionTypes.text,
inputType: "text",
title: "How do you want to name your creation?",
// customValidation: {
// regex: "^.{0,10}$",
// error: "Names longer than 10 characters are not allowed",
// },
image: {
url: "https://via.placeholder.com/350x65",
alignment: "right",
alt: "Placeholder 3",
},
calcFunction: (question: any, answer: any) => {
return answer.value.length;
},
rowCount: 5,
},
{
id: "rating-order",
type: questionTypes.single,
title: "Did you like this order flow?",
checkedByDefault: true,
required: true,
image: {
url: "https://via.placeholder.com/350x65",
alignment: "center",
size: 0.6,
alt: "Placeholder 4",
},
},
{
id: "rating-product",
type: questionTypes.range,
title: "How much did you like it?",
inputType: "radio",
tickLabels: ["derp\nderp"],
min: 2,
step: 2,
max: 8,
default: 4,
direction: "decrease",
calcFunction: (question: any, answer: any): number =>
Math.round((answer.value / (question.max - question.min)) * 100),
},
],
},
{
title: "Table questions",
tabledView: true,
tableInputHeadings: ["Very bad", "Bad", "Neutral", "Good", "Very good"],
questions: [
{
id: "Table1",
type: questionTypes.range,
title: "Question 1Question 1Question 1Question 1",
inputType: "radio",
min: 0,
max: 4,
},
{
id: "Table2",
type: questionTypes.range,
title: "Question 2",
inputType: "radio",
min: 0,
max: 4,
},
{
id: "Table3",
type: questionTypes.range,
title: "Question 3",
inputType: "radio",
min: 0,
max: 4,
},
{
id: "Table4",
type: questionTypes.range,
title: "Question 4",
inputType: "radio",
min: 0,
max: 4,
},
{
id: "Table5",
type: questionTypes.range,
title: "Question 5",
inputType: "slider",
min: 0,
max: 4,
tickCount: 5,
},
{
id: "interested2",
type: questionTypes.single,
title: "Are you interested{hint} in eating an ice cream?{hint}",
hints: ["It's a word", "Say yes!"],
},
{
id: "flavour2",
type: questionTypes.multiple,
title: "What flavour do you want?",
inputType: "radio",
options: [
{ id: "0", title: "Vanilla" },
{ id: "1", title: "Banana" },
{
id: "2",
title: "Ben & Jerry's{hint} Imagine Whirled Peace{hint}",
hints: ["(TM)", "Yes this is a real flavour."],
},
{ id: "3", title: "Chocolat" },
],
required: true,
image: {
url: "https://via.placeholder.com/350x65",
alt: "Placeholder 1",
alignment: "left",
},
},
{
id: "flavour-shared2",
type: questionTypes.text,
inputType: "number",
title: "How many other people would you estimate that share your favourite flavour?",
required: true,
calcFunction: (_, answer: any) => ({ secondaryScore: parseFloat(answer.value) }),
},
],
},
],
result: {
scoreTypes: ["mainScore", "secondaryScore"],
scoreDomains: {
mainScore: [0, 150],
secondaryScore: [0, 100],
},
postDataUrl: "POST;https://example.org/api/answer" as AnswerDataUrl,
restartTimeout: 1000,
content: [
{ type: resultContentTypes.label, style: "title", label: "Thanks for your {mainScore}/10 submission." },
{
type: resultContentTypes.button,
label: "Your score is {mainScore}",
function: "link",
url: "https://example.org/?score={mainScore}" as AnswerDataUrl,
},
{
type: resultContentTypes.label,
style: "description",
label:
"Lorem {mainScore5}/5 ipsum dolor sit amet ({mainScore}) consectetur adipiscing elit. {mainScore20} out of 20 Erat enim Polemonis. Iam contemni non poteris. Equidem etiam Epicurum, in physicis quidem, Democriteum puto. An quod ita callida est, ut optime possit architectari voluptates? Iam quae corporis sunt, ea nec auctoritatem cum animi partibus, comparandam et cognitionem habent faciliorem. Duo Reges: constructio interrete. Sine ea igitur iucunde negat posse se vivere? Cur tantas regiones barbarorum pedibus obiit, tot maria transmisit? Bonum incolumis acies: misera caecitas. Cur tantas regiones barbarorum pedibus obiit, tot maria transmisit?",
},
{
type: resultContentTypes.label,
style: "scoreCounter270",
label: "{mainScore100}% {secondaryScore10}",
animate: true,
visibleScoreDomain: { secondaryScore: [60, 80] },
},
{
type: resultContentTypes.label,
style: "scoreCounter180",
label: "{mainScore100}% {secondaryScore10}",
animate: true,
visibleScoreDomain: { mainScore: [Number.MIN_SAFE_INTEGER, 75] },
},
{
type: resultContentTypes.image,
url: "https://via.placeholder.com/350x65",
size: 0.7,
alt: "Placeholder 1",
},
{
type: resultContentTypes.graph,
dataUrl: "GET;/surveytool/mockLineGraph.json?score={mainScore}" as AnswerDataUrl,
format: "line",
titleLabel: "Line graph",
},
{
type: resultContentTypes.graph,
dataUrl: "/surveytool/mockBarGraph.json" as AnswerDataUrl,
format: "bar",
titleLabel: "Bar graph",
},
{
type: resultContentTypes.graph,
dataUrl: "/surveytool/mockSingleBarGraph.json" as AnswerDataUrl,
format: "bar",
titleLabel: "Bar graph",
hideLegend: true,
},
{ type: resultContentTypes.button, label: "Restart ({countdown})", function: "restart", icon: "redo" },
{
type: resultContentTypes.button,
label: "Save results",
function: "postData",
url: "POST;https://example.org/api/answer" as AnswerDataUrl,
},
{
type: resultContentTypes.button,
label: "Open results in new tab",
function: "link",
url: "https://example.org/?score={mainScore}" as AnswerDataUrl,
openInTab: true,
},
{
type: resultContentTypes.button,
label: "Navigate to result page",
function: "link",
url: "https://example.org/?score={mainScore}" as AnswerDataUrl,
},
{
type: resultContentTypes.iframe,
url: "https://example.org/?score={mainScore}" as AnswerDataUrl,
height: 300,
disableScroll: true,
},
{
type: resultContentTypes.label,
style: "description",
label: "The survey will restart in {countdown} seconds.",
},
],
},
settings: {
customMessageHandler: (messages: ExternalMessageType[]): boolean => {
// eslint-disable-next-line no-console
messages.forEach(console.info);
return true;
},
// eslint-disable-next-line no-console
onAnswerSubmit: (data) => console.log("onAnswerSubmit", data),
},
// theme: {
// darkMode: true,
// values: {
// colors: { controlHighlight: "#ff00ff" },
// sizes: { radius: "0px" },
// fonts: { title: "Serif", description: "fantasy", question: "cursive", text: "sans-serif" },
// breakpoints: { md: "600px" },
// },
// },
// labels: { footerText: "Copyright" },
};