@cuemath/leap 2.9.4-as10 → 2.9.4-as12
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/milestone/milestone-resources/resources-assign/api/goal-resource-assign.js +1 -1
- package/dist/features/milestone/milestone-resources/resources-assign/api/goal-resource-assign.js.map +1 -1
- package/dist/features/milestone/milestone-tests/tests-creation/api/test-sheet-assign.js.map +1 -1
- package/dist/features/milestone/milestone-tests/tests-creation/tests-creation.js +39 -38
- package/dist/features/milestone/milestone-tests/tests-creation/tests-creation.js.map +1 -1
- package/package.json +1 -1
package/dist/features/milestone/milestone-resources/resources-assign/api/goal-resource-assign.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createPostAPI as o } from "@cuemath/rest-api";
|
2
|
-
import {
|
2
|
+
import { BASE_URL_V3_1 as s } from "../../../../../constants/api.js";
|
3
3
|
const { usePost: u } = o({
|
4
4
|
getURL: (t, { userMilestoneId: e }) => `${s}/user-milestone/${e}/resources`
|
5
5
|
});
|
package/dist/features/milestone/milestone-resources/resources-assign/api/goal-resource-assign.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"goal-resource-assign.js","sources":["../../../../../../src/features/milestone/milestone-resources/resources-assign/api/goal-resource-assign.ts"],"sourcesContent":["import { createPostAPI } from '@cuemath/rest-api';\n\nimport {
|
1
|
+
{"version":3,"file":"goal-resource-assign.js","sources":["../../../../../../src/features/milestone/milestone-resources/resources-assign/api/goal-resource-assign.ts"],"sourcesContent":["import { createPostAPI } from '@cuemath/rest-api';\n\nimport { BASE_URL_V3_1 } from '../../../../../constants/api';\n\nconst { usePost: usePostMilestoneResource } = createPostAPI<\n void,\n {\n node_ids: string[];\n },\n { userMilestoneId: string }\n>({\n getURL: (_, { userMilestoneId }) =>\n `${BASE_URL_V3_1}/user-milestone/${userMilestoneId}/resources`,\n});\n\nexport { usePostMilestoneResource };\n"],"names":["usePostMilestoneResource","createPostAPI","_","userMilestoneId","BASE_URL_V3_1"],"mappings":";;AAIA,MAAM,EAAE,SAASA,EAAyB,IAAIC,EAM5C;AAAA,EACA,QAAQ,CAACC,GAAG,EAAE,iBAAAC,EACZ,MAAA,GAAGC,CAAa,mBAAmBD,CAAe;AACtD,CAAC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"test-sheet-assign.js","sources":["../../../../../../src/features/milestone/milestone-tests/tests-creation/api/test-sheet-assign.ts"],"sourcesContent":["import type { TTestDifficultyLevel } from '../tests-creation-types';\n\nimport { createPostAPI } from '@cuemath/rest-api';\n\nimport { BASE_URL_V3_1 } from '../../../../../constants/api';\n\ninterface ITestSheetAssignPayload {\n node_params: {\n is_timed: boolean;\n sheet_time: number;\n difficulty_level: TTestDifficultyLevel;\n };\n}\n\nconst { usePost: usePostTestSheetAssign } = createPostAPI<\n never,\n ITestSheetAssignPayload,\n { userMilestoneId: string }\n>({\n getURL: (_, { userMilestoneId }) => `${BASE_URL_V3_1}/user-milestone/${userMilestoneId}/tests`,\n});\n\nexport { usePostTestSheetAssign };\n"],"names":["usePostTestSheetAssign","createPostAPI","_","userMilestoneId","BASE_URL_V3_1"],"mappings":";;
|
1
|
+
{"version":3,"file":"test-sheet-assign.js","sources":["../../../../../../src/features/milestone/milestone-tests/tests-creation/api/test-sheet-assign.ts"],"sourcesContent":["import type { TTestDifficultyLevel } from '../tests-creation-types';\nimport type { ITestHelpPreviewResponse } from './preview-test-sheet';\n\nimport { createPostAPI } from '@cuemath/rest-api';\n\nimport { BASE_URL_V3_1 } from '../../../../../constants/api';\n\ninterface ITestSheetAssignPayload {\n items: ITestHelpPreviewResponse[];\n node_params: {\n is_timed: boolean;\n sheet_time: number;\n difficulty_level: TTestDifficultyLevel;\n };\n}\n\nconst { usePost: usePostTestSheetAssign } = createPostAPI<\n never,\n ITestSheetAssignPayload,\n { userMilestoneId: string }\n>({\n getURL: (_, { userMilestoneId }) => `${BASE_URL_V3_1}/user-milestone/${userMilestoneId}/tests`,\n});\n\nexport { usePostTestSheetAssign };\n"],"names":["usePostTestSheetAssign","createPostAPI","_","userMilestoneId","BASE_URL_V3_1"],"mappings":";;AAgBA,MAAM,EAAE,SAASA,EAAuB,IAAIC,EAI1C;AAAA,EACA,QAAQ,CAACC,GAAG,EAAE,iBAAAC,EAAsB,MAAA,GAAGC,CAAa,mBAAmBD,CAAe;AACxF,CAAC;"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as l, jsxs as W } from "react/jsx-runtime";
|
2
|
-
import { memo as G, useState as
|
2
|
+
import { memo as G, useState as T, useCallback as i, useEffect as E } from "react";
|
3
3
|
import U from "../../../ui/buttons/button/button.js";
|
4
4
|
import X from "../../../ui/layout/flex-view.js";
|
5
5
|
import q from "../../../ui/loader/app-loader/app-loader.js";
|
@@ -16,16 +16,16 @@ const ee = {
|
|
16
16
|
title: null,
|
17
17
|
duration: null,
|
18
18
|
chapters: null
|
19
|
-
}, te = G((
|
20
|
-
const { milestoneId: s, studentId:
|
21
|
-
|
19
|
+
}, te = G((y) => {
|
20
|
+
const { milestoneId: s, studentId: O, testNumber: D, onTestAssign: C, onExit: L, onError: c } = y, [_, x] = T("CHAPTER_SELECTION"), [o, f] = T(ee), [h, v] = T([]), m = i((e) => {
|
21
|
+
x(e);
|
22
22
|
}, []), F = i(
|
23
23
|
(e, t) => {
|
24
24
|
(e || !(t != null && t.length)) && (m("CHAPTER_SELECTION"), f((n) => {
|
25
|
-
const { chapters: r, selectedChapters: u } = n, V = r == null ? void 0 : r.map((
|
26
|
-
...
|
25
|
+
const { chapters: r, selectedChapters: u } = n, V = r == null ? void 0 : r.map((P) => u != null && u.includes(P.id) ? {
|
26
|
+
...P,
|
27
27
|
item_bank_enabled: !1
|
28
|
-
} :
|
28
|
+
} : P);
|
29
29
|
return {
|
30
30
|
...n,
|
31
31
|
chapters: V ?? null,
|
@@ -35,39 +35,40 @@ const ee = {
|
|
35
35
|
};
|
36
36
|
}), c(
|
37
37
|
"We're experiencing a temporary limitation with the chapters you've selected. Please select alternative chapters and proceed."
|
38
|
-
)), e ? c(e) : t &&
|
38
|
+
)), e ? c(e) : t && v(t);
|
39
39
|
},
|
40
|
-
[c,
|
40
|
+
[c, v, m]
|
41
41
|
), H = i(
|
42
42
|
(e) => {
|
43
|
-
e ? c(e) :
|
43
|
+
e ? c(e) : C();
|
44
44
|
},
|
45
|
-
[c,
|
45
|
+
[c, C]
|
46
46
|
), {
|
47
|
-
get:
|
47
|
+
get: I,
|
48
48
|
data: N,
|
49
49
|
isProcessing: $,
|
50
50
|
isProcessingFailed: b,
|
51
|
-
error:
|
51
|
+
error: p
|
52
52
|
} = B(s, {
|
53
53
|
with_sheets: !0
|
54
|
-
}), { post:
|
54
|
+
}), { post: A, isProcessing: M } = Y({
|
55
55
|
onComplete: F
|
56
|
-
}), { post:
|
56
|
+
}), { post: S, isProcessing: R } = J({
|
57
57
|
onComplete: H
|
58
|
-
}), { user_milestone_plan: j } = N || {}, { user_chapters: a } = j || {},
|
58
|
+
}), { user_milestone_plan: j } = N || {}, { user_chapters: a } = j || {}, w = i(
|
59
59
|
(e) => {
|
60
|
-
|
60
|
+
A(e);
|
61
61
|
},
|
62
|
-
[
|
63
|
-
),
|
64
|
-
|
62
|
+
[A]
|
63
|
+
), d = i(() => {
|
64
|
+
I(s, {
|
65
65
|
with_sheets: !0
|
66
66
|
});
|
67
|
-
}, [
|
67
|
+
}, [I, s]), k = i(() => {
|
68
68
|
const { duration: e, difficultyLevel: t, selectedChapters: n } = o;
|
69
|
-
e && t && n &&
|
69
|
+
e && t && n && S(
|
70
70
|
{
|
71
|
+
items: h,
|
71
72
|
node_params: {
|
72
73
|
is_timed: !0,
|
73
74
|
sheet_time: e * 60,
|
@@ -78,25 +79,25 @@ const ee = {
|
|
78
79
|
userMilestoneId: s
|
79
80
|
}
|
80
81
|
);
|
81
|
-
}, [
|
82
|
+
}, [S, o, s, h]), g = i(
|
82
83
|
(e, t) => {
|
83
84
|
if (m(e), t) {
|
84
85
|
const { difficultyLevel: n, duration: r } = t;
|
85
|
-
f((u) => ({ ...u, ...t })), e === "PREVIEW" && n && r &&
|
86
|
+
f((u) => ({ ...u, ...t })), e === "PREVIEW" && n && r && w({
|
86
87
|
difficulty_level: n,
|
87
88
|
duration: r,
|
88
89
|
user_chapter_ids: o.selectedChapters || []
|
89
90
|
});
|
90
91
|
}
|
91
92
|
},
|
92
|
-
[m,
|
93
|
+
[m, w, o]
|
93
94
|
);
|
94
|
-
return
|
95
|
-
s &&
|
96
|
-
}, [s,
|
95
|
+
return E(() => {
|
96
|
+
s && d();
|
97
|
+
}, [s, d]), E(() => {
|
97
98
|
a && a.length > 0 && f((e) => ({ ...e, chapters: a }));
|
98
99
|
}, [a]), $ || M ? /* @__PURE__ */ l(q, { height: "100vh" }) : b ? /* @__PURE__ */ W(X, { $height: "100vh", $flexGapX: 1.5, $alignItems: "center", $justifyContent: "center", children: [
|
99
|
-
/* @__PURE__ */ l(z, { $renderAs: "h6", children: (
|
100
|
+
/* @__PURE__ */ l(z, { $renderAs: "h6", children: (p == null ? void 0 : p.message) || "Oops! Something went wrong." }),
|
100
101
|
/* @__PURE__ */ l(
|
101
102
|
U,
|
102
103
|
{
|
@@ -105,26 +106,26 @@ const ee = {
|
|
105
106
|
shape: "square",
|
106
107
|
renderAs: "primary",
|
107
108
|
label: "Try again",
|
108
|
-
onClick:
|
109
|
+
onClick: d
|
109
110
|
}
|
110
111
|
)
|
111
|
-
] }) : a ?
|
112
|
+
] }) : a ? _ === "PREVIEW" ? /* @__PURE__ */ l(
|
112
113
|
Z,
|
113
114
|
{
|
114
|
-
studentId:
|
115
|
-
items:
|
116
|
-
testNumber:
|
115
|
+
studentId: O,
|
116
|
+
items: h,
|
117
|
+
testNumber: D,
|
117
118
|
isAssignInProgress: R,
|
118
|
-
onTestStageChange:
|
119
|
+
onTestStageChange: g,
|
119
120
|
onTestSheetAssign: k
|
120
121
|
}
|
121
|
-
) :
|
122
|
+
) : _ === "DIFFICULTY_AND_DURATION_SELECTION" ? /* @__PURE__ */ l(
|
122
123
|
Q,
|
123
124
|
{
|
124
125
|
testFormData: o,
|
125
|
-
onTestStageChange:
|
126
|
+
onTestStageChange: g
|
126
127
|
}
|
127
|
-
) : /* @__PURE__ */ l(K, { testFormData: o, onProceed:
|
128
|
+
) : /* @__PURE__ */ l(K, { testFormData: o, onProceed: g, onExit: L }) : null;
|
128
129
|
}), pe = te;
|
129
130
|
export {
|
130
131
|
pe as default
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tests-creation.js","sources":["../../../../../src/features/milestone/milestone-tests/tests-creation/tests-creation.tsx"],"sourcesContent":["import type { ITestHelpPreviewPayload, ITestHelpPreviewResponse } from './api/preview-test-sheet';\nimport type { ITestFromData, ITestsCreationProps, TTestsStage } from './tests-creation-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useState } from 'react';\n\nimport Button from '../../../ui/buttons/button/button';\nimport FlexView from '../../../ui/layout/flex-view';\nimport AppLoader from '../../../ui/loader/app-loader/app-loader';\nimport Text from '../../../ui/text/text';\nimport { useMilestoneGet } from '../../edit/comps/edit-milestone-modal/api/get-milestone';\nimport { usePostTestHelpPreview } from './api/preview-test-sheet';\nimport { usePostTestSheetAssign } from './api/test-sheet-assign';\nimport ChapterSelection from './test-stages/chapter-selection/chapter-selection';\nimport DifficultyAndDurationSelection from './test-stages/difficulty-and-duration-selection/difficulty-and-duration-selection';\nimport TestPreview from './test-stages/test-preview/test-preview';\n\nconst initFormData: ITestFromData = {\n selectedChapters: null,\n difficultyLevel: null,\n title: null,\n duration: null,\n chapters: null,\n};\n\nconst TestsCreation: FC<ITestsCreationProps> = memo(props => {\n const { milestoneId, studentId, testNumber, onTestAssign, onExit, onError } = props;\n\n const [testStage, setTestStage] = useState<TTestsStage>('CHAPTER_SELECTION');\n const [testFormData, setTestFromData] = useState<ITestFromData>(initFormData);\n const [testPreviewItems, setTestPreviewItems] = useState<ITestHelpPreviewResponse[]>([]);\n\n const handleOnTestStageChange = useCallback((nextStage: TTestsStage) => {\n setTestStage(nextStage);\n }, []);\n\n const handleOnTestHelpPreviewComplete = useCallback(\n (errorMessage: string | null, data?: ITestHelpPreviewResponse[]) => {\n if (errorMessage || !data?.length) {\n handleOnTestStageChange('CHAPTER_SELECTION');\n\n setTestFromData(prev => {\n const { chapters, selectedChapters } = prev;\n\n const updatedChapters = chapters?.map(chapter => {\n if (selectedChapters?.includes(chapter.id)) {\n return {\n ...chapter,\n item_bank_enabled: false,\n };\n }\n\n return chapter;\n });\n\n return {\n ...prev,\n chapters: updatedChapters ?? null,\n selectedChapters: null,\n difficultyLevel: null,\n duration: null,\n };\n });\n\n onError(\n `We're experiencing a temporary limitation with the chapters you've selected. Please select alternative chapters and proceed.`,\n );\n }\n\n if (errorMessage) {\n onError(errorMessage);\n } else if (data) {\n setTestPreviewItems(data);\n }\n },\n [onError, setTestPreviewItems, handleOnTestStageChange],\n );\n\n const handleOnTestSheetAssignComplete = useCallback(\n (errorMessage: string | null) => {\n if (errorMessage) {\n onError(errorMessage);\n } else {\n onTestAssign();\n }\n },\n [onError, onTestAssign],\n );\n\n const {\n get: getMilestone,\n data: currentMilestoneData,\n isProcessing: isMilestoneProcessing,\n isProcessingFailed: isMilestoneProcessingFailed,\n error: milestoneGetError,\n } = useMilestoneGet(milestoneId, {\n with_sheets: true,\n });\n\n const { post: postTestHelpPreview, isProcessing: testPreviewIsProcessing } =\n usePostTestHelpPreview({\n onComplete: handleOnTestHelpPreviewComplete,\n });\n\n const { post: postTestSheetAssign, isProcessing: testAssignIsProcessing } =\n usePostTestSheetAssign({\n onComplete: handleOnTestSheetAssignComplete,\n });\n\n const { user_milestone_plan: userMilestonePlan } = currentMilestoneData || {};\n const { user_chapters: userChapters } = userMilestonePlan || {};\n\n const handleOnPostTestHelpPreview = useCallback(\n (data: ITestHelpPreviewPayload) => {\n postTestHelpPreview(data);\n },\n [postTestHelpPreview],\n );\n\n const handleOnGetMilestone = useCallback(() => {\n getMilestone(milestoneId, {\n with_sheets: true,\n });\n }, [getMilestone, milestoneId]);\n\n const handleOnTestSheetAssign = useCallback(() => {\n const { duration, difficultyLevel, selectedChapters } = testFormData;\n\n if (duration && difficultyLevel && selectedChapters) {\n postTestSheetAssign(\n {\n node_params: {\n is_timed: true,\n sheet_time: duration * 60,\n difficulty_level: difficultyLevel,\n },\n },\n {\n userMilestoneId: milestoneId,\n },\n );\n }\n }, [postTestSheetAssign, testFormData, milestoneId]);\n\n const handleOnProceed = useCallback(\n (nextStage: TTestsStage, updatedForm?: ITestFromData) => {\n handleOnTestStageChange(nextStage);\n\n if (updatedForm) {\n const { difficultyLevel, duration } = updatedForm;\n\n setTestFromData(prev => ({ ...prev, ...updatedForm }));\n\n if (nextStage === 'PREVIEW' && difficultyLevel && duration) {\n handleOnPostTestHelpPreview({\n difficulty_level: difficultyLevel,\n duration: duration,\n user_chapter_ids: testFormData.selectedChapters || [],\n });\n }\n }\n },\n [handleOnTestStageChange, handleOnPostTestHelpPreview, testFormData],\n );\n\n useEffect(() => {\n if (milestoneId) {\n handleOnGetMilestone();\n }\n }, [milestoneId, handleOnGetMilestone]);\n\n useEffect(() => {\n if (userChapters && userChapters.length > 0) {\n setTestFromData(prev => ({ ...prev, chapters: userChapters }));\n }\n }, [userChapters]);\n\n if (isMilestoneProcessing || testPreviewIsProcessing) {\n return <AppLoader height=\"100vh\" />;\n }\n\n if (isMilestoneProcessingFailed) {\n return (\n <FlexView $height=\"100vh\" $flexGapX={1.5} $alignItems=\"center\" $justifyContent=\"center\">\n <Text $renderAs=\"h6\">{milestoneGetError?.message || 'Oops! Something went wrong.'}</Text>\n <Button\n widthX={14}\n size=\"small\"\n shape=\"square\"\n renderAs=\"primary\"\n label=\"Try again\"\n onClick={handleOnGetMilestone}\n />\n </FlexView>\n );\n }\n\n if (!userChapters) return null;\n\n if (testStage === 'PREVIEW') {\n return (\n <TestPreview\n studentId={studentId}\n items={testPreviewItems}\n testNumber={testNumber}\n isAssignInProgress={testAssignIsProcessing}\n onTestStageChange={handleOnProceed}\n onTestSheetAssign={handleOnTestSheetAssign}\n />\n );\n }\n\n if (testStage === 'DIFFICULTY_AND_DURATION_SELECTION') {\n return (\n <DifficultyAndDurationSelection\n testFormData={testFormData}\n onTestStageChange={handleOnProceed}\n />\n );\n }\n\n return (\n <ChapterSelection testFormData={testFormData} onProceed={handleOnProceed} onExit={onExit} />\n );\n});\n\nexport default TestsCreation;\n"],"names":["initFormData","TestsCreation","memo","props","milestoneId","studentId","testNumber","onTestAssign","onExit","onError","testStage","setTestStage","useState","testFormData","setTestFromData","testPreviewItems","setTestPreviewItems","handleOnTestStageChange","useCallback","nextStage","handleOnTestHelpPreviewComplete","errorMessage","data","prev","chapters","selectedChapters","updatedChapters","chapter","handleOnTestSheetAssignComplete","getMilestone","currentMilestoneData","isMilestoneProcessing","isMilestoneProcessingFailed","milestoneGetError","useMilestoneGet","postTestHelpPreview","testPreviewIsProcessing","usePostTestHelpPreview","postTestSheetAssign","testAssignIsProcessing","usePostTestSheetAssign","userMilestonePlan","userChapters","handleOnPostTestHelpPreview","handleOnGetMilestone","handleOnTestSheetAssign","duration","difficultyLevel","handleOnProceed","updatedForm","useEffect","jsx","AppLoader","jsxs","FlexView","Text","Button","TestPreview","DifficultyAndDurationSelection","ChapterSelection","TestsCreation$1"],"mappings":";;;;;;;;;;;;AAiBA,MAAMA,KAA8B;AAAA,EAClC,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AACZ,GAEMC,KAAyCC,EAAK,CAASC,MAAA;AAC3D,QAAM,EAAE,aAAAC,GAAa,WAAAC,GAAW,YAAAC,GAAY,cAAAC,GAAc,QAAAC,GAAQ,SAAAC,EAAY,IAAAN,GAExE,CAACO,GAAWC,CAAY,IAAIC,EAAsB,mBAAmB,GACrE,CAACC,GAAcC,CAAe,IAAIF,EAAwBZ,EAAY,GACtE,CAACe,GAAkBC,CAAmB,I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BwC;EACvB,GACC,CAACxC,GAAawC,CAAoB,CAAC,GAEtCM,EAAU,MAAM;AACV,IAAAR,KAAgBA,EAAa,SAAS,KACxC5B,EAAgB,QAAS,EAAE,GAAGS,GAAM,UAAUmB,EAAe,EAAA;AAAA,EAC/D,GACC,CAACA,CAAY,CAAC,GAEbX,KAAyBK,IACpB,gBAAAe,EAACC,GAAU,EAAA,QAAO,QAAQ,CAAA,IAG/BpB,IAEA,gBAAAqB,EAACC,KAAS,SAAQ,SAAQ,WAAW,KAAK,aAAY,UAAS,iBAAgB,UAC7E,UAAA;AAAA,IAAA,gBAAAH,EAACI,GAAK,EAAA,WAAU,MAAM,WAAAtB,KAAA,gBAAAA,EAAmB,YAAW,+BAA8B;AAAA,IAClF,gBAAAkB;AAAA,MAACK;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,MAAK;AAAA,QACL,OAAM;AAAA,QACN,UAAS;AAAA,QACT,OAAM;AAAA,QACN,SAASZ;AAAA,MAAA;AAAA,IACX;AAAA,EACF,EAAA,CAAA,IAICF,IAEDhC,MAAc,YAEd,gBAAAyC;AAAA,IAACM;AAAA,IAAA;AAAA,MACC,WAAApD;AAAA,MACA,OAAOU;AAAA,MACP,YAAAT;AAAA,MACA,oBAAoBiC;AAAA,MACpB,mBAAmBS;AAAA,MACnB,mBAAmBH;AAAA,IAAA;AAAA,EAAA,IAKrBnC,MAAc,sCAEd,gBAAAyC;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,cAAA7C;AAAA,MACA,mBAAmBmC;AAAA,IAAA;AAAA,EAAA,IAMtB,gBAAAG,EAAAQ,GAAA,EAAiB,cAAA9C,GAA4B,WAAWmC,GAAiB,QAAAxC,EAAgB,CAAA,IAzBlE;AA2B5B,CAAC,GAEDoD,KAAe3D;"}
|
1
|
+
{"version":3,"file":"tests-creation.js","sources":["../../../../../src/features/milestone/milestone-tests/tests-creation/tests-creation.tsx"],"sourcesContent":["import type { ITestHelpPreviewPayload, ITestHelpPreviewResponse } from './api/preview-test-sheet';\nimport type { ITestFromData, ITestsCreationProps, TTestsStage } from './tests-creation-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useState } from 'react';\n\nimport Button from '../../../ui/buttons/button/button';\nimport FlexView from '../../../ui/layout/flex-view';\nimport AppLoader from '../../../ui/loader/app-loader/app-loader';\nimport Text from '../../../ui/text/text';\nimport { useMilestoneGet } from '../../edit/comps/edit-milestone-modal/api/get-milestone';\nimport { usePostTestHelpPreview } from './api/preview-test-sheet';\nimport { usePostTestSheetAssign } from './api/test-sheet-assign';\nimport ChapterSelection from './test-stages/chapter-selection/chapter-selection';\nimport DifficultyAndDurationSelection from './test-stages/difficulty-and-duration-selection/difficulty-and-duration-selection';\nimport TestPreview from './test-stages/test-preview/test-preview';\n\nconst initFormData: ITestFromData = {\n selectedChapters: null,\n difficultyLevel: null,\n title: null,\n duration: null,\n chapters: null,\n};\n\nconst TestsCreation: FC<ITestsCreationProps> = memo(props => {\n const { milestoneId, studentId, testNumber, onTestAssign, onExit, onError } = props;\n\n const [testStage, setTestStage] = useState<TTestsStage>('CHAPTER_SELECTION');\n const [testFormData, setTestFromData] = useState<ITestFromData>(initFormData);\n const [testPreviewItems, setTestPreviewItems] = useState<ITestHelpPreviewResponse[]>([]);\n\n const handleOnTestStageChange = useCallback((nextStage: TTestsStage) => {\n setTestStage(nextStage);\n }, []);\n\n const handleOnTestHelpPreviewComplete = useCallback(\n (errorMessage: string | null, data?: ITestHelpPreviewResponse[]) => {\n if (errorMessage || !data?.length) {\n handleOnTestStageChange('CHAPTER_SELECTION');\n\n setTestFromData(prev => {\n const { chapters, selectedChapters } = prev;\n\n const updatedChapters = chapters?.map(chapter => {\n if (selectedChapters?.includes(chapter.id)) {\n return {\n ...chapter,\n item_bank_enabled: false,\n };\n }\n\n return chapter;\n });\n\n return {\n ...prev,\n chapters: updatedChapters ?? null,\n selectedChapters: null,\n difficultyLevel: null,\n duration: null,\n };\n });\n\n onError(\n `We're experiencing a temporary limitation with the chapters you've selected. Please select alternative chapters and proceed.`,\n );\n }\n\n if (errorMessage) {\n onError(errorMessage);\n } else if (data) {\n setTestPreviewItems(data);\n }\n },\n [onError, setTestPreviewItems, handleOnTestStageChange],\n );\n\n const handleOnTestSheetAssignComplete = useCallback(\n (errorMessage: string | null) => {\n if (errorMessage) {\n onError(errorMessage);\n } else {\n onTestAssign();\n }\n },\n [onError, onTestAssign],\n );\n\n const {\n get: getMilestone,\n data: currentMilestoneData,\n isProcessing: isMilestoneProcessing,\n isProcessingFailed: isMilestoneProcessingFailed,\n error: milestoneGetError,\n } = useMilestoneGet(milestoneId, {\n with_sheets: true,\n });\n\n const { post: postTestHelpPreview, isProcessing: testPreviewIsProcessing } =\n usePostTestHelpPreview({\n onComplete: handleOnTestHelpPreviewComplete,\n });\n\n const { post: postTestSheetAssign, isProcessing: testAssignIsProcessing } =\n usePostTestSheetAssign({\n onComplete: handleOnTestSheetAssignComplete,\n });\n\n const { user_milestone_plan: userMilestonePlan } = currentMilestoneData || {};\n const { user_chapters: userChapters } = userMilestonePlan || {};\n\n const handleOnPostTestHelpPreview = useCallback(\n (data: ITestHelpPreviewPayload) => {\n postTestHelpPreview(data);\n },\n [postTestHelpPreview],\n );\n\n const handleOnGetMilestone = useCallback(() => {\n getMilestone(milestoneId, {\n with_sheets: true,\n });\n }, [getMilestone, milestoneId]);\n\n const handleOnTestSheetAssign = useCallback(() => {\n const { duration, difficultyLevel, selectedChapters } = testFormData;\n\n if (duration && difficultyLevel && selectedChapters) {\n postTestSheetAssign(\n {\n items: testPreviewItems,\n node_params: {\n is_timed: true,\n sheet_time: duration * 60,\n difficulty_level: difficultyLevel,\n },\n },\n {\n userMilestoneId: milestoneId,\n },\n );\n }\n }, [postTestSheetAssign, testFormData, milestoneId, testPreviewItems]);\n\n const handleOnProceed = useCallback(\n (nextStage: TTestsStage, updatedForm?: ITestFromData) => {\n handleOnTestStageChange(nextStage);\n\n if (updatedForm) {\n const { difficultyLevel, duration } = updatedForm;\n\n setTestFromData(prev => ({ ...prev, ...updatedForm }));\n\n if (nextStage === 'PREVIEW' && difficultyLevel && duration) {\n handleOnPostTestHelpPreview({\n difficulty_level: difficultyLevel,\n duration: duration,\n user_chapter_ids: testFormData.selectedChapters || [],\n });\n }\n }\n },\n [handleOnTestStageChange, handleOnPostTestHelpPreview, testFormData],\n );\n\n useEffect(() => {\n if (milestoneId) {\n handleOnGetMilestone();\n }\n }, [milestoneId, handleOnGetMilestone]);\n\n useEffect(() => {\n if (userChapters && userChapters.length > 0) {\n setTestFromData(prev => ({ ...prev, chapters: userChapters }));\n }\n }, [userChapters]);\n\n if (isMilestoneProcessing || testPreviewIsProcessing) {\n return <AppLoader height=\"100vh\" />;\n }\n\n if (isMilestoneProcessingFailed) {\n return (\n <FlexView $height=\"100vh\" $flexGapX={1.5} $alignItems=\"center\" $justifyContent=\"center\">\n <Text $renderAs=\"h6\">{milestoneGetError?.message || 'Oops! Something went wrong.'}</Text>\n <Button\n widthX={14}\n size=\"small\"\n shape=\"square\"\n renderAs=\"primary\"\n label=\"Try again\"\n onClick={handleOnGetMilestone}\n />\n </FlexView>\n );\n }\n\n if (!userChapters) return null;\n\n if (testStage === 'PREVIEW') {\n return (\n <TestPreview\n studentId={studentId}\n items={testPreviewItems}\n testNumber={testNumber}\n isAssignInProgress={testAssignIsProcessing}\n onTestStageChange={handleOnProceed}\n onTestSheetAssign={handleOnTestSheetAssign}\n />\n );\n }\n\n if (testStage === 'DIFFICULTY_AND_DURATION_SELECTION') {\n return (\n <DifficultyAndDurationSelection\n testFormData={testFormData}\n onTestStageChange={handleOnProceed}\n />\n );\n }\n\n return (\n <ChapterSelection testFormData={testFormData} onProceed={handleOnProceed} onExit={onExit} />\n );\n});\n\nexport default TestsCreation;\n"],"names":["initFormData","TestsCreation","memo","props","milestoneId","studentId","testNumber","onTestAssign","onExit","onError","testStage","setTestStage","useState","testFormData","setTestFromData","testPreviewItems","setTestPreviewItems","handleOnTestStageChange","useCallback","nextStage","handleOnTestHelpPreviewComplete","errorMessage","data","prev","chapters","selectedChapters","updatedChapters","chapter","handleOnTestSheetAssignComplete","getMilestone","currentMilestoneData","isMilestoneProcessing","isMilestoneProcessingFailed","milestoneGetError","useMilestoneGet","postTestHelpPreview","testPreviewIsProcessing","usePostTestHelpPreview","postTestSheetAssign","testAssignIsProcessing","usePostTestSheetAssign","userMilestonePlan","userChapters","handleOnPostTestHelpPreview","handleOnGetMilestone","handleOnTestSheetAssign","duration","difficultyLevel","handleOnProceed","updatedForm","useEffect","jsx","AppLoader","jsxs","FlexView","Text","Button","TestPreview","DifficultyAndDurationSelection","ChapterSelection","TestsCreation$1"],"mappings":";;;;;;;;;;;;AAiBA,MAAMA,KAA8B;AAAA,EAClC,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AACZ,GAEMC,KAAyCC,EAAK,CAASC,MAAA;AAC3D,QAAM,EAAE,aAAAC,GAAa,WAAAC,GAAW,YAAAC,GAAY,cAAAC,GAAc,QAAAC,GAAQ,SAAAC,EAAY,IAAAN,GAExE,CAACO,GAAWC,CAAY,IAAIC,EAAsB,mBAAmB,GACrE,CAACC,GAAcC,CAAe,IAAIF,EAAwBZ,EAAY,GACtE,CAACe,GAAkBC,CAAmB,IAAIJ,EAAqC,CAAE,CAAA,GAEjFK,IAA0BC,EAAY,CAACC,MAA2B;AACtE,IAAAR,EAAaQ,CAAS;AAAA,EACxB,GAAG,CAAE,CAAA,GAECC,IAAkCF;AAAA,IACtC,CAACG,GAA6BC,MAAsC;AAC9D,OAAAD,KAAgB,EAACC,KAAA,QAAAA,EAAM,aACzBL,EAAwB,mBAAmB,GAE3CH,EAAgB,CAAQS,MAAA;AAChB,cAAA,EAAE,UAAAC,GAAU,kBAAAC,EAAqB,IAAAF,GAEjCG,IAAkBF,KAAA,gBAAAA,EAAU,IAAI,CAAWG,MAC3CF,KAAA,QAAAA,EAAkB,SAASE,EAAQ,MAC9B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