@cuemath/leap 2.8.31-hg3 → 2.8.31-hg4

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,151 +1,155 @@
1
- import { useCallback as c, useEffect as W } from "react";
2
- import { COURSE_STREAMS as Z } from "../../milestone/constants.js";
3
- import { useMilestoneBulkPost as V } from "../../milestone/create/api/milestone-bulk.js";
4
- import { usePostStudentPreferences as j } from "../api/course-stream.js";
5
- import { usePatchStudentInformation as q } from "../api/student-information.js";
6
- import { usePatchTrialHome as J } from "../api/trial-home.js";
7
- import { useTrialSessionContext as Q } from "../context/use-trial-session-context.js";
8
- import { getFormattedPreferences as X, getFormattedStudentPersonalizedPreference as Y } from "../helper.js";
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
9
  import { DEFAULT_BUTTON_STATE as _, TrialPageId as e } from "../trial-session-constants.js";
10
- import $ from "../../../node_modules/uuid/dist/esm-browser/v4.js";
10
+ import z from "../../../node_modules/uuid/dist/esm-browser/v4.js";
11
11
  const de = () => {
12
12
  const {
13
13
  updateSlideConfig: s,
14
- slideConfig: z,
15
- formData: B,
14
+ slideConfig: B,
15
+ formData: H,
16
16
  updateButtonState: a,
17
- teacherId: l,
17
+ teacherId: d,
18
18
  studentId: n,
19
- milestoneConfig: I,
19
+ milestoneConfig: P,
20
20
  onTrialInformationUpdate: h,
21
- trialHomeData: H,
22
- worksheetNavigationPanel: N
23
- } = Q(), { nextPage: x, id: r } = z || {}, { demo_info: w } = H, { stream: L } = w, { pageId: d } = x || {}, {
21
+ trialHomeData: x,
22
+ worksheetNavigationPanel: I
23
+ } = X(), { nextPage: w, id: r } = B || {}, { demo_info: Z } = x, { stream: N } = Z, { pageId: i } = w || {}, {
24
24
  name: u,
25
25
  grade: p,
26
- goals: T,
27
- curriculum: S,
26
+ goals: C,
27
+ curriculum: E,
28
28
  studentTimezone: g,
29
- preferences: A = [],
30
- personalizedLevel: C = [],
29
+ preferences: T = [],
30
+ personalizedLevel: A = [],
31
31
  personalizedFocus: R = [],
32
32
  personalizedBehaviors: O = []
33
- } = B || {}, i = c(() => {
33
+ } = H || {}, c = l(() => {
34
34
  a("both", {
35
35
  left: { isDisabled: !0, isLoading: !1 },
36
36
  right: { isDisabled: !0, isLoading: !0 }
37
37
  });
38
- }, [a]), E = (t) => {
39
- t || s({ id: d }), a("both", _), (r === e.STUDENT_INFORMATION || r === e.SCHOOL_GOALS) && (h == null || h());
40
- }, { patch: b } = J({ onComplete: E }), { patch: v } = q({
41
- onComplete: E
42
- }), { post: k } = V({
43
- onComplete: E
44
- }), { post: D } = j({
45
- onComplete: E
46
- }), G = c(() => {
47
- const [t, o] = (u == null ? void 0 : u.split(" ")) || [], m = {
48
- first_name: t,
49
- last_name: o,
38
+ }, [a]), S = (o) => {
39
+ if (!o) {
40
+ const t = {};
41
+ (i === e.CIRCLE_GAME || i === e.CIRCLE_PUZZLE || i === e.CIRCLE_SKILL) && (t.matchmakingId = z(), t.showCircleGameScreen = !0), s({ id: i, ...t });
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 = {
52
+ first_name: o,
53
+ last_name: t,
50
54
  grade: p,
51
- board: S,
55
+ board: E,
52
56
  demo_type: "TRIAL_V3",
53
- teacher_id: l
57
+ teacher_id: d
54
58
  };
55
- i(), v(n, m);
56
- }, [S, p, u, v, n, l, i]), M = c(() => {
57
- const t = X(A, g);
58
- if (t.length > 0) {
59
- const o = {
59
+ c(), v(n, m);
60
+ }, [E, p, u, v, n, d, c]), M = l(() => {
61
+ const o = Y(T, g);
62
+ if (o.length > 0) {
63
+ const t = {
60
64
  trial_details: {
61
- selected_regular_slots: t
65
+ selected_regular_slots: o
62
66
  }
63
67
  };
64
- i(), b("trial-v3-patch", {
68
+ c(), b("trial-v3-patch", {
65
69
  action: "UPDATE_DEMO",
66
- action_data: o,
67
- teacher_id: l,
70
+ action_data: t,
71
+ teacher_id: d,
68
72
  student_id: n
69
73
  });
70
74
  } else
71
- s({ id: d }), a("both", _);
75
+ s({ id: i }), a("both", _);
72
76
  }, [
73
- A,
77
+ T,
74
78
  g,
75
- i,
79
+ c,
76
80
  b,
77
- l,
81
+ d,
78
82
  n,
79
83
  s,
80
- d,
84
+ i,
81
85
  a
82
- ]), F = c(() => {
83
- const t = {
84
- course_stream: L,
86
+ ]), U = l(() => {
87
+ const o = {
88
+ course_stream: N,
85
89
  grade: p,
86
- teacher_id: l,
87
- board: S,
88
- goals: T
90
+ teacher_id: d,
91
+ board: E,
92
+ goals: C
89
93
  };
90
- i(), k(t, {
94
+ c(), k(o, {
91
95
  studentId: n
92
96
  });
93
97
  }, [
94
- S,
95
- i,
96
- T,
98
+ E,
99
+ c,
100
+ C,
97
101
  p,
98
102
  k,
99
- L,
103
+ N,
100
104
  n,
101
- l
102
- ]), U = c(() => {
103
- const o = { preferences: Y(I, [
104
- ...C,
105
+ d
106
+ ]), F = l(() => {
107
+ const t = { preferences: $(P, [
108
+ ...A,
105
109
  ...R,
106
110
  ...O
107
- ]) }, m = { stream: Z.MATH, studentId: n };
108
- i(), D(o, m);
111
+ ]) }, m = { stream: V.MATH, studentId: n };
112
+ c(), D(t, m);
109
113
  }, [
110
- i,
111
- I,
114
+ c,
115
+ P,
112
116
  O,
113
117
  R,
114
- C,
118
+ A,
115
119
  D,
116
120
  n
117
- ]), P = c(
118
- (t, o) => {
121
+ ]), L = l(
122
+ (o, t) => {
119
123
  if (!s) return;
120
124
  const m = r === e.STUDENT_PROFILE, K = r === e.LEARNING_PLAN, f = {};
121
- if ((o === e.CIRCLE_GAME || o === e.CIRCLE_PUZZLE || o === e.CIRCLE_SKILL) && (f.matchmakingId = $(), f.showCircleGameScreen = !0), t === "prev" && (s({
122
- id: o,
125
+ if ((t === e.CIRCLE_GAME || t === e.CIRCLE_PUZZLE || t === e.CIRCLE_SKILL) && (f.matchmakingId = z(), f.showCircleGameScreen = !0), o === "prev" && (s({
126
+ id: t,
123
127
  ...m && { studentProfile: void 0 },
124
128
  ...K && {
125
129
  chapterId: void 0
126
130
  },
127
131
  ...f
128
- }), a("both", _)), t === "next")
132
+ }), a("both", _)), o === "next")
129
133
  switch (r) {
130
134
  case e.STUDENT_INFORMATION:
131
135
  case e.SCHOOL_GOALS:
132
136
  G();
133
137
  break;
134
138
  case e.LEARNING_WORKSHEET:
135
- F();
139
+ U();
136
140
  break;
137
141
  case e.CLASS_PREFERENCE:
138
142
  M();
139
143
  break;
140
144
  case e.LEARNING_LEVEL:
141
145
  case e.STUDENT_PERSONALIZATION:
142
- U();
146
+ F();
143
147
  break;
144
148
  case e.LEARNING_PLAN:
145
- s({ id: o, chapterId: void 0, ...f });
149
+ s({ id: t, chapterId: void 0, ...f });
146
150
  break;
147
151
  default:
148
- s({ id: o, ...f }), a("both", _);
152
+ s({ id: t, ...f }), a("both", _);
149
153
  }
150
154
  },
151
155
  [
@@ -153,16 +157,16 @@ const de = () => {
153
157
  r,
154
158
  a,
155
159
  G,
156
- F,
160
+ U,
157
161
  M,
158
- U
162
+ F
159
163
  ]
160
- ), y = c(() => {
161
- !N && r === e.LEARNING_WORKSHEET && P("next", d);
162
- }, [r, P, d, N]);
164
+ ), y = l(() => {
165
+ !I && r === e.LEARNING_WORKSHEET && L("next", i);
166
+ }, [r, L, i, I]);
163
167
  return W(() => {
164
168
  y();
165
- }, [N]), { handleNavigation: P };
169
+ }, [I]), { handleNavigation: L };
166
170
  };
167
171
  export {
168
172
  de as useTrialSessionNavigation
@@ -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 updateSlideConfig({ id: nextPageId });\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","DEFAULT_BUTTON_STATE","TrialPageId","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","overrides","uuidv4","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,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AkB,EAAE,IAAAsD,GAAI,WAAW,QAAW,GAAGG,GAAW;AAC5D;AAAA,UACF;AACE,YAAAzD,EAAkB,EAAE,IAAAsD,GAAI,GAAGG,EAAW,CAAA,GACtCtD,EAAkB,QAAQ0B,CAAoB;AAAA,QAElD;AAAA,IAEJ;AAAA,IACA;AAAA,MACE7B;AAAA,MACAY;AAAA,MACAT;AAAA,MACAoC;AAAA,MACAQ;AAAA,MACAJ;AAAA,MACAK;AAAA,IACF;AAAA,EAAA,GAGIW,IAA6BjC,EAAY,MAAM;AACnD,IAAI,CAACjB,KAA4BG,MAAkBkB,EAAY,sBAC7DsB,EAAiB,QAAQrC,CAAU;AAAA,KAEpC,CAACH,GAAewC,GAAkBrC,GAAYN,CAAwB,CAAC;AAE1E,SAAAmD,EAAU,MAAM;AACa,IAAAD;EAAA,GAE1B,CAAClD,CAAwB,CAAC,GAEtB,EAAE,kBAAA2C,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 } = 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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GAAe0C,GAAkBvC,GAAYN,CAAwB,CAAC;AAE1E,SAAAmD,EAAU,MAAM;AACa,IAAAD;EAAA,GAE1B,CAAClD,CAAwB,CAAC,GAEtB,EAAE,kBAAA6C,EAAiB;AAC5B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/leap",
3
- "version": "2.8.31-hg3",
3
+ "version": "2.8.31-hg4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"