analytica-frontend-lib 1.1.31 → 1.1.32
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/dist/Quiz/index.js +40 -0
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +40 -0
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Quiz/useQuizStore/index.d.mts +6 -1
- package/dist/Quiz/useQuizStore/index.d.ts +6 -1
- package/dist/Quiz/useQuizStore/index.js +42 -0
- package/dist/Quiz/useQuizStore/index.js.map +1 -1
- package/dist/Quiz/useQuizStore/index.mjs +41 -0
- package/dist/Quiz/useQuizStore/index.mjs.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/Quiz/index.js
CHANGED
|
@@ -976,10 +976,12 @@ var import_react12 = require("react");
|
|
|
976
976
|
// src/components/Quiz/useQuizStore.ts
|
|
977
977
|
var import_zustand2 = require("zustand");
|
|
978
978
|
var import_middleware = require("zustand/middleware");
|
|
979
|
+
var MINUTE_INTERVAL_MS = 6e4;
|
|
979
980
|
var useQuizStore = (0, import_zustand2.create)()(
|
|
980
981
|
(0, import_middleware.devtools)(
|
|
981
982
|
(set, get) => {
|
|
982
983
|
let timerInterval = null;
|
|
984
|
+
let minuteCallbackInterval = null;
|
|
983
985
|
const startTimer = () => {
|
|
984
986
|
if (get().isFinished) {
|
|
985
987
|
return;
|
|
@@ -998,6 +1000,35 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
998
1000
|
timerInterval = null;
|
|
999
1001
|
}
|
|
1000
1002
|
};
|
|
1003
|
+
const setMinuteCallback = (callback) => {
|
|
1004
|
+
set({ minuteCallback: callback });
|
|
1005
|
+
};
|
|
1006
|
+
const startMinuteCallback = () => {
|
|
1007
|
+
const { minuteCallback, isFinished } = get();
|
|
1008
|
+
if (isFinished || !minuteCallback) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
if (minuteCallbackInterval) {
|
|
1012
|
+
clearInterval(minuteCallbackInterval);
|
|
1013
|
+
}
|
|
1014
|
+
minuteCallbackInterval = setInterval(() => {
|
|
1015
|
+
const {
|
|
1016
|
+
minuteCallback: currentCallback,
|
|
1017
|
+
isFinished: currentIsFinished
|
|
1018
|
+
} = get();
|
|
1019
|
+
if (currentIsFinished || !currentCallback) {
|
|
1020
|
+
stopMinuteCallback();
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
currentCallback();
|
|
1024
|
+
}, MINUTE_INTERVAL_MS);
|
|
1025
|
+
};
|
|
1026
|
+
const stopMinuteCallback = () => {
|
|
1027
|
+
if (minuteCallbackInterval) {
|
|
1028
|
+
clearInterval(minuteCallbackInterval);
|
|
1029
|
+
minuteCallbackInterval = null;
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1001
1032
|
return {
|
|
1002
1033
|
// Initial State
|
|
1003
1034
|
currentQuestionIndex: 0,
|
|
@@ -1008,6 +1039,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1008
1039
|
isFinished: false,
|
|
1009
1040
|
userId: "",
|
|
1010
1041
|
variant: "default",
|
|
1042
|
+
minuteCallback: null,
|
|
1011
1043
|
questionsResult: null,
|
|
1012
1044
|
currentQuestionResult: null,
|
|
1013
1045
|
// Setters
|
|
@@ -1242,13 +1274,16 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1242
1274
|
startQuiz: () => {
|
|
1243
1275
|
set({ isStarted: true, timeElapsed: 0 });
|
|
1244
1276
|
startTimer();
|
|
1277
|
+
startMinuteCallback();
|
|
1245
1278
|
},
|
|
1246
1279
|
finishQuiz: () => {
|
|
1247
1280
|
set({ isFinished: true });
|
|
1248
1281
|
stopTimer();
|
|
1282
|
+
stopMinuteCallback();
|
|
1249
1283
|
},
|
|
1250
1284
|
resetQuiz: () => {
|
|
1251
1285
|
stopTimer();
|
|
1286
|
+
stopMinuteCallback();
|
|
1252
1287
|
set({
|
|
1253
1288
|
currentQuestionIndex: 0,
|
|
1254
1289
|
selectedAnswers: {},
|
|
@@ -1258,6 +1293,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1258
1293
|
isFinished: false,
|
|
1259
1294
|
userId: "",
|
|
1260
1295
|
variant: "default",
|
|
1296
|
+
minuteCallback: null,
|
|
1261
1297
|
questionsResult: null,
|
|
1262
1298
|
currentQuestionResult: null
|
|
1263
1299
|
});
|
|
@@ -1266,6 +1302,10 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1266
1302
|
updateTime: (time) => set({ timeElapsed: time }),
|
|
1267
1303
|
startTimer,
|
|
1268
1304
|
stopTimer,
|
|
1305
|
+
// Minute Callback
|
|
1306
|
+
setMinuteCallback,
|
|
1307
|
+
startMinuteCallback,
|
|
1308
|
+
stopMinuteCallback,
|
|
1269
1309
|
// Getters
|
|
1270
1310
|
getCurrentQuestion: () => {
|
|
1271
1311
|
const { currentQuestionIndex, getActiveQuiz } = get();
|