@cuemath/leap 2.8.53-link.0 → 2.8.53-link.1

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.
@@ -1,174 +1,175 @@
1
- import { useCallback as l, useEffect as W } from "react";
2
- import { COURSE_STREAMS as V } from "../../milestone/constants.js";
3
- import { useMilestoneBulkPost as j } from "../../milestone/create/api/milestone-bulk.js";
4
- import { usePostStudentPreferences as q } from "../api/course-stream.js";
5
- import { usePatchStudentInformation as J } from "../api/student-information.js";
6
- import { usePatchTrialHome as Q } from "../api/trial-home.js";
7
- import { useTrialSessionContext as X } from "../context/use-trial-session-context.js";
8
- import { getFormattedPreferences as Y, getFormattedStudentPersonalizedPreference as $ } from "../helper.js";
9
- import { DEFAULT_BUTTON_STATE as _, TrialPageId as e } from "../trial-session-constants.js";
1
+ import { useCallback as d, useEffect as j } from "react";
2
+ import { COURSE_STREAMS as q } from "../../milestone/constants.js";
3
+ import { useMilestoneBulkPost as J } from "../../milestone/create/api/milestone-bulk.js";
4
+ import { usePostStudentPreferences as Q } from "../api/course-stream.js";
5
+ import { usePatchStudentInformation as X } from "../api/student-information.js";
6
+ import { usePatchTrialHome as Y } from "../api/trial-home.js";
7
+ import { useTrialSessionContext as $ } from "../context/use-trial-session-context.js";
8
+ import { getFormattedPreferences as ee, getFormattedStudentPersonalizedPreference as te } from "../helper.js";
9
+ import { DEFAULT_BUTTON_STATE as S, TrialPageId as e } from "../trial-session-constants.js";
10
10
  import z from "../../../node_modules/uuid/dist/esm-browser/v4.js";
11
- const de = () => {
11
+ const ue = () => {
12
12
  const {
13
13
  updateSlideConfig: s,
14
14
  slideConfig: B,
15
15
  formData: H,
16
- updateButtonState: a,
17
- teacherId: d,
18
- studentId: n,
16
+ updateButtonState: n,
17
+ teacherId: l,
18
+ studentId: a,
19
19
  milestoneConfig: P,
20
20
  onTrialInformationUpdate: h,
21
21
  trialHomeData: x,
22
22
  worksheetNavigationPanel: I
23
- } = X(), { nextPage: w, id: r } = B || {}, { demo_info: Z } = x, { stream: N } = Z, { pageId: i } = w || {}, {
24
- name: u,
23
+ } = $(), { nextPage: w, id: r } = B || {}, { demo_info: Z } = x, { stream: N, region_data: K } = Z, { opportunity_country: C = "US" } = K || {}, { pageId: i } = w || {}, {
24
+ name: f,
25
25
  grade: p,
26
- goals: C,
27
- curriculum: E,
28
- studentTimezone: g,
29
- preferences: T = [],
30
- personalizedLevel: A = [],
31
- personalizedFocus: R = [],
32
- personalizedBehaviors: O = []
33
- } = H || {}, c = l(() => {
34
- a("both", {
26
+ goals: g,
27
+ curriculum: _,
28
+ studentTimezone: T,
29
+ preferences: A = [],
30
+ personalizedLevel: R = [],
31
+ personalizedFocus: O = [],
32
+ personalizedBehaviors: b = []
33
+ } = H || {}, c = d(() => {
34
+ n("both", {
35
35
  left: { isDisabled: !0, isLoading: !1 },
36
36
  right: { isDisabled: !0, isLoading: !0 }
37
37
  });
38
- }, [a]), S = (o) => {
38
+ }, [n]), E = (o) => {
39
39
  if (!o) {
40
40
  const t = {};
41
41
  (i === e.CIRCLE_GAME || i === e.CIRCLE_PUZZLE || i === e.CIRCLE_SKILL) && (t.matchmakingId = z(), t.showCircleGameScreen = !0), s({ id: i, ...t });
42
42
  }
43
- a("both", _), (r === e.STUDENT_INFORMATION || r === e.SCHOOL_GOALS) && (h == null || h());
44
- }, { patch: b } = Q({ onComplete: S }), { patch: v } = J({
45
- onComplete: S
46
- }), { post: k } = j({
47
- onComplete: S
48
- }), { post: D } = q({
49
- onComplete: S
50
- }), G = l(() => {
51
- const [o, t] = (u == null ? void 0 : u.split(" ")) || [], m = {
43
+ n("both", S), (r === e.STUDENT_INFORMATION || r === e.SCHOOL_GOALS) && (h == null || h());
44
+ }, { patch: v } = Y({ onComplete: E }), { patch: k } = X({
45
+ onComplete: E
46
+ }), { post: D } = J({
47
+ onComplete: E
48
+ }), { post: G } = Q({
49
+ onComplete: E
50
+ }), M = d(() => {
51
+ const [o, t] = (f == null ? void 0 : f.split(" ")) || [], m = {
52
52
  first_name: o,
53
53
  last_name: t,
54
54
  grade: p,
55
- board: E,
55
+ board: _,
56
56
  demo_type: "TRIAL_V3",
57
- teacher_id: d
57
+ teacher_id: l
58
58
  };
59
- c(), v(n, m);
60
- }, [E, p, u, v, n, d, c]), M = l(() => {
61
- const o = Y(T, g);
59
+ c(), k(a, m);
60
+ }, [_, p, f, k, a, l, c]), U = d(() => {
61
+ const o = ee(A, T);
62
62
  if (o.length > 0) {
63
63
  const t = {
64
64
  trial_details: {
65
65
  selected_regular_slots: o
66
66
  }
67
67
  };
68
- c(), b("trial-v3-patch", {
68
+ c(), v("trial-v3-patch", {
69
69
  action: "UPDATE_DEMO",
70
70
  action_data: t,
71
- teacher_id: d,
72
- student_id: n
71
+ teacher_id: l,
72
+ student_id: a
73
73
  });
74
74
  } else
75
- s({ id: i }), a("both", _);
75
+ s({ id: i }), n("both", S);
76
76
  }, [
77
+ A,
77
78
  T,
78
- g,
79
79
  c,
80
- b,
81
- d,
82
- n,
80
+ v,
81
+ l,
82
+ a,
83
83
  s,
84
84
  i,
85
- a
86
- ]), U = l(() => {
85
+ n
86
+ ]), y = d(() => {
87
87
  const o = {
88
88
  course_stream: N,
89
89
  grade: p,
90
- teacher_id: d,
91
- board: E,
92
- goals: C
90
+ teacher_id: l,
91
+ board: _,
92
+ goals: g
93
93
  };
94
- c(), k(o, {
95
- studentId: n
94
+ c(), D(o, {
95
+ studentId: a
96
96
  });
97
97
  }, [
98
- E,
98
+ _,
99
99
  c,
100
- C,
100
+ g,
101
101
  p,
102
- k,
102
+ D,
103
103
  N,
104
- n,
105
- d
106
- ]), F = l(() => {
107
- const t = { preferences: $(P, [
108
- ...A,
104
+ a,
105
+ l
106
+ ]), F = d(() => {
107
+ const t = { preferences: te(P, [
109
108
  ...R,
110
- ...O
111
- ]) }, m = { stream: V.MATH, studentId: n };
112
- c(), D(t, m);
109
+ ...O,
110
+ ...b
111
+ ]) }, m = { stream: q.MATH, studentId: a, country_code: C };
112
+ c(), G(t, m);
113
113
  }, [
114
+ C,
114
115
  c,
115
116
  P,
117
+ b,
116
118
  O,
117
119
  R,
118
- A,
119
- D,
120
- n
121
- ]), L = l(
120
+ G,
121
+ a
122
+ ]), L = d(
122
123
  (o, t) => {
123
124
  if (!s) return;
124
- const m = r === e.STUDENT_PROFILE, K = r === e.LEARNING_PLAN, f = {};
125
- if ((t === e.CIRCLE_GAME || t === e.CIRCLE_PUZZLE || t === e.CIRCLE_SKILL) && (f.matchmakingId = z(), f.showCircleGameScreen = !0), o === "prev" && (s({
125
+ const m = r === e.STUDENT_PROFILE, V = r === e.LEARNING_PLAN, u = {};
126
+ if ((t === e.CIRCLE_GAME || t === e.CIRCLE_PUZZLE || t === e.CIRCLE_SKILL) && (u.matchmakingId = z(), u.showCircleGameScreen = !0), o === "prev" && (s({
126
127
  id: t,
127
128
  ...m && { studentProfile: void 0 },
128
- ...K && {
129
+ ...V && {
129
130
  chapterId: void 0
130
131
  },
131
- ...f
132
- }), a("both", _)), o === "next")
132
+ ...u
133
+ }), n("both", S)), o === "next")
133
134
  switch (r) {
134
135
  case e.STUDENT_INFORMATION:
135
136
  case e.SCHOOL_GOALS:
136
- G();
137
+ M();
137
138
  break;
138
139
  case e.LEARNING_WORKSHEET:
139
- U();
140
+ y();
140
141
  break;
141
142
  case e.CLASS_PREFERENCE:
142
- M();
143
+ U();
143
144
  break;
144
145
  case e.LEARNING_LEVEL:
145
146
  case e.STUDENT_PERSONALIZATION:
146
147
  F();
147
148
  break;
148
149
  case e.LEARNING_PLAN:
149
- s({ id: t, chapterId: void 0, ...f });
150
+ s({ id: t, chapterId: void 0, ...u });
150
151
  break;
151
152
  default:
152
- s({ id: t, ...f }), a("both", _);
153
+ s({ id: t, ...u }), n("both", S);
153
154
  }
154
155
  },
155
156
  [
156
157
  s,
157
158
  r,
158
- a,
159
- G,
160
- U,
159
+ n,
161
160
  M,
161
+ y,
162
+ U,
162
163
  F
163
164
  ]
164
- ), y = l(() => {
165
+ ), W = d(() => {
165
166
  !I && r === e.LEARNING_WORKSHEET && L("next", i);
166
167
  }, [r, L, i, I]);
167
- return W(() => {
168
- y();
168
+ return j(() => {
169
+ W();
169
170
  }, [I]), { handleNavigation: L };
170
171
  };
171
172
  export {
172
- de as useTrialSessionNavigation
173
+ ue as useTrialSessionNavigation
173
174
  };
174
175
  //# sourceMappingURL=use-trial-session-navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-trial-session-navigation.js","sources":["../../../../src/features/trial-session/hooks/use-trial-session-navigation.ts"],"sourcesContent":["import type { ITrialSessionFormFields } from '../trial-session-types';\n\nimport { useCallback, useEffect } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { COURSE_STREAMS } from '../../milestone/constants';\nimport { useMilestoneBulkPost } from '../../milestone/create/api/milestone-bulk';\nimport { usePostStudentPreferences } from '../api/course-stream';\nimport { usePatchStudentInformation } from '../api/student-information';\nimport { usePatchTrialHome } from '../api/trial-home';\nimport { useTrialSessionContext } from '../context/use-trial-session-context';\nimport { getFormattedPreferences, getFormattedStudentPersonalizedPreference } from '../helper';\nimport { DEFAULT_BUTTON_STATE, TrialPageId } from '../trial-session-constants';\n\nconst useTrialSessionNavigation = () => {\n const {\n updateSlideConfig,\n slideConfig,\n formData,\n updateButtonState,\n teacherId,\n studentId,\n milestoneConfig,\n onTrialInformationUpdate,\n trialHomeData,\n worksheetNavigationPanel,\n } = useTrialSessionContext();\n const { nextPage, id: currentPageId } = slideConfig || {};\n const { demo_info: demoInfo } = trialHomeData;\n const { stream } = demoInfo;\n const { pageId: nextPageId } = nextPage || {};\n const {\n name,\n grade,\n goals,\n curriculum,\n studentTimezone,\n preferences = [],\n personalizedLevel = [],\n personalizedFocus = [],\n personalizedBehaviors = [],\n } = formData || {};\n\n const disableNavButtons = useCallback(() => {\n updateButtonState('both', {\n left: { isDisabled: true, isLoading: false },\n right: { isDisabled: true, isLoading: true },\n });\n }, [updateButtonState]);\n\n const onAcknowledge = (errorMessage: string | null) => {\n if (!errorMessage) {\n const overrides: Partial<ITrialSessionFormFields> = {};\n\n if (\n nextPageId === TrialPageId.CIRCLE_GAME ||\n nextPageId === TrialPageId.CIRCLE_PUZZLE ||\n nextPageId === TrialPageId.CIRCLE_SKILL\n ) {\n overrides.matchmakingId = uuidv4();\n overrides.showCircleGameScreen = true;\n }\n\n updateSlideConfig({ id: nextPageId, ...overrides });\n }\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n\n if (\n currentPageId === TrialPageId.STUDENT_INFORMATION ||\n currentPageId === TrialPageId.SCHOOL_GOALS\n ) {\n //TODO: remove TrialPageId.STUDENT_INFORMATION\n onTrialInformationUpdate?.();\n }\n };\n\n // API specifications\n const { patch: patchTrialSession } = usePatchTrialHome({ onComplete: onAcknowledge });\n const { patch: patchStudentInformation } = usePatchStudentInformation({\n onComplete: onAcknowledge,\n });\n const { post: postMilestoneBulk } = useMilestoneBulkPost({\n onComplete: onAcknowledge,\n });\n const { post: postStudentPreferences } = usePostStudentPreferences({\n onComplete: onAcknowledge,\n });\n\n // Function to call API and updates states\n const handleStudentInformation = useCallback(() => {\n const [firstName, lastName] = name?.split(' ') || [];\n const payload = {\n first_name: firstName,\n last_name: lastName,\n grade,\n board: curriculum,\n demo_type: 'TRIAL_V3',\n teacher_id: teacherId,\n };\n\n disableNavButtons();\n patchStudentInformation(studentId, payload);\n }, [curriculum, grade, name, patchStudentInformation, studentId, teacherId, disableNavButtons]);\n\n const handleClassPreferences = useCallback(() => {\n const selectedRegularSlots = getFormattedPreferences(preferences, studentTimezone);\n\n if (selectedRegularSlots.length > 0) {\n const actionData = {\n trial_details: {\n selected_regular_slots: selectedRegularSlots,\n },\n };\n\n disableNavButtons();\n patchTrialSession('trial-v3-patch', {\n action: 'UPDATE_DEMO',\n action_data: actionData,\n teacher_id: teacherId,\n student_id: studentId,\n });\n } else {\n updateSlideConfig({ id: nextPageId });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n }, [\n preferences,\n studentTimezone,\n disableNavButtons,\n patchTrialSession,\n teacherId,\n studentId,\n updateSlideConfig,\n nextPageId,\n updateButtonState,\n ]);\n\n const handleMileStoneBulkPost = useCallback(() => {\n const payload = {\n course_stream: stream,\n grade,\n teacher_id: teacherId,\n board: curriculum,\n goals,\n };\n\n disableNavButtons();\n postMilestoneBulk(payload, {\n studentId,\n });\n }, [\n curriculum,\n disableNavButtons,\n goals,\n grade,\n postMilestoneBulk,\n stream,\n studentId,\n teacherId,\n ]);\n\n const handleStudentPreferencesPatch = useCallback(() => {\n const personalizedPreferences = getFormattedStudentPersonalizedPreference(milestoneConfig, [\n ...personalizedLevel,\n ...personalizedFocus,\n ...personalizedBehaviors,\n ]);\n\n const payload = { preferences: personalizedPreferences };\n const meta = { stream: COURSE_STREAMS.MATH, studentId };\n\n disableNavButtons();\n postStudentPreferences(payload, meta);\n }, [\n disableNavButtons,\n milestoneConfig,\n personalizedBehaviors,\n personalizedFocus,\n personalizedLevel,\n postStudentPreferences,\n studentId,\n ]);\n\n // Navigation logic\n const handleNavigation = useCallback(\n (dir: string, id?: string) => {\n if (!updateSlideConfig) return;\n\n const isStudentProfilePage = currentPageId === TrialPageId.STUDENT_PROFILE;\n const isLearningPlanSlide = currentPageId === TrialPageId.LEARNING_PLAN;\n const overrides: Partial<ITrialSessionFormFields> = {};\n\n if (\n id === TrialPageId.CIRCLE_GAME ||\n id === TrialPageId.CIRCLE_PUZZLE ||\n id === TrialPageId.CIRCLE_SKILL\n ) {\n overrides.matchmakingId = uuidv4();\n overrides.showCircleGameScreen = true;\n }\n\n if (dir === 'prev') {\n updateSlideConfig({\n id,\n ...(isStudentProfilePage && { studentProfile: undefined }),\n ...(isLearningPlanSlide && {\n chapterId: undefined,\n }),\n ...overrides,\n });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n\n if (dir === 'next') {\n switch (currentPageId) {\n //TODO: remove STUDENT_INFORMATION\n case TrialPageId.STUDENT_INFORMATION:\n case TrialPageId.SCHOOL_GOALS:\n handleStudentInformation();\n break;\n case TrialPageId.LEARNING_WORKSHEET:\n handleMileStoneBulkPost();\n break;\n case TrialPageId.CLASS_PREFERENCE:\n handleClassPreferences();\n break;\n case TrialPageId.LEARNING_LEVEL:\n case TrialPageId.STUDENT_PERSONALIZATION:\n handleStudentPreferencesPatch();\n break;\n case TrialPageId.LEARNING_PLAN:\n updateSlideConfig({ id, chapterId: undefined, ...overrides });\n break;\n default: {\n updateSlideConfig({ id, ...overrides });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n }\n }\n },\n [\n updateSlideConfig,\n currentPageId,\n updateButtonState,\n handleStudentInformation,\n handleMileStoneBulkPost,\n handleClassPreferences,\n handleStudentPreferencesPatch,\n ],\n );\n\n const sessionWorksheetNavigation = useCallback(() => {\n if (!worksheetNavigationPanel && currentPageId === TrialPageId.LEARNING_WORKSHEET) {\n handleNavigation('next', nextPageId);\n }\n }, [currentPageId, handleNavigation, nextPageId, worksheetNavigationPanel]);\n\n useEffect(() => {\n sessionWorksheetNavigation();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [worksheetNavigationPanel]);\n\n return { handleNavigation };\n};\n\nexport { useTrialSessionNavigation };\n"],"names":["useTrialSessionNavigation","updateSlideConfig","slideConfig","formData","updateButtonState","teacherId","studentId","milestoneConfig","onTrialInformationUpdate","trialHomeData","worksheetNavigationPanel","useTrialSessionContext","nextPage","currentPageId","demoInfo","stream","nextPageId","name","grade","goals","curriculum","studentTimezone","preferences","personalizedLevel","personalizedFocus","personalizedBehaviors","disableNavButtons","useCallback","onAcknowledge","errorMessage","overrides","TrialPageId","uuidv4","DEFAULT_BUTTON_STATE","patchTrialSession","usePatchTrialHome","patchStudentInformation","usePatchStudentInformation","postMilestoneBulk","useMilestoneBulkPost","postStudentPreferences","usePostStudentPreferences","handleStudentInformation","firstName","lastName","payload","handleClassPreferences","selectedRegularSlots","getFormattedPreferences","actionData","handleMileStoneBulkPost","handleStudentPreferencesPatch","getFormattedStudentPersonalizedPreference","meta","COURSE_STREAMS","handleNavigation","dir","id","isStudentProfilePage","isLearningPlanSlide","sessionWorksheetNavigation","useEffect"],"mappings":";;;;;;;;;;AAcA,MAAMA,KAA4B,MAAM;AAChC,QAAA;AAAA,IACJ,mBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,eAAAC;AAAA,IACA,0BAAAC;AAAA,MACEC,EAAuB,GACrB,EAAE,UAAAC,GAAU,IAAIC,EAAc,IAAIX,KAAe,CAAA,GACjD,EAAE,WAAWY,EAAa,IAAAL,GAC1B,EAAE,QAAAM,EAAW,IAAAD,GACb,EAAE,QAAQE,MAAeJ,KAAY,CAAA,GACrC;AAAA,IACJ,MAAAK;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC,IAAc,CAAC;AAAA,IACf,mBAAAC,IAAoB,CAAC;AAAA,IACrB,mBAAAC,IAAoB,CAAC;AAAA,IACrB,uBAAAC,IAAwB,CAAC;AAAA,EAAA,IACvBtB,KAAY,CAAA,GAEVuB,IAAoBC,EAAY,MAAM;AAC1C,IAAAvB,EAAkB,QAAQ;AAAA,MACxB,MAAM,EAAE,YAAY,IAAM,WAAW,GAAM;AAAA,MAC3C,OAAO,EAAE,YAAY,IAAM,WAAW,GAAK;AAAA,IAAA,CAC5C;AAAA,EAAA,GACA,CAACA,CAAiB,CAAC,GAEhBwB,IAAgB,CAACC,MAAgC;AACrD,QAAI,CAACA,GAAc;AACjB,YAAMC,IAA8C,CAAA;AAGlD,OAAAd,MAAee,EAAY,eAC3Bf,MAAee,EAAY,iBAC3Bf,MAAee,EAAY,kBAE3BD,EAAU,gBAAgBE,KAC1BF,EAAU,uBAAuB,KAGnC7B,EAAkB,EAAE,IAAIe,GAAY,GAAGc,EA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AAAA,QACA,GAAIC,KAAwB,EAAE,gBAAgB,OAAU;AAAA,QACxD,GAAIC,KAAuB;AAAA,UACzB,WAAW;AAAA,QACb;AAAA,QACA,GAAG7B;AAAA,MAAA,CACJ,GACD1B,EAAkB,QAAQ6B,CAAoB,IAG5CuB,MAAQ;AACV,gBAAQ3C,GAAe;AAAA,UAErB,KAAKkB,EAAY;AAAA,UACjB,KAAKA,EAAY;AACU,YAAAW;AACzB;AAAA,UACF,KAAKX,EAAY;AACS,YAAAmB;AACxB;AAAA,UACF,KAAKnB,EAAY;AACQ,YAAAe;AACvB;AAAA,UACF,KAAKf,EAAY;AAAA,UACjB,KAAKA,EAAY;AACe,YAAAoB;AAC9B;AAAA,UACF,KAAKpB,EAAY;AACf,YAAA9B,EAAkB,EAAE,IAAAwD,GAAI,WAAW,QAAW,GAAG3B,GAAW;AAC5D;AAAA,UACF;AACE,YAAA7B,EAAkB,EAAE,IAAAwD,GAAI,GAAG3B,EAAW,CAAA,GACtC1B,EAAkB,QAAQ6B,CAAoB;AAAA,QAElD;AAAA,IAEJ;AAAA,IACA;AAAA,MACEhC;AAAA,MACAY;AAAA,MACAT;AAAA,MACAsC;AAAA,MACAQ;AAAA,MACAJ;AAAA,MACAK;AAAA,IACF;AAAA,EAAA,GAGIS,IAA6BjC,EAAY,MAAM;AACnD,IAAI,CAACjB,KAA4BG,MAAkBkB,EAAY,sBAC7DwB,EAAiB,QAAQvC,CAAU;AAAA,KAEpC,CAACH,GAAe0C,GAAkBvC,GAAYN,CAAwB,CAAC;AAE1E,SAAAmD,EAAU,MAAM;AACa,IAAAD;EAAA,GAE1B,CAAClD,CAAwB,CAAC,GAEtB,EAAE,kBAAA6C,EAAiB;AAC5B;"}
1
+ {"version":3,"file":"use-trial-session-navigation.js","sources":["../../../../src/features/trial-session/hooks/use-trial-session-navigation.ts"],"sourcesContent":["import type { ITrialSessionFormFields } from '../trial-session-types';\n\nimport { useCallback, useEffect } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { COURSE_STREAMS } from '../../milestone/constants';\nimport { useMilestoneBulkPost } from '../../milestone/create/api/milestone-bulk';\nimport { usePostStudentPreferences } from '../api/course-stream';\nimport { usePatchStudentInformation } from '../api/student-information';\nimport { usePatchTrialHome } from '../api/trial-home';\nimport { useTrialSessionContext } from '../context/use-trial-session-context';\nimport { getFormattedPreferences, getFormattedStudentPersonalizedPreference } from '../helper';\nimport { DEFAULT_BUTTON_STATE, TrialPageId } from '../trial-session-constants';\n\nconst useTrialSessionNavigation = () => {\n const {\n updateSlideConfig,\n slideConfig,\n formData,\n updateButtonState,\n teacherId,\n studentId,\n milestoneConfig,\n onTrialInformationUpdate,\n trialHomeData,\n worksheetNavigationPanel,\n } = useTrialSessionContext();\n const { nextPage, id: currentPageId } = slideConfig || {};\n const { demo_info: demoInfo } = trialHomeData;\n const { stream, region_data: regionData } = demoInfo;\n const { opportunity_country: countryCode = 'US' } = regionData || {};\n const { pageId: nextPageId } = nextPage || {};\n const {\n name,\n grade,\n goals,\n curriculum,\n studentTimezone,\n preferences = [],\n personalizedLevel = [],\n personalizedFocus = [],\n personalizedBehaviors = [],\n } = formData || {};\n\n const disableNavButtons = useCallback(() => {\n updateButtonState('both', {\n left: { isDisabled: true, isLoading: false },\n right: { isDisabled: true, isLoading: true },\n });\n }, [updateButtonState]);\n\n const onAcknowledge = (errorMessage: string | null) => {\n if (!errorMessage) {\n const overrides: Partial<ITrialSessionFormFields> = {};\n\n if (\n nextPageId === TrialPageId.CIRCLE_GAME ||\n nextPageId === TrialPageId.CIRCLE_PUZZLE ||\n nextPageId === TrialPageId.CIRCLE_SKILL\n ) {\n overrides.matchmakingId = uuidv4();\n overrides.showCircleGameScreen = true;\n }\n\n updateSlideConfig({ id: nextPageId, ...overrides });\n }\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n\n if (\n currentPageId === TrialPageId.STUDENT_INFORMATION ||\n currentPageId === TrialPageId.SCHOOL_GOALS\n ) {\n //TODO: remove TrialPageId.STUDENT_INFORMATION\n onTrialInformationUpdate?.();\n }\n };\n\n // API specifications\n const { patch: patchTrialSession } = usePatchTrialHome({ onComplete: onAcknowledge });\n const { patch: patchStudentInformation } = usePatchStudentInformation({\n onComplete: onAcknowledge,\n });\n const { post: postMilestoneBulk } = useMilestoneBulkPost({\n onComplete: onAcknowledge,\n });\n const { post: postStudentPreferences } = usePostStudentPreferences({\n onComplete: onAcknowledge,\n });\n\n // Function to call API and updates states\n const handleStudentInformation = useCallback(() => {\n const [firstName, lastName] = name?.split(' ') || [];\n const payload = {\n first_name: firstName,\n last_name: lastName,\n grade,\n board: curriculum,\n demo_type: 'TRIAL_V3',\n teacher_id: teacherId,\n };\n\n disableNavButtons();\n patchStudentInformation(studentId, payload);\n }, [curriculum, grade, name, patchStudentInformation, studentId, teacherId, disableNavButtons]);\n\n const handleClassPreferences = useCallback(() => {\n const selectedRegularSlots = getFormattedPreferences(preferences, studentTimezone);\n\n if (selectedRegularSlots.length > 0) {\n const actionData = {\n trial_details: {\n selected_regular_slots: selectedRegularSlots,\n },\n };\n\n disableNavButtons();\n patchTrialSession('trial-v3-patch', {\n action: 'UPDATE_DEMO',\n action_data: actionData,\n teacher_id: teacherId,\n student_id: studentId,\n });\n } else {\n updateSlideConfig({ id: nextPageId });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n }, [\n preferences,\n studentTimezone,\n disableNavButtons,\n patchTrialSession,\n teacherId,\n studentId,\n updateSlideConfig,\n nextPageId,\n updateButtonState,\n ]);\n\n const handleMileStoneBulkPost = useCallback(() => {\n const payload = {\n course_stream: stream,\n grade,\n teacher_id: teacherId,\n board: curriculum,\n goals,\n };\n\n disableNavButtons();\n postMilestoneBulk(payload, {\n studentId,\n });\n }, [\n curriculum,\n disableNavButtons,\n goals,\n grade,\n postMilestoneBulk,\n stream,\n studentId,\n teacherId,\n ]);\n\n const handleStudentPreferencesPatch = useCallback(() => {\n const personalizedPreferences = getFormattedStudentPersonalizedPreference(milestoneConfig, [\n ...personalizedLevel,\n ...personalizedFocus,\n ...personalizedBehaviors,\n ]);\n\n const payload = { preferences: personalizedPreferences };\n const meta = { stream: COURSE_STREAMS.MATH, studentId, country_code: countryCode };\n\n disableNavButtons();\n postStudentPreferences(payload, meta);\n }, [\n countryCode,\n disableNavButtons,\n milestoneConfig,\n personalizedBehaviors,\n personalizedFocus,\n personalizedLevel,\n postStudentPreferences,\n studentId,\n ]);\n\n // Navigation logic\n const handleNavigation = useCallback(\n (dir: string, id?: string) => {\n if (!updateSlideConfig) return;\n\n const isStudentProfilePage = currentPageId === TrialPageId.STUDENT_PROFILE;\n const isLearningPlanSlide = currentPageId === TrialPageId.LEARNING_PLAN;\n const overrides: Partial<ITrialSessionFormFields> = {};\n\n if (\n id === TrialPageId.CIRCLE_GAME ||\n id === TrialPageId.CIRCLE_PUZZLE ||\n id === TrialPageId.CIRCLE_SKILL\n ) {\n overrides.matchmakingId = uuidv4();\n overrides.showCircleGameScreen = true;\n }\n\n if (dir === 'prev') {\n updateSlideConfig({\n id,\n ...(isStudentProfilePage && { studentProfile: undefined }),\n ...(isLearningPlanSlide && {\n chapterId: undefined,\n }),\n ...overrides,\n });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n\n if (dir === 'next') {\n switch (currentPageId) {\n //TODO: remove STUDENT_INFORMATION\n case TrialPageId.STUDENT_INFORMATION:\n case TrialPageId.SCHOOL_GOALS:\n handleStudentInformation();\n break;\n case TrialPageId.LEARNING_WORKSHEET:\n handleMileStoneBulkPost();\n break;\n case TrialPageId.CLASS_PREFERENCE:\n handleClassPreferences();\n break;\n case TrialPageId.LEARNING_LEVEL:\n case TrialPageId.STUDENT_PERSONALIZATION:\n handleStudentPreferencesPatch();\n break;\n case TrialPageId.LEARNING_PLAN:\n updateSlideConfig({ id, chapterId: undefined, ...overrides });\n break;\n default: {\n updateSlideConfig({ id, ...overrides });\n updateButtonState('both', DEFAULT_BUTTON_STATE);\n }\n }\n }\n },\n [\n updateSlideConfig,\n currentPageId,\n updateButtonState,\n handleStudentInformation,\n handleMileStoneBulkPost,\n handleClassPreferences,\n handleStudentPreferencesPatch,\n ],\n );\n\n const sessionWorksheetNavigation = useCallback(() => {\n if (!worksheetNavigationPanel && currentPageId === TrialPageId.LEARNING_WORKSHEET) {\n handleNavigation('next', nextPageId);\n }\n }, [currentPageId, handleNavigation, nextPageId, worksheetNavigationPanel]);\n\n useEffect(() => {\n sessionWorksheetNavigation();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [worksheetNavigationPanel]);\n\n return { handleNavigation };\n};\n\nexport { useTrialSessionNavigation };\n"],"names":["useTrialSessionNavigation","updateSlideConfig","slideConfig","formData","updateButtonState","teacherId","studentId","milestoneConfig","onTrialInformationUpdate","trialHomeData","worksheetNavigationPanel","useTrialSessionContext","nextPage","currentPageId","demoInfo","stream","regionData","countryCode","nextPageId","name","grade","goals","curriculum","studentTimezone","preferences","personalizedLevel","personalizedFocus","personalizedBehaviors","disableNavButtons","useCallback","onAcknowledge","errorMessage","overrides","TrialPageId","uuidv4","DEFAULT_BUTTON_STATE","patchTrialSession","usePatchTrialHome","patchStudentInformation","usePatchStudentInformation","postMilestoneBulk","useMilestoneBulkPost","postStudentPreferences","usePostStudentPreferences","handleStudentInformation","firstName","lastName","payload","handleClassPreferences","selectedRegularSlots","getFormattedPreferences","actionData","handleMileStoneBulkPost","handleStudentPreferencesPatch","getFormattedStudentPersonalizedPreference","meta","COURSE_STREAMS","handleNavigation","dir","id","isStudentProfilePage","isLearningPlanSlide","sessionWorksheetNavigation","useEffect"],"mappings":";;;;;;;;;;AAcA,MAAMA,KAA4B,MAAM;AAChC,QAAA;AAAA,IACJ,mBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,eAAAC;AAAA,IACA,0BAAAC;AAAA,MACEC,EAAuB,GACrB,E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;AACzB;AAAA,UACF,KAAKX,EAAY;AACS,YAAAmB;AACxB;AAAA,UACF,KAAKnB,EAAY;AACQ,YAAAe;AACvB;AAAA,UACF,KAAKf,EAAY;AAAA,UACjB,KAAKA,EAAY;AACe,YAAAoB;AAC9B;AAAA,UACF,KAAKpB,EAAY;AACf,YAAAhC,EAAkB,EAAE,IAAA0D,GAAI,WAAW,QAAW,GAAG3B,GAAW;AAC5D;AAAA,UACF;AACE,YAAA/B,EAAkB,EAAE,IAAA0D,GAAI,GAAG3B,EAAW,CAAA,GACtC5B,EAAkB,QAAQ+B,CAAoB;AAAA,QAElD;AAAA,IAEJ;AAAA,IACA;AAAA,MACElC;AAAA,MACAY;AAAA,MACAT;AAAA,MACAwC;AAAA,MACAQ;AAAA,MACAJ;AAAA,MACAK;AAAA,IACF;AAAA,EAAA,GAGIS,IAA6BjC,EAAY,MAAM;AACnD,IAAI,CAACnB,KAA4BG,MAAkBoB,EAAY,sBAC7DwB,EAAiB,QAAQvC,CAAU;AAAA,KAEpC,CAACL,GAAe4C,GAAkBvC,GAAYR,CAAwB,CAAC;AAE1E,SAAAqD,EAAU,MAAM;AACa,IAAAD;EAAA,GAE1B,CAACpD,CAAwB,CAAC,GAEtB,EAAE,kBAAA+C,EAAiB;AAC5B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/leap",
3
- "version": "2.8.53-link.0",
3
+ "version": "2.8.53-link.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -93,6 +93,5 @@
93
93
  "vite-plugin-dts": "3.6.4",
94
94
  "vite-plugin-svgr": "3.2.0",
95
95
  "vite-tsconfig-paths": "^4.2.2"
96
- },
97
- "packageManager": "yarn@4.4.1"
96
+ }
98
97
  }