@cuemath/leap 2.8.61-hg1 → 2.8.61-rj-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/dist/features/circle-games/game-launcher/dal/use-get-circle-home-details-dal/use-get-circle-home-details-dal.js +77 -85
- package/dist/features/circle-games/game-launcher/dal/use-get-circle-home-details-dal/use-get-circle-home-details-dal.js.map +1 -1
- package/dist/features/circle-games/game-launcher/game-launcher.js +66 -76
- package/dist/features/circle-games/game-launcher/game-launcher.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js +37 -38
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js +49 -50
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view-types.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view.js +53 -47
- package/dist/features/circle-games/games/web-view/web-view.js.map +1 -1
- package/dist/features/journey/hooks/use-get-eligible-journeys-via-route.js +13 -0
- package/dist/features/journey/hooks/use-get-eligible-journeys-via-route.js.map +1 -0
- package/dist/features/journey/use-journey/journey-context-provider.js +74 -40
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/features/journey/use-journey/journey-styled.js +1 -1
- package/dist/features/journey/use-journey/journey-styled.js.map +1 -1
- package/dist/features/journey/user-journey-api/user-journey-api.js +12 -0
- package/dist/features/journey/user-journey-api/user-journey-api.js.map +1 -0
- package/dist/index.d.ts +27 -33
- package/dist/index.js +78 -78
- package/package.json +1 -1
- package/dist/features/circle-games/game-launcher/api/update-circle-onboarding/constants.js +0 -5
- package/dist/features/circle-games/game-launcher/api/update-circle-onboarding/constants.js.map +0 -1
- package/dist/features/circle-games/game-launcher/api/update-circle-onboarding/post-circle-coachmark-api.js +0 -9
- package/dist/features/circle-games/game-launcher/api/update-circle-onboarding/post-circle-coachmark-api.js.map +0 -1
- package/dist/features/circle-games/game-launcher/dal/use-post-update-circle-journey-dal/use-post-update-circle-journey-dal.js +0 -23
- package/dist/features/circle-games/game-launcher/dal/use-post-update-circle-journey-dal/use-post-update-circle-journey-dal.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-view-types.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view-types.ts"],"sourcesContent":["import type { IAvatarLayer } from '../../../ui/avatar/avatar-types';\nimport type { TUserTypes } from '../../../ui/types';\nimport type { WebViewEvent, ProjectOutcome, ProjectType } from './enums';\nimport type { WEBVIEW_ANALYTICS_EVENTS } from './web-view-analytics-events';\nimport type { IframeHTMLAttributes } from 'react';\n\nexport interface IPlayer {\n id: string;\n username: string;\n grade?: string;\n avatar?: IAvatarLayer[] | null;\n playerType: TUserTypes;\n countryCode: string;\n
|
1
|
+
{"version":3,"file":"web-view-types.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view-types.ts"],"sourcesContent":["import type { IAvatarLayer } from '../../../ui/avatar/avatar-types';\nimport type { TUserTypes } from '../../../ui/types';\nimport type { WebViewEvent, ProjectOutcome, ProjectType } from './enums';\nimport type { WEBVIEW_ANALYTICS_EVENTS } from './web-view-analytics-events';\nimport type { IframeHTMLAttributes } from 'react';\n\nexport interface IPlayer {\n id: string;\n username: string;\n grade?: string;\n avatar?: IAvatarLayer[] | null;\n playerType: TUserTypes;\n countryCode: string;\n}\n\ninterface ISyncableWebGameProps {\n joinByRoomId?: string;\n enableSync?: boolean; // applicable for all except multiplayer games and tables\n}\n\ninterface IBaseWebGameProps {\n projectId: string;\n variant: string;\n projectType: ProjectType;\n enableCloseButton?: boolean;\n}\n\nexport interface IMultiplayerWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n enablePlayerTurnIndicators?: boolean;\n}\n\nexport interface IPuzzleWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n question: string;\n askHintPermission?: boolean;\n}\n\nexport interface ILessonWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n miniGameIdentifier: string;\n sessionId: string;\n targetQuestions: number;\n}\n\nexport interface ITableWebGameProps extends IBaseWebGameProps {\n tableNumber: number;\n infiniteModeHighScore?: number;\n}\n\nexport interface IVibrationPattern {\n pattern: number[] | number;\n}\n\nexport enum IStatsToAwardErrorCode {\n DEFAULT = 'default',\n SUCCESS = 'success',\n FAIL = 'fail',\n}\n\nexport interface IPlayerStats {\n points: number;\n accuracy: number;\n timeSpent: number;\n streakDays: number;\n streakStatusToday: 'pending' | 'completed';\n errorCode: IStatsToAwardErrorCode;\n outcome: ProjectOutcome;\n value: string;\n starEligibleTime?: number;\n starEligibleAccuracy?: number;\n starRewarded?: boolean;\n}\n\nexport interface IInfoMessage {\n message: string;\n position: 'top' | 'bottom';\n}\n\nexport interface ITrackEvent {\n eventName: typeof WEBVIEW_ANALYTICS_EVENTS;\n properties: Record<string, unknown>;\n}\n\nexport interface IWebViewProps extends IframeHTMLAttributes<HTMLIFrameElement> {\n baseUrl: string;\n projectDetails:\n | IMultiplayerWebGameProps\n | IPuzzleWebGameProps\n | ILessonWebGameProps\n | ITableWebGameProps;\n parentDomain: string;\n playerDetails: IPlayer;\n onBack?: () => void;\n onGameLoad?: () => void;\n onGamePlayFinish?: (playerStats: IPlayerStats) => void;\n handleInfoMessage?: (infoMessage: IInfoMessage) => void;\n}\n\nexport interface IMessageProps {\n event: `${WebViewEvent}`;\n payload: IVibrationPattern | IPlayerStats | IInfoMessage | null;\n}\n"],"names":["IStatsToAwardErrorCode"],"mappings":"AAmDY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,UAAU,WACVA,EAAA,OAAO,QAHGA,IAAAA,KAAA,CAAA,CAAA;"}
|
@@ -1,28 +1,28 @@
|
|
1
1
|
import { jsx as P } from "react/jsx-runtime";
|
2
|
-
import { forwardRef as
|
3
|
-
import { useUIContext as
|
4
|
-
import { ALLOWED_ORIGIN as
|
2
|
+
import { forwardRef as G, useRef as W, useMemo as _, useCallback as T, useImperativeHandle as V, useEffect as $ } from "react";
|
3
|
+
import { useUIContext as B } from "../../../ui/context/context.js";
|
4
|
+
import { ALLOWED_ORIGIN as N } from "./constants.js";
|
5
5
|
import { ProjectType as s } from "./enums/project-type-enum.js";
|
6
6
|
import { WebViewEvent as o } from "./enums/web-view-events-enum.js";
|
7
|
-
const
|
7
|
+
const F = G((C, I) => {
|
8
8
|
const {
|
9
|
-
baseUrl:
|
10
|
-
projectDetails:
|
11
|
-
playerDetails:
|
9
|
+
baseUrl: L,
|
10
|
+
projectDetails: y,
|
11
|
+
playerDetails: v,
|
12
12
|
onGameLoad: a,
|
13
|
-
onGamePlayFinish:
|
14
|
-
handleInfoMessage:
|
13
|
+
onGamePlayFinish: p,
|
14
|
+
handleInfoMessage: c,
|
15
15
|
onBack: f,
|
16
|
-
parentDomain:
|
17
|
-
...
|
18
|
-
} =
|
16
|
+
parentDomain: w,
|
17
|
+
...R
|
18
|
+
} = C, l = W(null), D = _(() => v, [v]), t = _(() => y, [y]);
|
19
19
|
let A = "";
|
20
|
-
const { onEvent: O } =
|
20
|
+
const { onEvent: O } = B();
|
21
21
|
t.projectType === s.LESSON && (A = t.miniGameIdentifier);
|
22
|
-
const m =
|
23
|
-
const { enableCloseButton:
|
22
|
+
const m = T(() => {
|
23
|
+
const { enableCloseButton: n = !0 } = t;
|
24
24
|
let e = {
|
25
|
-
enableCloseButton:
|
25
|
+
enableCloseButton: n
|
26
26
|
};
|
27
27
|
return t.projectType === s.GAME && (e = {
|
28
28
|
...e,
|
@@ -37,60 +37,66 @@ const Z = V((I, b) => {
|
|
37
37
|
...e,
|
38
38
|
...t
|
39
39
|
}), e;
|
40
|
-
}, [t]),
|
40
|
+
}, [t]), E = T(() => {
|
41
41
|
var e, r;
|
42
|
-
const
|
42
|
+
const n = m();
|
43
43
|
(r = (e = l.current) == null ? void 0 : e.contentWindow) == null || r.postMessage(
|
44
44
|
JSON.stringify({
|
45
45
|
event: o.GAME_DATA,
|
46
|
-
payload:
|
46
|
+
payload: n
|
47
47
|
}),
|
48
|
-
|
48
|
+
N
|
49
49
|
);
|
50
|
-
}, [m]),
|
50
|
+
}, [m]), g = T(() => {
|
51
51
|
var e, r;
|
52
|
-
const
|
52
|
+
const n = m();
|
53
53
|
(r = (e = l.current) == null ? void 0 : e.contentWindow) == null || r.postMessage(
|
54
54
|
JSON.stringify({
|
55
55
|
event: o.SET_CONFIG,
|
56
56
|
payload: {
|
57
|
-
user:
|
58
|
-
projectConfig:
|
59
|
-
parentDomain:
|
57
|
+
user: D,
|
58
|
+
projectConfig: n,
|
59
|
+
parentDomain: w
|
60
60
|
}
|
61
61
|
}),
|
62
|
-
|
62
|
+
N
|
63
63
|
);
|
64
|
-
}, [
|
65
|
-
|
66
|
-
const
|
67
|
-
var j,
|
68
|
-
const r = e.data,
|
69
|
-
if (
|
70
|
-
const { pattern: u } =
|
71
|
-
|
64
|
+
}, [D, m, w]);
|
65
|
+
return V(I, () => l.current, []), $(() => {
|
66
|
+
const n = (e) => {
|
67
|
+
var j, S;
|
68
|
+
const r = e.data, b = typeof r == "string" ? JSON.parse(r) : r, { event: i, payload: d = null } = b;
|
69
|
+
if (i === o.VIBRATE) {
|
70
|
+
const { pattern: u } = d;
|
71
|
+
(S = (j = window.navigator).vibrate) == null || S.call(j, u);
|
72
72
|
}
|
73
|
-
if (
|
74
|
-
const { eventName: u, properties:
|
75
|
-
O(u,
|
73
|
+
if (i === o.GAME_BACK && (f == null || f()), i === o.HIDE_LOADER && (a == null || a()), i === o.LOAD_DATA_FROM_APP && (E == null || E()), i === o.GET_CONFIG && g(), i === o.UPDATE_STATS && (p == null || p(d)), i === o.SHOW_SNACKBAR && (c == null || c(d)), i === o.TRACK_EVENT) {
|
74
|
+
const { eventName: u, properties: M } = d;
|
75
|
+
O(u, M);
|
76
76
|
}
|
77
77
|
};
|
78
|
-
return window.addEventListener("message",
|
79
|
-
window.removeEventListener("message",
|
78
|
+
return window.addEventListener("message", n), () => {
|
79
|
+
window.removeEventListener("message", n);
|
80
80
|
};
|
81
81
|
}, [
|
82
|
-
p,
|
83
|
-
f,
|
84
82
|
c,
|
83
|
+
f,
|
84
|
+
p,
|
85
85
|
a,
|
86
|
-
|
87
|
-
|
86
|
+
g,
|
87
|
+
E,
|
88
88
|
O
|
89
|
-
])
|
90
|
-
|
91
|
-
|
89
|
+
]), /* @__PURE__ */ P(
|
90
|
+
"iframe",
|
91
|
+
{
|
92
|
+
...R,
|
93
|
+
ref: l,
|
94
|
+
src: `${L}/play-game/${t.projectId}/${t.variant}${A ? `/${A}` : ""}?version=2`,
|
95
|
+
allow: "autoplay"
|
96
|
+
}
|
97
|
+
);
|
92
98
|
});
|
93
99
|
export {
|
94
|
-
|
100
|
+
F as WebView
|
95
101
|
};
|
96
102
|
//# sourceMappingURL=web-view.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["
|
1
|
+
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["import type {\n IInfoMessage,\n ILessonWebGameProps,\n IMessageProps,\n IMultiplayerWebGameProps,\n IPlayerStats,\n IPuzzleWebGameProps,\n ITableWebGameProps,\n IVibrationPattern,\n IWebViewProps,\n} from './web-view-types';\nimport type { ForwardedRef } from 'react';\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport { useUIContext } from '../../../ui/context/context';\nimport { ALLOWED_ORIGIN } from './constants';\nimport { ProjectType, WebViewEvent } from './enums';\n\nexport const WebView = forwardRef((props: IWebViewProps, ref: ForwardedRef<HTMLIFrameElement>) => {\n const {\n baseUrl,\n projectDetails,\n playerDetails,\n onGameLoad,\n onGamePlayFinish,\n handleInfoMessage,\n onBack,\n parentDomain,\n ...rest\n } = props;\n const webViewRef = useRef<HTMLIFrameElement>(null);\n const memoizedPlayerDetails = useMemo(() => playerDetails, [playerDetails]);\n const memoizedProjectDetails = useMemo(() => projectDetails, [projectDetails]);\n\n let miniGameIdentifier = '';\n const { onEvent: trackEvent } = useUIContext();\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n miniGameIdentifier = (memoizedProjectDetails as ILessonWebGameProps).miniGameIdentifier;\n }\n\n const getProjectDetails = useCallback(() => {\n const { enableCloseButton = true } = memoizedProjectDetails;\n\n let payload = {\n enableCloseButton,\n } as IMultiplayerWebGameProps | IPuzzleWebGameProps | ILessonWebGameProps;\n\n if (memoizedProjectDetails.projectType === ProjectType.GAME) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IMultiplayerWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.PUZZLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IPuzzleWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ILessonWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.TABLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ITableWebGameProps;\n }\n\n return payload;\n }, [memoizedProjectDetails]);\n\n const sendGamesData = useCallback(() => {\n const payload = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.GAME_DATA,\n payload,\n }),\n ALLOWED_ORIGIN,\n );\n }, [getProjectDetails]);\n\n const setConfig = useCallback(() => {\n const projectConfig = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.SET_CONFIG,\n payload: {\n user: memoizedPlayerDetails,\n projectConfig,\n parentDomain,\n },\n }),\n ALLOWED_ORIGIN,\n );\n }, [memoizedPlayerDetails, getProjectDetails, parentDomain]);\n\n useImperativeHandle(ref, () => webViewRef.current as HTMLIFrameElement, []);\n\n useEffect(() => {\n const handleMessage = (e: MessageEvent) => {\n const data: string = e.data;\n const parsedData = typeof data === 'string' ? JSON.parse(data) : (data as IMessageProps);\n\n const { event, payload = null } = parsedData;\n\n if (event === WebViewEvent.VIBRATE) {\n const { pattern } = payload as IVibrationPattern;\n\n window.navigator.vibrate?.(pattern);\n }\n\n if (event === WebViewEvent.GAME_BACK) {\n onBack?.();\n }\n\n if (event === WebViewEvent.HIDE_LOADER) {\n onGameLoad?.();\n }\n\n if (event === WebViewEvent.LOAD_DATA_FROM_APP) {\n sendGamesData?.();\n }\n\n if (event === WebViewEvent.GET_CONFIG) {\n setConfig();\n }\n\n if (event === WebViewEvent.UPDATE_STATS) {\n onGamePlayFinish?.(payload as IPlayerStats);\n }\n\n if (event === WebViewEvent.SHOW_SNACKBAR) {\n handleInfoMessage?.(payload as IInfoMessage);\n }\n\n if (event === WebViewEvent.TRACK_EVENT) {\n const { eventName, properties } = payload;\n\n trackEvent(eventName, properties);\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n return () => {\n window.removeEventListener('message', handleMessage);\n };\n }, [\n handleInfoMessage,\n onBack,\n onGamePlayFinish,\n onGameLoad,\n setConfig,\n sendGamesData,\n trackEvent,\n ]);\n\n return (\n <iframe\n {...rest}\n ref={webViewRef}\n src={`${baseUrl}/play-game/${memoizedProjectDetails.projectId}/${\n memoizedProjectDetails.variant\n }${miniGameIdentifier ? `/${miniGameIdentifier}` : ''}?version=2`}\n allow=\"autoplay\"\n />\n );\n});\n"],"names":["WebView","forwardRef","props","ref","baseUrl","projectDetails","playerDetails","onGameLoad","onGamePlayFinish","handleInfoMessage","onBack","parentDomain","rest","webViewRef","useRef","memoizedPlayerDetails","useMemo","memoizedProjectDetails","miniGameIdentifier","trackEvent","useUIContext","ProjectType","getProjectDetails","useCallback","enableCloseButton","payload","sendGamesData","_b","_a","WebViewEvent","ALLOWED_ORIGIN","setConfig","projectConfig","useImperativeHandle","useEffect","handleMessage","data","parsed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AC,EAAe,IAAAhB;AAElC,QAAAN,EAAWqB,GAAWC,CAAU;AAAA,MAClC;AAAA,IAAA;AAGK,kBAAA,iBAAiB,WAAWN,CAAa,GAEzC,MAAM;AACJ,aAAA,oBAAoB,WAAWA,CAAa;AAAA,IAAA;AAAA,EACrD,GACC;AAAA,IACD1B;AAAA,IACAC;AAAA,IACAF;AAAA,IACAD;AAAA,IACAwB;AAAA,IACAL;AAAA,IACAP;AAAA,EAAA,CACD,GAGC,gBAAAuB;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG9B;AAAA,MACJ,KAAKC;AAAA,MACL,KAAK,GAAGT,CAAO,cAAca,EAAuB,SAAS,IAC3DA,EAAuB,OACzB,GAAGC,IAAqB,IAAIA,CAAkB,KAAK,EAAE;AAAA,MACrD,OAAM;AAAA,IAAA;AAAA,EAAA;AAGZ,CAAC;"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { useMemo as m } from "react";
|
2
|
+
import { useJourney as b } from "../use-journey/use-journey.js";
|
3
|
+
const t = (i) => {
|
4
|
+
const { userCompletedJourneyIds: l } = b();
|
5
|
+
return m(
|
6
|
+
() => i ? i == null ? void 0 : i.filter((c) => !(l != null && l.includes(c))) : [],
|
7
|
+
[i, l]
|
8
|
+
);
|
9
|
+
};
|
10
|
+
export {
|
11
|
+
t as useGetEligibleJourneysViaRoute
|
12
|
+
};
|
13
|
+
//# sourceMappingURL=use-get-eligible-journeys-via-route.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-get-eligible-journeys-via-route.js","sources":["../../../../src/features/journey/hooks/use-get-eligible-journeys-via-route.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\n\nimport { useMemo } from 'react';\n\nimport { useJourney } from '../use-journey/use-journey';\n\n/**\n * Unless the useGetUserJourney API is resolved, this hook will return an empty array.\n * This is because the userCompletedJourneyIds are set from the API response.\n * And Unless the API is resolved, we cannot determine the eligible journeys.\n * So, we return an empty array.\n */\nexport const useGetEligibleJourneysViaRoute = (routeJourneyIds: TJourneyId[]) => {\n const { userCompletedJourneyIds } = useJourney();\n\n const eligibleJourneys: TJourneyId[] = useMemo(\n () =>\n routeJourneyIds\n ? routeJourneyIds?.filter(journeyId => !userCompletedJourneyIds?.includes(journeyId))\n : [],\n [routeJourneyIds, userCompletedJourneyIds],\n );\n\n return eligibleJourneys;\n};\n"],"names":["useGetEligibleJourneysViaRoute","routeJourneyIds","userCompletedJourneyIds","useJourney","useMemo","journeyId"],"mappings":";;AAYa,MAAAA,IAAiC,CAACC,MAAkC;AACzE,QAAA,EAAE,yBAAAC,MAA4BC;AAU7B,SARgCC;AAAA,IACrC,MACEH,IACIA,KAAA,gBAAAA,EAAiB,OAAO,CAAAI,MAAa,EAACH,KAAA,QAAAA,EAAyB,SAASG,OACxE,CAAC;AAAA,IACP,CAACJ,GAAiBC,CAAuB;AAAA,EAAA;AAI7C;"}
|
@@ -1,71 +1,105 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { createContext as
|
3
|
-
import { Coachmark as
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
1
|
+
import { jsxs as U, jsx as w } from "react/jsx-runtime";
|
2
|
+
import { createContext as b, useState as h, useRef as p, useCallback as l, useMemo as q, useEffect as R } from "react";
|
3
|
+
import { Coachmark as D } from "../comps/coachmark/coachmark.js";
|
4
|
+
import { usePostUserJourney as L, useGetUserJourney as N } from "../user-journey-api/user-journey-api.js";
|
5
|
+
import { Overlay as M } from "./journey-styled.js";
|
6
|
+
const z = b(null), H = ({ children: T, appId: u, userId: o }) => {
|
7
|
+
const [v, k] = h([]), [c, s] = h([]), [J, x] = h(!1), a = p(-1), r = p(), d = p([]), { post: _ } = L(), { data: f = null, get: g } = N(), A = l(
|
7
8
|
(e, t) => {
|
8
|
-
if (
|
9
|
+
if (c.length > 0) {
|
9
10
|
console.error(
|
10
11
|
`setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
11
12
|
);
|
12
13
|
return;
|
13
14
|
}
|
14
|
-
r.current = e,
|
15
|
+
x(!0), r.current = e, a.current = -1, s([...t]);
|
15
16
|
},
|
16
|
-
[
|
17
|
-
),
|
18
|
-
|
17
|
+
[c.length]
|
18
|
+
), m = l(() => {
|
19
|
+
d.current.forEach((e) => {
|
19
20
|
clearTimeout(e);
|
20
|
-
}),
|
21
|
-
}, []),
|
21
|
+
}), d.current = [], r.current = void 0, a.current = -1, s([]), x(!1);
|
22
|
+
}, []), $ = l(
|
23
|
+
(e) => {
|
24
|
+
k((t) => [...t, e]), _({
|
25
|
+
app_id: u,
|
26
|
+
user_id: o,
|
27
|
+
journey_id: e,
|
28
|
+
journey_status: "COMPLETED"
|
29
|
+
}), m();
|
30
|
+
},
|
31
|
+
[u, m, _, o]
|
32
|
+
), E = l((e, t) => {
|
22
33
|
if (!r.current || e !== r.current) {
|
23
34
|
console.error(
|
24
35
|
r.current ? `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}` : "addCoachmark was called before setJourney and Journey ID is undefined"
|
25
36
|
);
|
26
37
|
return;
|
27
38
|
}
|
28
|
-
|
29
|
-
}, []),
|
30
|
-
(e, t = !1,
|
39
|
+
s((y) => [...y, t]);
|
40
|
+
}, []), P = l(
|
41
|
+
(e, t = !1, y = 0) => {
|
31
42
|
if (!r.current || e !== r.current) {
|
32
43
|
console.error(
|
33
44
|
r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
34
45
|
);
|
35
46
|
return;
|
36
47
|
}
|
37
|
-
|
38
|
-
const
|
39
|
-
clearTimeout(
|
40
|
-
const n =
|
41
|
-
|
42
|
-
if (n >=
|
43
|
-
return r.current = void 0,
|
44
|
-
|
45
|
-
const
|
46
|
-
return
|
48
|
+
y !== 0 && s((n) => n.map((i) => ({ ...i, isActive: !1 })));
|
49
|
+
const j = setTimeout(() => {
|
50
|
+
clearTimeout(j);
|
51
|
+
const n = a.current + 1;
|
52
|
+
s((i) => {
|
53
|
+
if (n >= i.length || i.length === 0)
|
54
|
+
return r.current = void 0, a.current = -1, [];
|
55
|
+
a.current = n;
|
56
|
+
const C = [...i];
|
57
|
+
return C[n].isActive = !0, n > 0 && (C[n - 1].isActive = t), C;
|
47
58
|
});
|
48
|
-
},
|
49
|
-
|
59
|
+
}, y);
|
60
|
+
d.current.push(j);
|
50
61
|
},
|
51
62
|
[]
|
52
|
-
),
|
63
|
+
), O = q(
|
53
64
|
() => ({
|
54
|
-
nextCoachmark:
|
55
|
-
setJourney:
|
56
|
-
addCoachmark:
|
57
|
-
clearJourney:
|
58
|
-
|
65
|
+
nextCoachmark: P,
|
66
|
+
setJourney: A,
|
67
|
+
addCoachmark: E,
|
68
|
+
clearJourney: m,
|
69
|
+
endJourney: $,
|
70
|
+
coachmarks: c,
|
71
|
+
userCompletedJourneyIds: v,
|
72
|
+
isJourneyActive: J
|
59
73
|
}),
|
60
|
-
[
|
74
|
+
[
|
75
|
+
P,
|
76
|
+
A,
|
77
|
+
E,
|
78
|
+
m,
|
79
|
+
$,
|
80
|
+
c,
|
81
|
+
v,
|
82
|
+
J
|
83
|
+
]
|
61
84
|
);
|
62
|
-
return
|
63
|
-
|
64
|
-
|
85
|
+
return R(() => {
|
86
|
+
u && o && g(o, {
|
87
|
+
app_id: u,
|
88
|
+
user_id: o,
|
89
|
+
journey_status: "COMPLETED"
|
90
|
+
});
|
91
|
+
}, [u, g, o]), R(() => {
|
92
|
+
if (f) {
|
93
|
+
const e = f.map((t) => t.journey_id);
|
94
|
+
k(e);
|
95
|
+
}
|
96
|
+
}, [f]), /* @__PURE__ */ U(z.Provider, { value: O, children: [
|
97
|
+
J && /* @__PURE__ */ w(M, { children: c.map((e, t) => /* @__PURE__ */ w(D, { coachmark: e }, `coachmark-${t}`)) }),
|
98
|
+
T
|
65
99
|
] });
|
66
100
|
};
|
67
101
|
export {
|
68
|
-
|
69
|
-
|
102
|
+
z as JourneyContext,
|
103
|
+
H as JourneyProvider
|
70
104
|
};
|
71
105
|
//# sourceMappingURL=journey-context-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { ICoachmarkProps, IJourneyContext } from './journey-context-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { createContext, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<{ children: ReactNode }> = ({ children }) => {\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n currentJourneyIdStudent.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n }, []);\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n console.error(\n currentJourneyIdStudent.current\n ? `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n console.error(\n currentJourneyIdStudent.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n coachmarks: coachmarkList,\n }),\n [nextCoachmark, setJourney, addCoachmark, clearJourney, coachmarkList],\n );\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {coachmarkList.length > 0 && (\n <S.BlurOverlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.BlurOverlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","coachmarkList","setCoachmarkList","useState","currentIndex","useRef","currentJourneyIdStudent","timerRefs","setJourney","useCallback","id","coachmarks","clearJourney","timer","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;AAUa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA+C,CAAC,EAAE,UAAAC,QAAe;AAC5E,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,CAAE,CAAA,GAClEC,IAAeC,EAAO,EAAE,GACxBC,IAA0BD,KAC1BE,IAAYF,EAAwC,CAAA,CAAE,GAEtDG,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAV,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEK,EAAwB,OAAO,0BAA0BI,CAAE;AAAA,QAAA;AAG9H;AAAA,MACF;AACA,MAAAJ,EAAwB,UAAUI,GAClCN,EAAa,UAAU,IACNF,EAAA,CAAC,GAAGS,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAACV,EAAc,MAAM;AAAA,EAAA,GAGjBW,IAAeH,EAAY,MAAM;AAE3B,IAAAF,EAAA,QAAQ,QAAQ,CAASM,MAAA;AACjC,mBAAaA,CAAK;AAAA,IAAA,CACnB,GACDN,EAAU,UAAU,IACpBD,EAAwB,UAAU,QAClCF,EAAa,UAAU,IACvBF,EAAiB,CAAE,CAAA;AAAA,EACrB,GAAG,CAAE,CAAA,GAECY,IAAeL,EAAY,CAACC,GAAgBK,MAA+B;AAC/E,QAAI,CAACT,EAAwB,WAAWI,MAAOJ,EAAwB,SAAS;AACtE,cAAA;AAAA,QACNA,EAAwB,UACpB,iDAAiDA,EAAwB,OAAO,0BAA0BI,CAAE,KAC5G;AAAA,MAAA;AAGN;AAAA,IACF;AAEA,IAAAR,EAAiB,CAAQc,MAAA,CAAC,GAAGA,GAAMD,CAAS,CAAC;AAAA,EAC/C,GAAG,CAAE,CAAA,GAECE,IAAgBR;AAAA,IACpB,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WAAAf,EAAA,GAAtB,aAAac,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED7B;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
1
|
+
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const { data: userCompletedJourneys = null, get: getJourneyProgress } = useGetUserJourney();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {isJourneyActive && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","useGetUserJourney","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","S.Overlay","index","jsx","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAAC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;AAAA,MACA,cAAAL;AAAA,MACA,YAAAE;AAAA,MACA,YAAYnB;AAAA,MACZ,yBAAAH;AAAA,MACA,iBAAAK;AAAA,IAAA;AAAA,IAEF;AAAA,MACEsB;AAAA,MACAX;AAAA,MACAS;AAAA,MACAL;AAAA,MACAE;AAAA,MACAnB;AAAA,MACAH;AAAA,MACAK;AAAA,IACF;AAAA,EAAA;AAIF,SAAA+B,EAAU,MAAM;AACd,IAAItC,KAASC,KACXe,EAAmBf,GAAQ;AAAA,MACzB,QAAQD;AAAA,MACR,SAASC;AAAA,MACT,gBAAgB;AAAA,IAAA,CACjB;AAAA,EAEF,GAAA,CAACD,GAAOgB,GAAoBf,CAAM,CAAC,GAGtCqC,EAAU,MAAM;AACd,QAAIvB,GAAuB;AACzB,YAAMwB,IAA2BxB,EAAsB,IAAI,CAAAyB,MAAWA,EAAQ,UAAU;AAExF,MAAArC,EAA2BoC,CAAwB;AAAA,IACrD;AAAA,EAAA,GACC,CAACxB,CAAqB,CAAC,GAGvB,gBAAA0B,EAAA7C,EAAe,UAAf,EAAwB,OAAOwC,GAC7B,UAAA;AAAA,IAAA7B,uBACEmC,GAAA,EACE,UAAArC,EAAc,IAAI,CAACuB,GAAWe,MAC7B,gBAAAC,EAACC,KAAqC,WAAAjB,KAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED5C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"journey-styled.js","sources":["../../../../src/features/journey/use-journey/journey-styled.tsx"],"sourcesContent":["import styled from 'styled-components';\n\nimport { BLUR_OVERLAY_Z_INDEX } from './constants';\n\nexport const
|
1
|
+
{"version":3,"file":"journey-styled.js","sources":["../../../../src/features/journey/use-journey/journey-styled.tsx"],"sourcesContent":["import styled from 'styled-components';\n\nimport { BLUR_OVERLAY_Z_INDEX } from './constants';\n\nexport const Overlay = styled.div`\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: ${BLUR_OVERLAY_Z_INDEX};\n`;\n"],"names":["Overlay","styled","BLUR_OVERLAY_Z_INDEX"],"mappings":";;AAIO,MAAMA,IAAUC,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMjBC,CAAoB;AAAA;"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { createGetAPI as o, createPostAPI as u } from "@cuemath/rest-api";
|
2
|
+
import { BASE_URL_V1 as e } from "../../../constants/api.js";
|
3
|
+
const { useGet: p } = o({
|
4
|
+
getURL: (n, { app_id: t, journey_status: s, user_id: r }) => `${e}/task/user-journey/?app_id=${t}&journey_status=${s}&user_id=${r}`
|
5
|
+
}), { usePost: y } = u({
|
6
|
+
getURL: () => `${e}/task/user-journey/`
|
7
|
+
});
|
8
|
+
export {
|
9
|
+
p as useGetUserJourney,
|
10
|
+
y as usePostUserJourney
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=user-journey-api.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user-journey-api.js","sources":["../../../../src/features/journey/user-journey-api/user-journey-api.ts"],"sourcesContent":["import type {\n TGetJourneyProgressPayloadModel,\n TGetJourneyProgressResponseModel,\n TPostJourneyProgressPayloadModel,\n TPostJourneyProgressResponseModel,\n} from './user-journey-api-types';\n\nimport { createGetAPI, createPostAPI } from '@cuemath/rest-api';\n\nimport { BASE_URL_V1 } from '../../../constants/api';\n\nconst { useGet: useGetUserJourney } = createGetAPI<\n TGetJourneyProgressResponseModel,\n TGetJourneyProgressPayloadModel\n>({\n getURL: (_, { app_id, journey_status, user_id }) =>\n `${BASE_URL_V1}/task/user-journey/?app_id=${app_id}&journey_status=${journey_status}&user_id=${user_id}`,\n});\n\nconst { usePost: usePostUserJourney } = createPostAPI<\n TPostJourneyProgressResponseModel,\n TPostJourneyProgressPayloadModel\n>({\n getURL: () => `${BASE_URL_V1}/task/user-journey/`,\n});\n\nexport { useGetUserJourney, usePostUserJourney };\n"],"names":["useGetUserJourney","createGetAPI","_","app_id","journey_status","user_id","BASE_URL_V1","usePostUserJourney","createPostAPI"],"mappings":";;AAWA,MAAM,EAAE,QAAQA,EAAkB,IAAIC,EAGpC;AAAA,EACA,QAAQ,CAACC,GAAG,EAAE,QAAAC,GAAQ,gBAAAC,GAAgB,SAAAC,EAAA,MACpC,GAAGC,CAAW,8BAA8BH,CAAM,mBAAmBC,CAAc,YAAYC,CAAO;AAC1G,CAAC,GAEK,EAAE,SAASE,EAAmB,IAAIC,EAGtC;AAAA,EACA,QAAQ,MAAM,GAAGF,CAAW;AAC9B,CAAC;"}
|
package/dist/index.d.ts
CHANGED
@@ -842,7 +842,6 @@ export declare interface ICircleHomeDetails {
|
|
842
842
|
tournamentRank: number;
|
843
843
|
projects: IProjects;
|
844
844
|
timestamps: ITodaysContentTimeStamps;
|
845
|
-
coachmarkProgress: ICoachmarkProgress;
|
846
845
|
}
|
847
846
|
|
848
847
|
declare interface ICircularSteps {
|
@@ -906,15 +905,6 @@ declare interface ICoachMarkCompletion {
|
|
906
905
|
CIRCLE_TABLES_INTRO_JOURNEY: boolean;
|
907
906
|
}
|
908
907
|
|
909
|
-
export declare interface ICoachmarkProgress {
|
910
|
-
CIRCLE_ACTIVITIES_INTRO_JOURNEY: boolean;
|
911
|
-
CIRCLE_LEADERBOARD_INTRO_JOURNEY: boolean;
|
912
|
-
CIRCLE_POINTS_REWARD_JOURNEY: boolean;
|
913
|
-
CIRCLE_STREAK_UPDATE_JOURNEY: boolean;
|
914
|
-
CIRCLE_TUTORIAL_JOURNEY: boolean;
|
915
|
-
CIRCLE_TABLES_INTRO_JOURNEY: boolean;
|
916
|
-
}
|
917
|
-
|
918
908
|
/**
|
919
909
|
* Represents a coachmark, an interactive guidance element positioned over an existing element.
|
920
910
|
*/
|
@@ -1121,7 +1111,6 @@ declare interface IGameLauncherProps {
|
|
1121
1111
|
defaultIndex?: number;
|
1122
1112
|
journeyId?: TJourneyId;
|
1123
1113
|
isTutorialOnboardingDone?: boolean;
|
1124
|
-
onJourneyComplete: (journeyId: TJourneyId) => void;
|
1125
1114
|
}
|
1126
1115
|
|
1127
1116
|
declare interface IGetArrowTooltipConfig {
|
@@ -1295,6 +1284,7 @@ declare interface IIsOkayTypeQuestion {
|
|
1295
1284
|
* Context interface for managing onboarding journeys using coachmarks.
|
1296
1285
|
*/
|
1297
1286
|
export declare interface IJourneyContext {
|
1287
|
+
isJourneyActive: boolean;
|
1298
1288
|
/** List of all active coachmarks within the journey. */
|
1299
1289
|
coachmarks: ICoachmarkProps[];
|
1300
1290
|
/**
|
@@ -1327,6 +1317,23 @@ export declare interface IJourneyContext {
|
|
1327
1317
|
* @param delayInMs - Optional delay (in milliseconds) before rendering the current coachmark.
|
1328
1318
|
*/
|
1329
1319
|
nextCoachmark: (id: TJourneyId, keepPrevActive?: boolean, delayInMs?: number) => void;
|
1320
|
+
/**
|
1321
|
+
* Must be called to end journey and update the journey status on server.
|
1322
|
+
* @param id - The journey id.
|
1323
|
+
*/
|
1324
|
+
endJourney: (id: TJourneyId) => void;
|
1325
|
+
/**
|
1326
|
+
* Array of IDs representing the journeys that the user has completed.
|
1327
|
+
* This data is set only the component is mounted.
|
1328
|
+
* And thereafter it is updated when the user completes a journey, through the `endJourney` method.
|
1329
|
+
*/
|
1330
|
+
userCompletedJourneyIds: TJourneyId[] | null;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
declare interface IJourneyProviderProps {
|
1334
|
+
children: React.ReactNode;
|
1335
|
+
appId: string;
|
1336
|
+
userId: string;
|
1330
1337
|
}
|
1331
1338
|
|
1332
1339
|
export declare interface ILayout {
|
@@ -2113,7 +2120,6 @@ export declare interface IPlayer {
|
|
2113
2120
|
avatar?: IAvatarLayer[] | null;
|
2114
2121
|
playerType: TUserTypes;
|
2115
2122
|
countryCode: string;
|
2116
|
-
isAdmin?: boolean;
|
2117
2123
|
}
|
2118
2124
|
|
2119
2125
|
export declare interface IPlayerStats {
|
@@ -2152,11 +2158,6 @@ export declare interface IPointsLeaderboardDetails extends IBaseLeaderboardDetai
|
|
2152
2158
|
leaderboardPlayers: ILeaderboardPlayerWithPoints[];
|
2153
2159
|
}
|
2154
2160
|
|
2155
|
-
declare interface IPostCircleOnboardingPayload {
|
2156
|
-
intelenrollment_id: string;
|
2157
|
-
completed_coachmarks: string[];
|
2158
|
-
}
|
2159
|
-
|
2160
2161
|
export declare interface IPostGameStat {
|
2161
2162
|
type: EPostGameStat;
|
2162
2163
|
value: number;
|
@@ -3435,9 +3436,7 @@ export declare enum JOURNEY_ID_STUDENT {
|
|
3435
3436
|
CIRCLE_STREAK_REDUCTION_JOURNEY = "CIRCLE_STREAK_REDUCTION_JOURNEY"
|
3436
3437
|
}
|
3437
3438
|
|
3438
|
-
export declare const JourneyProvider: FC<
|
3439
|
-
children: ReactNode;
|
3440
|
-
}>;
|
3439
|
+
export declare const JourneyProvider: FC<IJourneyProviderProps>;
|
3441
3440
|
|
3442
3441
|
export declare const Leaderboard: ({ leaderboardData, type, userId, onClose, isLoading, streakInfo, }: ILeaderboardProps) => JSX_2.Element;
|
3443
3442
|
|
@@ -5024,6 +5023,14 @@ export declare const useGetCircleHomeDetailsDal: (userId: string, grade: string,
|
|
5024
5023
|
invalidateCircleHomeDetails: () => void;
|
5025
5024
|
};
|
5026
5025
|
|
5026
|
+
/**
|
5027
|
+
* Unless the useGetUserJourney API is resolved, this hook will return an empty array.
|
5028
|
+
* This is because the userCompletedJourneyIds are set from the API response.
|
5029
|
+
* And Unless the API is resolved, we cannot determine the eligible journeys.
|
5030
|
+
* So, we return an empty array.
|
5031
|
+
*/
|
5032
|
+
export declare const useGetEligibleJourneysViaRoute: (routeJourneyIds: TJourneyId[]) => JOURNEY_ID_STUDENT[];
|
5033
|
+
|
5027
5034
|
declare const useGetLeaderboard: (initialId?: string, initialQuery?: IGetLeaderboardPayloadModel | undefined) => {
|
5028
5035
|
get: (id: string, query: IGetLeaderboardPayloadModel, meta: void) => Promise<void>;
|
5029
5036
|
resource: ResourceModel<IGetLeaderboardResponseModel> | undefined;
|
@@ -5090,19 +5097,6 @@ export declare const useJourney: () => IJourneyContext;
|
|
5090
5097
|
|
5091
5098
|
export declare const usePointerSync: ({ userType, targetUserId, }: IusePointerSyncProps) => IusePointerSyncMethods;
|
5092
5099
|
|
5093
|
-
declare const usePostUpdateCircleCoachmark: (opts?: {
|
5094
|
-
onComplete?: ((errorMessage: string | null, data?: IGetCircleHomeResponseModel | undefined, permissions?: void | undefined) => void) | undefined;
|
5095
|
-
triggerOnComplete?: boolean | undefined;
|
5096
|
-
} | undefined) => {
|
5097
|
-
post: (body: IPostCircleOnboardingPayload, meta: void) => Promise<void>;
|
5098
|
-
isProcessing: boolean;
|
5099
|
-
onComplete: (() => void) | undefined;
|
5100
|
-
};
|
5101
|
-
|
5102
|
-
export declare const usePostUpdateCircleJourneyDal: () => Omit<ReturnType<typeof usePostUpdateCircleCoachmark>, "data" | "post"> & {
|
5103
|
-
postCircleJourneyCompletion: (userId: string, journeyCompletionIds: TJourneyId[]) => void;
|
5104
|
-
};
|
5105
|
-
|
5106
5100
|
export declare const User2Icon: React.FC<React.SVGProps<SVGSVGElement>>;
|
5107
5101
|
|
5108
5102
|
export declare const UserIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|