@cuemath/leap 2.8.21 → 2.8.22
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/assets/images/images.js +12 -0
- package/dist/assets/images/images.js.map +1 -1
- package/dist/constants/urls.js +5 -0
- package/dist/constants/urls.js.map +1 -0
- package/dist/features/chapters/chapter/chapter.js +45 -43
- package/dist/features/chapters/chapter/chapter.js.map +1 -1
- package/dist/features/chapters/chapter/comps/core-lessons/core-lessons.js +23 -21
- package/dist/features/chapters/chapter/comps/core-lessons/core-lessons.js.map +1 -1
- package/dist/features/milestone/constants.js +53 -18
- package/dist/features/milestone/constants.js.map +1 -1
- package/dist/features/milestone/create/comps/chapters-selection-step/chapters-selection-step-styled.js +16 -4
- package/dist/features/milestone/create/comps/chapters-selection-step/chapters-selection-step-styled.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-constants.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-container.js +56 -47
- package/dist/features/milestone/create/milestone-create-container.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-helpers.js +132 -113
- package/dist/features/milestone/create/milestone-create-helpers.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-hooks.js +92 -90
- package/dist/features/milestone/create/milestone-create-hooks.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-styled.js +34 -20
- package/dist/features/milestone/create/milestone-create-styled.js.map +1 -1
- package/dist/features/milestone/create/milestone-create.js +72 -53
- package/dist/features/milestone/create/milestone-create.js.map +1 -1
- package/dist/features/milestone/create/submit-modal/use-submit-milestone.js +53 -46
- package/dist/features/milestone/create/submit-modal/use-submit-milestone.js.map +1 -1
- package/dist/features/milestone/create/utils/index.js.map +1 -1
- package/dist/features/milestone/drafts/create/draft-create-container.js +54 -0
- package/dist/features/milestone/drafts/create/draft-create-container.js.map +1 -0
- package/dist/features/milestone/drafts/edit/draft-edit-container.js +77 -0
- package/dist/features/milestone/drafts/edit/draft-edit-container.js.map +1 -0
- package/dist/features/milestone/drafts/edit/draft-edit-helpers.js +69 -0
- package/dist/features/milestone/drafts/edit/draft-edit-helpers.js.map +1 -0
- package/dist/features/milestone/{edit/goal-drafts → drafts/goal-edit}/goal-draft-edit-container.js +24 -22
- package/dist/features/milestone/drafts/goal-edit/goal-draft-edit-container.js.map +1 -0
- package/dist/features/milestone/drafts/review/draft-review-container.js +76 -0
- package/dist/features/milestone/drafts/review/draft-review-container.js.map +1 -0
- package/dist/features/milestone/edit/comps/delete-milestone/add-remove-nudge.js +48 -0
- package/dist/features/milestone/edit/comps/delete-milestone/add-remove-nudge.js.map +1 -0
- package/dist/features/milestone/edit/comps/delete-milestone/styled.js +11 -8
- package/dist/features/milestone/edit/comps/delete-milestone/styled.js.map +1 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone-modal-styled.js +23 -0
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone-modal-styled.js.map +1 -0
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone.js +79 -82
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone.js.map +1 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/index.js +136 -112
- package/dist/features/milestone/edit/comps/edit-milestone-modal/index.js.map +1 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/share-screen.js +68 -0
- package/dist/features/milestone/edit/comps/edit-milestone-modal/share-screen.js.map +1 -0
- package/dist/features/milestone/edit/goal-edit-helpers.js +6 -5
- package/dist/features/milestone/edit/goal-edit-helpers.js.map +1 -1
- package/dist/features/milestone/edit/milestone-edit-helpers.js +17 -16
- package/dist/features/milestone/edit/milestone-edit-helpers.js.map +1 -1
- package/dist/features/milestone/help-modals/index.js +22 -0
- package/dist/features/milestone/help-modals/index.js.map +1 -0
- package/dist/features/milestone/help-modals/milestone-lesson.js +17 -0
- package/dist/features/milestone/help-modals/milestone-lesson.js.map +1 -0
- package/dist/features/milestone/help-modals/milestone-list.js +17 -0
- package/dist/features/milestone/help-modals/milestone-list.js.map +1 -0
- package/dist/features/milestone/help-modals/utils.js +20 -0
- package/dist/features/milestone/help-modals/utils.js.map +1 -0
- package/dist/features/milestone/intro-modal/index.js +24 -0
- package/dist/features/milestone/intro-modal/index.js.map +1 -0
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-list.js +48 -46
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-list.js.map +1 -1
- package/dist/features/milestone/milestone-list-container/milestone-list-container.js +60 -58
- package/dist/features/milestone/milestone-list-container/milestone-list-container.js.map +1 -1
- package/dist/features/milestone/outcome/comps/past-milestone/past-milestone-container.js +41 -39
- package/dist/features/milestone/outcome/comps/past-milestone/past-milestone-container.js.map +1 -1
- package/dist/features/notifications/api/notification.js +13 -0
- package/dist/features/notifications/api/notification.js.map +1 -0
- package/dist/features/notifications/use-student-journey.js +20 -0
- package/dist/features/notifications/use-student-journey.js.map +1 -0
- package/dist/features/sheets/constants/lessons.js +28 -0
- package/dist/features/sheets/constants/lessons.js.map +1 -0
- package/dist/features/ui/modals/info-modal/index.js +117 -0
- package/dist/features/ui/modals/info-modal/index.js.map +1 -0
- package/dist/index.d.ts +125 -7
- package/dist/index.js +258 -244
- package/dist/index.js.map +1 -1
- package/dist/static/goal_creation_helper.d45e4d58.png +0 -0
- package/dist/static/help_banner1.ddb0ef0f.png +0 -0
- package/dist/static/help_banner2.40979ed0.png +0 -0
- package/dist/static/help_banner3.532099c7.png +0 -0
- package/dist/static/help_banner4.90a6fd4d.png +0 -0
- package/dist/static/help_banner5.2a9efb39.png +0 -0
- package/dist/static/help_banner6.94fe9589.png +0 -0
- package/dist/static/milestone_intro_slide1.1537493e.png +0 -0
- package/dist/static/milestone_intro_slide2.b791c159.png +0 -0
- package/dist/static/milestone_intro_slide3.f7d63a11.png +0 -0
- package/dist/static/milestone_intro_slide4.f8da4e46.png +0 -0
- package/dist/static/milestone_intro_slide5.ea5d12d2.png +0 -0
- package/package.json +1 -1
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-container.js.map +0 -1
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-helpers.js +0 -17
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-helpers.js.map +0 -1
@@ -1,142 +1,144 @@
|
|
1
|
-
import { useState as P, useMemo as
|
1
|
+
import { useState as P, useMemo as N, useRef as B, useCallback as b } from "react";
|
2
|
+
import j from "../../notifications/use-student-journey.js";
|
2
3
|
import { TEST_TYPE_TO_TEST_NAME as v } from "../constants.js";
|
3
|
-
import { checkIfCommittedFieldIsUpdated as
|
4
|
-
import { GOAL_EDIT_FLOWS as p, BRANCHING_FIELDS as
|
5
|
-
import
|
4
|
+
import { checkIfCommittedFieldIsUpdated as y } from "../edit/goal-edit-helpers.js";
|
5
|
+
import { GOAL_EDIT_FLOWS as p, BRANCHING_FIELDS as k } from "./milestone-create-constants.js";
|
6
|
+
import F, { CHAPTERS_SELECTION_FORM_TREE as H, ADD_CUSTOM_CHAPTERS as W, SET_COMPLETION_DATE as J } from "./milestone-create-form-tree.js";
|
6
7
|
import { appendSchoolDataToFormState as V, generateFormStateWithPrefilledSchoolData as Y, getCurrenStep as h, clearNextFields as q } from "./milestone-create-helpers.js";
|
7
|
-
const
|
8
|
-
schoolData:
|
9
|
-
board:
|
10
|
-
grade:
|
8
|
+
const a = (d, {
|
9
|
+
schoolData: o,
|
10
|
+
board: e,
|
11
|
+
grade: u,
|
11
12
|
currentCountryCode: T,
|
12
|
-
flow:
|
13
|
+
flow: r
|
13
14
|
}) => {
|
14
|
-
const [
|
15
|
+
const [l, i] = P(() => d && p.includes(r) ? V(d, o, e, u) : {
|
15
16
|
...Y(
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
o,
|
18
|
+
e,
|
19
|
+
u,
|
19
20
|
T
|
20
21
|
)
|
21
22
|
});
|
22
|
-
return { formDataState:
|
23
|
-
},
|
24
|
-
flow:
|
25
|
-
formDataState:
|
26
|
-
isGoalCreation:
|
23
|
+
return { formDataState: l, setFormData: i };
|
24
|
+
}, g = (d, o) => j(d === "TEACHER" ? o : null), D = ({
|
25
|
+
flow: d,
|
26
|
+
formDataState: o,
|
27
|
+
isGoalCreation: e
|
27
28
|
}) => {
|
28
|
-
const { testType:
|
29
|
-
return
|
30
|
-
if (p.includes(
|
31
|
-
const
|
32
|
-
...
|
29
|
+
const { testType: u } = o;
|
30
|
+
return N(() => {
|
31
|
+
if (p.includes(d) && u) {
|
32
|
+
const r = {
|
33
|
+
...H,
|
33
34
|
isRootNode: !0,
|
34
|
-
title: v[
|
35
|
-
},
|
36
|
-
return
|
35
|
+
title: v[u]
|
36
|
+
}, l = Object.assign({}, W), i = Object.assign({}, J);
|
37
|
+
return e || (l.buttonLabel = "Add to learning plan", r.buttonLabel = "Update"), d === "EDIT" && (i.buttonLabel = "Update goal"), (!e || u === "no-test") && (r.next = [l, i]), r;
|
37
38
|
}
|
38
|
-
return
|
39
|
-
}, [
|
40
|
-
},
|
41
|
-
flow:
|
42
|
-
updatedFormTree:
|
43
|
-
formData:
|
44
|
-
formDataState:
|
39
|
+
return F;
|
40
|
+
}, [d, u, e]);
|
41
|
+
}, ee = ({
|
42
|
+
flow: d,
|
43
|
+
updatedFormTree: o,
|
44
|
+
formData: e,
|
45
|
+
formDataState: u,
|
45
46
|
setFormData: T,
|
46
|
-
handleExit:
|
47
|
+
handleExit: r
|
47
48
|
}) => {
|
48
|
-
const
|
49
|
-
() => h(
|
50
|
-
[
|
51
|
-
), O =
|
52
|
-
(
|
53
|
-
T((
|
54
|
-
const S =
|
55
|
-
if (p.includes(
|
56
|
-
const
|
57
|
-
...
|
58
|
-
...
|
49
|
+
const l = B(u), i = (e == null ? void 0 : e.currentFlow) ?? d, s = N(
|
50
|
+
() => h(o, e, i),
|
51
|
+
[o, e, i]
|
52
|
+
), O = s == null ? void 0 : s.name, A = !!(s != null && s.isRootNode), E = b(
|
53
|
+
(t) => {
|
54
|
+
T((n) => {
|
55
|
+
const S = n.testType;
|
56
|
+
if (p.includes(i)) {
|
57
|
+
const I = {
|
58
|
+
...n.committed,
|
59
|
+
...t.committed
|
59
60
|
}, C = [];
|
60
|
-
if (Object.entries((
|
61
|
-
const
|
62
|
-
if (
|
63
|
-
field:
|
64
|
-
isFieldCommited:
|
65
|
-
prevFormData:
|
66
|
-
newValueOfField:
|
67
|
-
formDataStateRef:
|
61
|
+
if (Object.entries((t == null ? void 0 : t.committed) || {}).forEach((R) => {
|
62
|
+
const c = R[0], M = !!R[1], U = t[c] ?? n[c];
|
63
|
+
if (y({
|
64
|
+
field: c,
|
65
|
+
isFieldCommited: M,
|
66
|
+
prevFormData: n,
|
67
|
+
newValueOfField: U,
|
68
|
+
formDataStateRef: l.current
|
68
69
|
})) {
|
69
70
|
let _ = [];
|
70
|
-
S && S === "no-test" && (_ = _.concat(["board"])), _.includes(
|
71
|
+
S && S === "no-test" && (_ = _.concat(["board"])), _.includes(c) || C.push(c);
|
71
72
|
}
|
72
|
-
}), C.length > 0 && C.some((
|
73
|
-
const
|
74
|
-
|
75
|
-
|
73
|
+
}), C.length > 0 && C.some((c) => k.includes(c))) {
|
74
|
+
const c = q(
|
75
|
+
o,
|
76
|
+
n,
|
76
77
|
O,
|
77
|
-
|
78
|
+
A,
|
78
79
|
[]
|
79
80
|
);
|
80
|
-
if (
|
81
|
+
if (c)
|
81
82
|
return {
|
82
|
-
...
|
83
|
-
...
|
83
|
+
...c,
|
84
|
+
...t,
|
84
85
|
committed: {
|
85
|
-
...
|
86
|
-
...
|
86
|
+
...c.committed,
|
87
|
+
...t.committed
|
87
88
|
},
|
88
89
|
reviewed: {
|
89
|
-
...
|
90
|
+
...I
|
90
91
|
},
|
91
92
|
currentFlow: "CREATE"
|
92
93
|
};
|
93
94
|
}
|
94
95
|
return {
|
95
|
-
...
|
96
|
-
...
|
96
|
+
...n,
|
97
|
+
...t,
|
97
98
|
committed: {
|
98
|
-
...
|
99
|
-
...
|
99
|
+
...n.committed,
|
100
|
+
...t.committed
|
100
101
|
},
|
101
|
-
reviewed:
|
102
|
+
reviewed: I
|
102
103
|
};
|
103
104
|
}
|
104
|
-
const { committed:
|
105
|
+
const { committed: m, reviewed: f, ...L } = n;
|
105
106
|
return {
|
106
107
|
...L,
|
107
|
-
...
|
108
|
+
...t,
|
108
109
|
committed: {
|
109
|
-
...
|
110
|
-
...
|
110
|
+
...m,
|
111
|
+
...t.committed
|
111
112
|
},
|
112
113
|
reviewed: {}
|
113
114
|
};
|
114
115
|
});
|
115
116
|
},
|
116
|
-
[T,
|
117
|
-
),
|
118
|
-
if (
|
119
|
-
const { reset:
|
117
|
+
[T, i, o, O, A]
|
118
|
+
), w = b(() => {
|
119
|
+
if (s) {
|
120
|
+
const { reset: t, rollback: n, isRootNode: S } = s;
|
120
121
|
if (S) {
|
121
|
-
|
122
|
+
r == null || r();
|
122
123
|
return;
|
123
124
|
}
|
124
|
-
const
|
125
|
+
const m = {
|
125
126
|
committed: {},
|
126
127
|
reviewed: {}
|
127
128
|
};
|
128
|
-
p.includes(
|
129
|
-
|
130
|
-
}) :
|
131
|
-
|
132
|
-
}), E(
|
129
|
+
p.includes(i) ? n.forEach((f) => {
|
130
|
+
m.reviewed[f] = void 0;
|
131
|
+
}) : t.forEach((f) => (m[f] = void 0, !0)), n.forEach((f) => {
|
132
|
+
m.committed[f] = void 0;
|
133
|
+
}), E(m);
|
133
134
|
}
|
134
|
-
}, [
|
135
|
-
return { currentStep:
|
135
|
+
}, [s, i, E, r]);
|
136
|
+
return { currentStep: s, updateFormData: E, handleBack: w };
|
136
137
|
};
|
137
138
|
export {
|
138
|
-
|
139
|
-
|
140
|
-
|
139
|
+
a as useFormDataPrefiller,
|
140
|
+
ee as useFormTreeTraversal,
|
141
|
+
D as useMilestoneFormTree,
|
142
|
+
g as useMilestoneInfoTransitionsControl
|
141
143
|
};
|
142
144
|
//# sourceMappingURL=milestone-create-hooks.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"milestone-create-hooks.js","sources":["../../../../src/features/milestone/create/milestone-create-hooks.ts"],"sourcesContent":["import type IStudentSchool from '../../../types/models/school';\nimport type {\n IFormStep,\n IFormStepProps,\n IMileStoneFormFields,\n IMilestoneConfig,\n IMilestoneFormData,\n TMilestoneFormStateField,\n TMilestoneFormFlow,\n} from './milestone-create-types';\n\nimport { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { TEST_TYPE_TO_TEST_NAME } from '../constants';\nimport { checkIfCommittedFieldIsUpdated } from '../edit/goal-edit-helpers';\nimport { BRANCHING_FIELDS, GOAL_EDIT_FLOWS } from './milestone-create-constants';\nimport FORM_TREE, {\n ADD_CUSTOM_CHAPTERS,\n CHAPTERS_SELECTION_FORM_TREE,\n SET_COMPLETION_DATE,\n} from './milestone-create-form-tree';\nimport {\n appendSchoolDataToFormState,\n clearNextFields,\n generateFormStateWithPrefilledSchoolData,\n getCurrenStep,\n} from './milestone-create-helpers';\n\n//TODO: right now it is for only one step, but should be for all steps in future if needed\nconst useFormDataPrefiller = (\n formDataProp: IMilestoneFormData | undefined,\n {\n schoolData,\n board,\n grade,\n currentCountryCode,\n flow,\n }: {\n grade: string;\n schoolData: IStudentSchool | undefined;\n board: string | undefined;\n config: IMilestoneConfig;\n flow: TMilestoneFormFlow;\n currentCountryCode?: string;\n },\n) => {\n const [formDataState, setFormData] = useState<IMilestoneFormData>(() => {\n if (formDataProp && GOAL_EDIT_FLOWS.includes(flow)) {\n return appendSchoolDataToFormState(formDataProp, schoolData, board, grade);\n }\n\n const formStateWithPrefilledSchoolData = generateFormStateWithPrefilledSchoolData(\n schoolData,\n board,\n grade,\n currentCountryCode,\n );\n\n return {\n ...formStateWithPrefilledSchoolData,\n };\n });\n\n return { formDataState, setFormData };\n};\n\n/**\n * Based on the flow returns the correct modified tree\n */\nconst useMilestoneFormTree = ({\n flow,\n formDataState,\n isGoalCreation,\n}: {\n flow: TMilestoneFormFlow;\n formDataState: IMilestoneFormData;\n isGoalCreation?: boolean;\n}) => {\n const { testType } = formDataState;\n\n const updatedFormTree: IFormStep = useMemo(() => {\n if (GOAL_EDIT_FLOWS.includes(flow) && testType) {\n const formTreeInfo = {\n ...CHAPTERS_SELECTION_FORM_TREE,\n isRootNode: true,\n title: TEST_TYPE_TO_TEST_NAME[testType],\n };\n\n //* Creating a shallow copy as we need to change only first level element.\n const addCustomChapter = Object.assign({}, ADD_CUSTOM_CHAPTERS);\n const setCompletionDate = Object.assign({}, SET_COMPLETION_DATE);\n\n //* To compensate existing milestones chapter addition.\n if (!isGoalCreation) {\n addCustomChapter.buttonLabel = 'Add to learning plan';\n formTreeInfo.buttonLabel = 'Update';\n }\n\n if (flow === 'EDIT') {\n setCompletionDate.buttonLabel = 'Update goal';\n }\n\n if (!isGoalCreation || testType === 'no-test') {\n formTreeInfo.next = [addCustomChapter, setCompletionDate];\n }\n\n return formTreeInfo;\n }\n\n return FORM_TREE;\n }, [flow, testType, isGoalCreation]);\n\n return updatedFormTree;\n};\n\n/**\n * This hook holds the logic to run the traversal of the tree during different flows.\n * While most of the logic is same for all flows, DRAFT_EDIT and DRAFT_REVIEW flows require extra logic where a user can navigate back and forth steps without clearing data.\n * Internally, this hook uses a currentFlow variable which is initially set to the flow but changes to CREATE flow, when certain BRANCHING_FIELDS are edited.\n * BRANCHING_FIELDS are fields on edition of which the flow might change and hence the prefilled data, needs to be cleared.\n * @returns `currentStep` - the current step the tree should be at\n * @returns `updateFormData` - the method to update form data\n * @returns `handleBack` - the method to handle back navigation\n */\nconst useFormTreeTraversal = ({\n flow,\n updatedFormTree,\n formData,\n formDataState,\n setFormData,\n handleExit,\n}: {\n flow: TMilestoneFormFlow;\n updatedFormTree: IFormStep;\n formData: IMilestoneFormData;\n formDataState: IMilestoneFormData;\n setFormData: React.Dispatch<React.SetStateAction<IMilestoneFormData>>;\n handleExit?: () => void;\n}) => {\n const formDataStateRef = useRef(formDataState);\n const currentFlow = formData?.currentFlow ?? flow;\n\n const currentStep = useMemo(\n () => getCurrenStep(updatedFormTree, formData, currentFlow),\n [updatedFormTree, formData, currentFlow],\n );\n\n const currentStepName = currentStep?.name;\n const isCurrentStepRoot = Boolean(currentStep?.isRootNode);\n\n const updateFormData = useCallback<IFormStepProps['onFormDataChange']>(\n changedFormData => {\n setFormData(prevFormData => {\n const currentTestType = prevFormData.testType;\n\n if (GOAL_EDIT_FLOWS.includes(currentFlow)) {\n const updatedReviewed = {\n ...prevFormData.committed,\n ...changedFormData.committed,\n };\n const updatedFields: TMilestoneFormStateField[] = [];\n\n Object.entries(changedFormData?.committed || {}).forEach(entry => {\n const field = entry[0] as keyof IMileStoneFormFields;\n const isFieldCommited = Boolean(entry[1]);\n const newValueOfField = changedFormData[field] ?? prevFormData[field];\n\n const isFieldUpdatedAndCommitted = checkIfCommittedFieldIsUpdated({\n field,\n isFieldCommited,\n prevFormData,\n newValueOfField,\n formDataStateRef: formDataStateRef.current,\n });\n\n if (isFieldUpdatedAndCommitted) {\n let exceptedFields: TMilestoneFormStateField[] = [];\n\n if (currentTestType && currentTestType === 'no-test') {\n exceptedFields = exceptedFields.concat(['board']);\n }\n\n if (!exceptedFields.includes(field)) {\n updatedFields.push(field);\n }\n }\n });\n\n if (updatedFields.length > 0) {\n const isBranchingFieldUpdated = updatedFields.some(field => {\n return BRANCHING_FIELDS.includes(field);\n });\n\n if (isBranchingFieldUpdated) {\n const updatedTree = clearNextFields(\n updatedFormTree,\n prevFormData,\n currentStepName,\n isCurrentStepRoot,\n [],\n );\n\n if (updatedTree)\n return {\n ...updatedTree,\n ...changedFormData,\n committed: {\n ...updatedTree.committed,\n ...changedFormData.committed,\n },\n reviewed: {\n ...updatedReviewed,\n },\n currentFlow: 'CREATE',\n };\n }\n }\n\n return {\n ...prevFormData,\n ...changedFormData,\n committed: {\n ...prevFormData.committed,\n ...changedFormData.committed,\n },\n reviewed: updatedReviewed,\n };\n }\n\n const { committed: prevFormCommitted, reviewed, ...fieldsData } = prevFormData;\n\n return {\n ...fieldsData,\n ...changedFormData,\n committed: {\n ...prevFormCommitted,\n ...changedFormData.committed,\n },\n reviewed: {},\n };\n });\n },\n [setFormData, currentFlow, updatedFormTree, currentStepName, isCurrentStepRoot],\n );\n\n const handleBack = useCallback(() => {\n if (currentStep) {\n const { reset, rollback, isRootNode } = currentStep;\n\n if (isRootNode) {\n handleExit?.();\n\n return;\n }\n\n const data: IMilestoneFormData = {\n committed: {},\n reviewed: {},\n };\n\n if (!GOAL_EDIT_FLOWS.includes(currentFlow)) {\n reset.forEach(field => {\n data[field] = undefined;\n\n return true;\n });\n } else {\n rollback.forEach(field => {\n data.reviewed[field] = undefined;\n });\n }\n rollback.forEach(field => {\n data.committed[field] = undefined;\n });\n\n updateFormData(data);\n }\n }, [currentStep, currentFlow, updateFormData, handleExit]);\n\n return { currentStep, updateFormData, handleBack };\n};\n\nexport { useFormDataPrefiller, useFormTreeTraversal, useMilestoneFormTree };\n"],"names":["useFormDataPrefiller","formDataProp","schoolData","board","grade","currentCountryCode","flow","formDataState","setFormData","useState","GOAL_EDIT_FLOWS","appendSchoolDataToFormState","generateFormStateWithPrefilledSchoolData","useMilestoneFormTree","isGoalCreation","testType","useMemo","formTreeInfo","CHAPTERS_SELECTION_FORM_TREE","TEST_TYPE_TO_TEST_NAME","addCustomChapter","ADD_CUSTOM_CHAPTERS","setCompletionDate","SET_COMPLETION_DATE","FORM_TREE","useFormTreeTraversal","updatedFormTree","formData","handleExit","formDataStateRef","useRef","currentFlow","currentStep","getCurrenStep","currentStepName","isCurrentStepRoot","updateFormData","useCallback","changedFormData","prevFormData","currentTestType","updatedReviewed","updatedFields","entry","field","isFieldCommited","newValueOfField","checkIfCommittedFieldIsUpdated","exceptedFields","BRANCHING_FIELDS","updatedTree","clearNextFields","prevFormCommitted","reviewed","fieldsData","handleBack","reset","rollback","isRootNode","data"],"mappings":";;;;;;AA6BM,MAAAA,IAAuB,CAC3BC,GACA;AAAA,EACE,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,MAAAC;AACF,MAQG;AACH,QAAM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AElD,SAAA,EAAE,aAAAI,GAAa,gBAAAI,GAAgB,YAAAmB;AACxC;"}
|
1
|
+
{"version":3,"file":"milestone-create-hooks.js","sources":["../../../../src/features/milestone/create/milestone-create-hooks.ts"],"sourcesContent":["import type IStudentSchool from '../../../types/models/school';\nimport type { IStudentJourneyData } from '../../notifications/types';\nimport type { TUserTypes } from '../../ui/types';\nimport type {\n IFormStep,\n IFormStepProps,\n IMileStoneFormFields,\n IMilestoneConfig,\n IMilestoneFormData,\n TMilesonteFormStateField,\n TMilestoneFormFlow,\n} from './milestone-create-types';\n\nimport { useCallback, useMemo, useRef, useState } from 'react';\n\nimport useStudentJourneys from '../../notifications/use-student-journey';\nimport { TEST_TYPE_TO_TEST_NAME } from '../constants';\nimport { checkIfCommittedFieldIsUpdated } from '../edit/goal-edit-helpers';\nimport { BRANCHING_FIELDS, GOAL_EDIT_FLOWS } from './milestone-create-constants';\nimport FORM_TREE, {\n ADD_CUSTOM_CHAPTERS,\n CHAPTERS_SELECTION_FORM_TREE,\n SET_COMPLETION_DATE,\n} from './milestone-create-form-tree';\nimport {\n appendSchoolDataToFormState,\n clearNextFields,\n generateFormStateWithPrefilledSchoolData,\n getCurrenStep,\n} from './milestone-create-helpers';\n\n//TODO: right now it is for only one step, but should be for all steps in future if needed\nconst useFormDataPrefiller = (\n formDataProp: IMilestoneFormData | undefined,\n {\n schoolData,\n board,\n grade,\n currentCountryCode,\n flow,\n }: {\n grade: string;\n schoolData: IStudentSchool | undefined;\n board: string | undefined;\n config: IMilestoneConfig;\n journeysToInclude: IStudentJourneyData[];\n flow: TMilestoneFormFlow;\n currentCountryCode?: string;\n },\n) => {\n const [formDataState, setFormData] = useState<IMilestoneFormData>(() => {\n if (formDataProp && GOAL_EDIT_FLOWS.includes(flow)) {\n return appendSchoolDataToFormState(formDataProp, schoolData, board, grade);\n }\n\n const formStateWithPrefilledSchoolData = generateFormStateWithPrefilledSchoolData(\n schoolData,\n board,\n grade,\n currentCountryCode,\n );\n\n return {\n ...formStateWithPrefilledSchoolData,\n };\n });\n\n return { formDataState, setFormData };\n};\n\nconst useMilestoneInfoTransitionsControl = (userType: TUserTypes, studentId: string | null) => {\n const journeysToInclude = useStudentJourneys(userType === 'TEACHER' ? studentId : null);\n\n return journeysToInclude;\n};\n\n/**\n * Based on the flow returns the correct modified tree\n */\nconst useMilestoneFormTree = ({\n flow,\n formDataState,\n isGoalCreation,\n}: {\n isFirstMilestoneCreated: boolean;\n flow: TMilestoneFormFlow;\n formDataState: IMilestoneFormData;\n isGoalCreation?: boolean;\n}) => {\n const { testType } = formDataState;\n\n const updatedFormTree: IFormStep = useMemo(() => {\n if (GOAL_EDIT_FLOWS.includes(flow) && testType) {\n const formTreeInfo = {\n ...CHAPTERS_SELECTION_FORM_TREE,\n isRootNode: true,\n title: TEST_TYPE_TO_TEST_NAME[testType],\n };\n\n //* Creating a shallow copy as we need to change only first level element.\n const addCustomChapter = Object.assign({}, ADD_CUSTOM_CHAPTERS);\n const setCompletionDate = Object.assign({}, SET_COMPLETION_DATE);\n\n //* To compensate existing milestones chapter addition.\n if (!isGoalCreation) {\n addCustomChapter.buttonLabel = 'Add to learning plan';\n formTreeInfo.buttonLabel = 'Update';\n }\n\n if (flow === 'EDIT') {\n setCompletionDate.buttonLabel = 'Update goal';\n }\n\n if (!isGoalCreation || testType === 'no-test') {\n formTreeInfo.next = [addCustomChapter, setCompletionDate];\n }\n\n return formTreeInfo;\n }\n\n return FORM_TREE;\n }, [flow, testType, isGoalCreation]);\n\n return updatedFormTree;\n};\n\n/**\n * This hook holds the logic to run the traversal of the tree during different flows.\n * While most of the logic is same for all flows, DRAFT_EDIT and DRAFT_REVIEW flows require extra logic where a user can navigate back and forth steps without clearing data.\n * Internally, this hook uses a currentFlow variable which is initially set to the flow but changes to CREATE flow, when certain BRANCHING_FIELDS are edited.\n * BRANCHING_FIELDS are fields on edition of which the flow might change and hence the prefilled data, needs to be cleared.\n * @returns `currentStep` - the current step the tree should be at\n * @returns `updateFormData` - the method to update form data\n * @returns `handleBack` - the method to handle back navigation\n */\nconst useFormTreeTraversal = ({\n flow,\n updatedFormTree,\n formData,\n formDataState,\n setFormData,\n handleExit,\n}: {\n flow: TMilestoneFormFlow;\n updatedFormTree: IFormStep;\n formData: IMilestoneFormData;\n formDataState: IMilestoneFormData;\n setFormData: React.Dispatch<React.SetStateAction<IMilestoneFormData>>;\n handleExit?: () => void;\n}) => {\n const formDataStateRef = useRef(formDataState);\n const currentFlow = formData?.currentFlow ?? flow;\n\n const currentStep = useMemo(\n () => getCurrenStep(updatedFormTree, formData, currentFlow),\n [updatedFormTree, formData, currentFlow],\n );\n\n const currentStepName = currentStep?.name;\n const isCurrentStepRoot = Boolean(currentStep?.isRootNode);\n\n const updateFormData = useCallback<IFormStepProps['onFormDataChange']>(\n changedFormData => {\n setFormData(prevFormData => {\n const currentTestType = prevFormData.testType;\n\n if (GOAL_EDIT_FLOWS.includes(currentFlow)) {\n const updatedReviewed = {\n ...prevFormData.committed,\n ...changedFormData.committed,\n };\n const updatedFields: TMilesonteFormStateField[] = [];\n\n Object.entries(changedFormData?.committed || {}).forEach(entry => {\n const field = entry[0] as keyof IMileStoneFormFields;\n const isFieldCommited = Boolean(entry[1]);\n const newValueOfField = changedFormData[field] ?? prevFormData[field];\n\n const isFieldUpdatedAndCommitted = checkIfCommittedFieldIsUpdated({\n field,\n isFieldCommited,\n prevFormData,\n newValueOfField,\n formDataStateRef: formDataStateRef.current,\n });\n\n if (isFieldUpdatedAndCommitted) {\n let exceptedFields: TMilesonteFormStateField[] = [];\n\n if (currentTestType && currentTestType === 'no-test') {\n exceptedFields = exceptedFields.concat(['board']);\n }\n\n if (!exceptedFields.includes(field)) {\n updatedFields.push(field);\n }\n }\n });\n\n if (updatedFields.length > 0) {\n const isBranchingFieldUpdated = updatedFields.some(field => {\n return BRANCHING_FIELDS.includes(field);\n });\n\n if (isBranchingFieldUpdated) {\n const updatedTree = clearNextFields(\n updatedFormTree,\n prevFormData,\n currentStepName,\n isCurrentStepRoot,\n [],\n );\n\n if (updatedTree)\n return {\n ...updatedTree,\n ...changedFormData,\n committed: {\n ...updatedTree.committed,\n ...changedFormData.committed,\n },\n reviewed: {\n ...updatedReviewed,\n },\n currentFlow: 'CREATE',\n };\n }\n }\n\n return {\n ...prevFormData,\n ...changedFormData,\n committed: {\n ...prevFormData.committed,\n ...changedFormData.committed,\n },\n reviewed: updatedReviewed,\n };\n }\n\n const { committed: prevFormCommitted, reviewed, ...fieldsData } = prevFormData;\n\n return {\n ...fieldsData,\n ...changedFormData,\n committed: {\n ...prevFormCommitted,\n ...changedFormData.committed,\n },\n reviewed: {},\n };\n });\n },\n [setFormData, currentFlow, updatedFormTree, currentStepName, isCurrentStepRoot],\n );\n\n const handleBack = useCallback(() => {\n if (currentStep) {\n const { reset, rollback, isRootNode } = currentStep;\n\n if (isRootNode) {\n handleExit?.();\n\n return;\n }\n\n const data: IMilestoneFormData = {\n committed: {},\n reviewed: {},\n };\n\n if (!GOAL_EDIT_FLOWS.includes(currentFlow)) {\n reset.forEach(field => {\n data[field] = undefined;\n\n return true;\n });\n } else {\n rollback.forEach(field => {\n data.reviewed[field] = undefined;\n });\n }\n rollback.forEach(field => {\n data.committed[field] = undefined;\n });\n\n updateFormData(data);\n }\n }, [currentStep, currentFlow, updateFormData, handleExit]);\n\n return { currentStep, updateFormData, handleBack };\n};\n\nexport {\n useFormDataPrefiller,\n useFormTreeTraversal,\n useMilestoneFormTree,\n useMilestoneInfoTransitionsControl,\n};\n"],"names":["useFormDataPrefiller","formDataProp","schoolData","board","grade","currentCountryCode","flow","formDataState","setFormData","useState","GOAL_EDIT_FLOWS","appendSchoolDataToFormState","generateFormStateWithPrefilledSchoolData","useMilestoneInfoTransitionsControl","userType","studentId","useStudentJourneys","useMilestoneFormTree","isGoalCreation","testType","useMemo","formTreeInfo","CHAPTERS_SELECTION_FORM_TREE","TEST_TYPE_TO_TEST_NAME","addCustomChapter","ADD_CUSTOM_CHAPTERS","setCompletionDate","SET_COMPLETION_DATE","FORM_TREE","useFormTreeTraversal","updatedFormTree","formData","handleExit","formDataStateRef","useRef","currentFlow","currentStep","getCurrenStep","currentStepName","isCurrentStepRoot","updateFormData","useCallback","changedFormData","prevFormData","currentTestType","updatedReviewed","updatedFields","entry","field","isFieldCommited","newValueOfField","checkIfCommittedFieldIsUpdated","exceptedFields","BRANCHING_FIELDS","updatedTree","clearNextFields","prevFormCommitted","reviewed","fieldsData","handleBack","reset","rollback","isRootNode","data"],"mappings":";;;;;;;AAgCM,MAAAA,IAAuB,CAC3BC,GACA;AAAA,EACE,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,MAAAC;AACF,MASG;AACH,QAAM,CAACC,GAAeC,CAAW,IAAIC,EAA6B,MAC5DR,KAAgBS,EAAgB,SAASJ,CAAI,IACxCK,EAA4BV,GAAcC,GAAYC,GAAOC,CAAK,IAUpE;AAAA,IACL,GARuCQ;AAAA,MACvCV;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,IAAA;AAAA,EAIG,CAEN;AAEM,SAAA,EAAE,eAAAE,GAAe,aAAAC;AAC1B,GAEMK,IAAqC,CAACC,GAAsBC,MACtCC,EAAmBF,MAAa,YAAYC,IAAY,IAAI,GAQlFE,IAAuB,CAAC;AAAA,EAC5B,MAAAX;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAW;AACF,MAKM;AACE,QAAA,EAAE,UAAAC,EAAa,IAAAZ;AAkCd,SAhC4Ba,EAAQ,MAAM;AAC/C,QAAIV,EAAgB,SAASJ,CAAI,KAAKa,GAAU;AAC9C,YAAME,IAAe;AAAA,QACnB,GAAGC;AAAA,QACH,YAAY;AAAA,QACZ,OAAOC,EAAuBJ,CAAQ;AAAA,MAAA,GAIlCK,IAAmB,OAAO,OAAO,IAAIC,CAAmB,GACxDC,IAAoB,OAAO,OAAO,IAAIC,CAAmB;AAG/D,aAAKT,MACHM,EAAiB,cAAc,wBAC/BH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AAC,EAAA,IAAe1B;AAExC,UAAI0B,GAAY;AACD,QAAA9B,KAAA,QAAAA;AAEb;AAAA,MACF;AAEA,YAAM+B,IAA2B;AAAA,QAC/B,WAAW,CAAC;AAAA,QACZ,UAAU,CAAC;AAAA,MAAA;AAGb,MAAKrD,EAAgB,SAASyB,CAAW,IAOvC0B,EAAS,QAAQ,CAASb,MAAA;AACnB,QAAAe,EAAA,SAASf,CAAK,IAAI;AAAA,MAAA,CACxB,IARDY,EAAM,QAAQ,CAASZ,OACrBe,EAAKf,CAAK,IAAI,QAEP,GACR,GAMHa,EAAS,QAAQ,CAASb,MAAA;AACnB,QAAAe,EAAA,UAAUf,CAAK,IAAI;AAAA,MAAA,CACzB,GAEDR,EAAeuB,CAAI;AAAA,IACrB;AAAA,KACC,CAAC3B,GAAaD,GAAaK,GAAgBR,CAAU,CAAC;AAElD,SAAA,EAAE,aAAAI,GAAa,gBAAAI,GAAgB,YAAAmB;AACxC;"}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import r from "styled-components";
|
2
2
|
import n from "../../ui/layout/flex-view.js";
|
3
|
-
const
|
4
|
-
({ $height: o, $viewMode:
|
3
|
+
const d = r.div(
|
4
|
+
({ $height: o, $viewMode: t, $minHeight: e }) => `
|
5
5
|
display: flex;
|
6
6
|
flex-direction: column;
|
7
7
|
height: ${o ? typeof o == "number" ? `${o}px` : `${o}` : "auto"};
|
8
|
-
min-height: ${
|
9
|
-
${
|
8
|
+
min-height: ${e || "auto"};
|
9
|
+
${t ? `
|
10
10
|
cursor: not-allowed;
|
11
11
|
border: 2px solid black;
|
12
12
|
border-radius: 8px;
|
@@ -16,8 +16,8 @@ const l = r.div(
|
|
16
16
|
}
|
17
17
|
` : ""}
|
18
18
|
`
|
19
|
-
),
|
20
|
-
({ theme: o, $viewMode:
|
19
|
+
), l = r.div(
|
20
|
+
({ theme: o, $viewMode: t }) => `
|
21
21
|
position: relative;
|
22
22
|
display: flex;
|
23
23
|
flex-direction: column;
|
@@ -25,7 +25,7 @@ const l = r.div(
|
|
25
25
|
margin-bottom: ${o.layout.gutter * 0.5}px;
|
26
26
|
border: 1px solid ${o.colors.GREY_1};
|
27
27
|
border-radius: ${o.layout.gutter * 0.75}px;
|
28
|
-
${
|
28
|
+
${t ? `
|
29
29
|
pointer-events: none;
|
30
30
|
// opacity: 0.85;
|
31
31
|
` : ""}
|
@@ -45,25 +45,34 @@ const l = r.div(
|
|
45
45
|
position: fixed;
|
46
46
|
bottom: 24px;
|
47
47
|
right: 24px;
|
48
|
-
`)
|
48
|
+
`);
|
49
|
+
r.div(({ theme: o }) => {
|
50
|
+
const { gutter: t } = o.layout;
|
51
|
+
return `
|
52
|
+
position: absolute;
|
53
|
+
top: ${t * 2}px;
|
54
|
+
left: ${t * 1.5}px;
|
55
|
+
`;
|
56
|
+
});
|
57
|
+
const x = r.img(({ theme: o, $backgroundColor: t }) => {
|
49
58
|
const {
|
50
|
-
layout: { gutter:
|
59
|
+
layout: { gutter: e },
|
51
60
|
colors: i
|
52
61
|
} = o;
|
53
62
|
return `
|
54
|
-
width: ${
|
55
|
-
height: ${
|
56
|
-
background: ${i[
|
57
|
-
border-radius: ${
|
63
|
+
width: ${e * 6}px;
|
64
|
+
height: ${e * 6}px;
|
65
|
+
background: ${i[t]};
|
66
|
+
border-radius: ${e * 0.5}px;
|
58
67
|
`;
|
59
|
-
}), f = r(n)(({ theme: o, $viewMode:
|
68
|
+
}), f = r(n)(({ theme: o, $viewMode: t }) => {
|
60
69
|
const {
|
61
|
-
layout: { gutter:
|
70
|
+
layout: { gutter: e }
|
62
71
|
} = o;
|
63
72
|
return `
|
64
73
|
position:relative;
|
65
|
-
min-height:${
|
66
|
-
${
|
74
|
+
min-height:${e * 2.75}px;
|
75
|
+
${t ? `
|
67
76
|
pointer-events: none;
|
68
77
|
opacity: 0.85;
|
69
78
|
` : ""}
|
@@ -72,15 +81,20 @@ const l = r.div(
|
|
72
81
|
position: absolute;
|
73
82
|
left: 50%;
|
74
83
|
transform: translateX(-50%);
|
84
|
+
`, b = r(n)`
|
85
|
+
border-radius: 0 0 8px 8px;
|
86
|
+
margin: auto;
|
87
|
+
width: 328px;
|
75
88
|
`;
|
76
89
|
export {
|
77
|
-
|
78
|
-
|
90
|
+
l as BodyContainer,
|
91
|
+
d as Container,
|
79
92
|
a as ContentContainer,
|
80
93
|
c as FooterWrapper,
|
81
94
|
u as HeaderContainer,
|
82
95
|
f as HeaderWrapper,
|
83
96
|
x as RadioCardIcon,
|
84
|
-
$ as StepperWrapper
|
97
|
+
$ as StepperWrapper,
|
98
|
+
b as SyncIndicator
|
85
99
|
};
|
86
100
|
//# sourceMappingURL=milestone-create-styled.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"milestone-create-styled.js","sources":["../../../../src/features/milestone/create/milestone-create-styled.tsx"],"sourcesContent":["import type { TColorNames } from '../../ui/types';\n\nimport styled from 'styled-components';\n\nimport FlexView from '../../ui/layout/flex-view';\n\ninterface ContainerProps {\n $height?: string | number;\n $minHeight?: string;\n $viewMode: boolean;\n}\n\nconst Container = styled.div<ContainerProps>(\n ({ $height, $viewMode, $minHeight }) => `\n display: flex;\n flex-direction: column;\n height: ${$height ? (typeof $height === 'number' ? `${$height}px` : `${$height}`) : 'auto'};\n min-height: ${$minHeight ? $minHeight : 'auto'};\n ${\n $viewMode\n ? `\n cursor: not-allowed;\n border: 2px solid black;\n border-radius: 8px;\n transform: scale3d(.9943, .9900, 1);\n & ${ContentContainer} {\n pointer-events: auto;\n }\n `\n : ``\n }\n`,\n);\n\nconst BodyContainer = styled.div<{ $viewMode?: boolean }>(\n ({ theme, $viewMode }) => `\n position: relative;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n margin-bottom: ${theme.layout.gutter * 0.5}px;\n border: 1px solid ${theme.colors.GREY_1};\n border-radius: ${theme.layout.gutter * 0.75}px;\n ${\n $viewMode\n ? `\n pointer-events: none;\n // opacity: 0.85;\n `\n : ``\n }\n`,\n);\n\ninterface IContentContainer {\n $overflowHidden?: boolean;\n}\n\nconst ContentContainer = styled.div<IContentContainer>(({ $overflowHidden }) => {\n return `\n flex-grow: 1;\n overflow-y: auto;\n\n ${$overflowHidden && 'overflow: hidden'};\n `;\n});\n\nconst HeaderContainer = styled(FlexView)(({ theme }) => {\n return `\n position: sticky;\n top: 0;\n z-index: 2;\n border-bottom: 1px solid ${theme.colors.WHITE_5};\n `;\n});\n\nconst FooterWrapper = styled(FlexView)(() => {\n return `\n align-self: flex-end;\n position: fixed;\n bottom: 24px;\n right: 24px;\n `;\n});\n\ninterface IRadioCardIconProps {\n $backgroundColor: TColorNames;\n}\n\nconst RadioCardIcon = styled.img<IRadioCardIconProps>(({ theme, $backgroundColor }) => {\n const {\n layout: { gutter },\n colors,\n } = theme;\n\n return `\n width: ${gutter * 6}px;\n height: ${gutter * 6}px;\n background: ${colors[$backgroundColor]};\n border-radius: ${gutter * 0.5}px;\n `;\n});\n\nconst HeaderWrapper = styled(FlexView)<{ $viewMode?: boolean }>(({ theme, $viewMode }) => {\n const {\n layout: { gutter },\n } = theme;\n\n return `\n position:relative;\n min-height:${gutter * 2.75}px;\n ${\n $viewMode\n ? `\n pointer-events: none;\n opacity: 0.85;\n `\n : ``\n }\n`;\n});\n\nconst StepperWrapper = styled.div`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n`;\n\nexport {\n Container,\n BodyContainer,\n ContentContainer,\n HeaderContainer,\n FooterWrapper,\n RadioCardIcon,\n StepperWrapper,\n HeaderWrapper,\n};\n"],"names":["Container","styled","$height","$viewMode","$minHeight","ContentContainer","BodyContainer","theme","$overflowHidden","HeaderContainer","FlexView","FooterWrapper","RadioCardIcon","$backgroundColor","
|
1
|
+
{"version":3,"file":"milestone-create-styled.js","sources":["../../../../src/features/milestone/create/milestone-create-styled.tsx"],"sourcesContent":["import type { TColorNames } from '../../ui/types';\n\nimport styled from 'styled-components';\n\nimport FlexView from '../../ui/layout/flex-view';\n\ninterface ContainerProps {\n $height?: string | number;\n $minHeight?: string;\n $viewMode: boolean;\n}\n\nconst Container = styled.div<ContainerProps>(\n ({ $height, $viewMode, $minHeight }) => `\n display: flex;\n flex-direction: column;\n height: ${$height ? (typeof $height === 'number' ? `${$height}px` : `${$height}`) : 'auto'};\n min-height: ${$minHeight ? $minHeight : 'auto'};\n ${\n $viewMode\n ? `\n cursor: not-allowed;\n border: 2px solid black;\n border-radius: 8px;\n transform: scale3d(.9943, .9900, 1);\n & ${ContentContainer} {\n pointer-events: auto;\n }\n `\n : ``\n }\n`,\n);\n\nconst BodyContainer = styled.div<{ $viewMode?: boolean }>(\n ({ theme, $viewMode }) => `\n position: relative;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n margin-bottom: ${theme.layout.gutter * 0.5}px;\n border: 1px solid ${theme.colors.GREY_1};\n border-radius: ${theme.layout.gutter * 0.75}px;\n ${\n $viewMode\n ? `\n pointer-events: none;\n // opacity: 0.85;\n `\n : ``\n }\n`,\n);\n\ninterface IContentContainer {\n $overflowHidden?: boolean;\n}\n\nconst ContentContainer = styled.div<IContentContainer>(({ $overflowHidden }) => {\n return `\n flex-grow: 1;\n overflow-y: auto;\n\n ${$overflowHidden && 'overflow: hidden'};\n `;\n});\n\nconst HeaderContainer = styled(FlexView)(({ theme }) => {\n return `\n position: sticky;\n top: 0;\n z-index: 2;\n border-bottom: 1px solid ${theme.colors.WHITE_5};\n `;\n});\n\nconst FooterWrapper = styled(FlexView)(() => {\n return `\n align-self: flex-end;\n position: fixed;\n bottom: 24px;\n right: 24px;\n `;\n});\n\nconst BackButtonWrapper = styled.div(({ theme }) => {\n const { gutter } = theme.layout;\n\n return `\n position: absolute;\n top: ${gutter * 2}px;\n left: ${gutter * 1.5}px;\n `;\n});\n\ninterface IRadioCardIconProps {\n $backgroundColor: TColorNames;\n}\n\nconst RadioCardIcon = styled.img<IRadioCardIconProps>(({ theme, $backgroundColor }) => {\n const {\n layout: { gutter },\n colors,\n } = theme;\n\n return `\n width: ${gutter * 6}px;\n height: ${gutter * 6}px;\n background: ${colors[$backgroundColor]};\n border-radius: ${gutter * 0.5}px;\n `;\n});\n\nconst HeaderWrapper = styled(FlexView)<{ $viewMode?: boolean }>(({ theme, $viewMode }) => {\n const {\n layout: { gutter },\n } = theme;\n\n return `\n position:relative;\n min-height:${gutter * 2.75}px;\n ${\n $viewMode\n ? `\n pointer-events: none;\n opacity: 0.85;\n `\n : ``\n }\n`;\n});\n\nconst StepperWrapper = styled.div`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n`;\n\nconst SyncIndicator = styled(FlexView)`\n border-radius: 0 0 8px 8px;\n margin: auto;\n width: 328px;\n`;\n\nexport {\n Container,\n BodyContainer,\n ContentContainer,\n HeaderContainer,\n FooterWrapper,\n BackButtonWrapper,\n RadioCardIcon,\n StepperWrapper,\n HeaderWrapper,\n SyncIndicator,\n};\n"],"names":["Container","styled","$height","$viewMode","$minHeight","ContentContainer","BodyContainer","theme","$overflowHidden","HeaderContainer","FlexView","FooterWrapper","gutter","RadioCardIcon","$backgroundColor","colors","HeaderWrapper","StepperWrapper","SyncIndicator"],"mappings":";;AAYA,MAAMA,IAAYC,EAAO;AAAA,EACvB,CAAC,EAAE,SAAAC,GAAS,WAAAC,GAAW,YAAAC,EAAiB,MAAA;AAAA;AAAA;AAAA,YAG9BF,IAAW,OAAOA,KAAY,WAAW,GAAGA,CAAO,OAAO,GAAGA,CAAO,KAAM,MAAM;AAAA,gBAC5EE,KAA0B,MAAM;AAAA,IAE5CD,IACI;AAAA;AAAA;AAAA;AAAA;AAAA,YAKIE,CAAgB;AAAA;AAAA;AAAA,UAIpB,EACN;AAAA;AAEF,GAEMC,IAAgBL,EAAO;AAAA,EAC3B,CAAC,EAAE,OAAAM,GAAO,WAAAJ,EAAA,MAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKTI,EAAM,OAAO,SAAS,GAAG;AAAA,sBACtBA,EAAM,OAAO,MAAM;AAAA,mBACtBA,EAAM,OAAO,SAAS,IAAI;AAAA,IAEz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1,93 @@
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
2
|
-
import { memo as
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
1
|
+
import { jsx as r, jsxs as I } from "react/jsx-runtime";
|
2
|
+
import { memo as V, useMemo as Y, useEffect as H } from "react";
|
3
|
+
import K from "../../ui/text/text.js";
|
4
|
+
import N from "./milestone-create-components-map.js";
|
5
|
+
import O from "./milestone-create-context.js";
|
6
|
+
import { useFormDataPrefiller as R, useMilestoneFormTree as U, useFormTreeTraversal as W } from "./milestone-create-hooks.js";
|
7
|
+
import { Container as _, SyncIndicator as q, BodyContainer as z } from "./milestone-create-styled.js";
|
8
|
+
const re = V(
|
8
9
|
({
|
9
|
-
studentName:
|
10
|
-
studentId:
|
10
|
+
studentName: $,
|
11
|
+
studentId: v,
|
11
12
|
height: x,
|
12
|
-
minHeight:
|
13
|
-
formData:
|
14
|
-
config:
|
13
|
+
minHeight: M,
|
14
|
+
formData: m,
|
15
|
+
config: c,
|
15
16
|
onChapterExitWarning: h,
|
16
17
|
onFormDataChange: e,
|
17
|
-
onPreSubmit:
|
18
|
-
onExit:
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
onPreSubmit: S,
|
19
|
+
onExit: T,
|
20
|
+
userType: C,
|
21
|
+
board: b,
|
22
|
+
schoolData: w,
|
23
|
+
grade: y,
|
24
|
+
journeysToInclude: D = [],
|
25
|
+
isFirstMilestoneCreated: E = !0,
|
22
26
|
flow: t,
|
23
|
-
milestoneId:
|
27
|
+
milestoneId: j,
|
24
28
|
currentCountryCode: B,
|
25
|
-
isGoalCreation:
|
26
|
-
courseStream:
|
27
|
-
classRatio:
|
29
|
+
isGoalCreation: a,
|
30
|
+
courseStream: F,
|
31
|
+
classRatio: L,
|
28
32
|
enrollmentType: d
|
29
33
|
}) => {
|
30
|
-
const { formDataState: i, setFormData:
|
31
|
-
schoolData:
|
32
|
-
board:
|
33
|
-
grade:
|
34
|
-
config:
|
34
|
+
const { formDataState: i, setFormData: P } = R(m, {
|
35
|
+
schoolData: w,
|
36
|
+
board: b,
|
37
|
+
grade: y,
|
38
|
+
config: c,
|
39
|
+
journeysToInclude: D,
|
35
40
|
flow: t,
|
36
41
|
currentCountryCode: B
|
37
|
-
}),
|
42
|
+
}), g = U({
|
43
|
+
isFirstMilestoneCreated: E,
|
38
44
|
flow: t,
|
39
45
|
formDataState: i,
|
40
|
-
isGoalCreation:
|
41
|
-
}), o = e ? i :
|
46
|
+
isGoalCreation: a
|
47
|
+
}), o = e ? i : m, n = e ? "edit" : "view", u = n === "view", { currentStep: s, updateFormData: k, handleBack: p } = W({
|
42
48
|
flow: t,
|
43
|
-
updatedFormTree:
|
49
|
+
updatedFormTree: g,
|
44
50
|
formData: o,
|
45
51
|
formDataState: i,
|
46
|
-
setFormData:
|
47
|
-
handleExit:
|
48
|
-
}), { name:
|
49
|
-
return
|
52
|
+
setFormData: P,
|
53
|
+
handleExit: T
|
54
|
+
}), { name: l } = s || {}, f = l ? N[l] : void 0, A = Y(() => ({ handleBack: p, mode: n, flow: t }), [p, n, t]);
|
55
|
+
return H(() => {
|
50
56
|
e && e(o);
|
51
|
-
}, [o, e]), /* @__PURE__ */ r(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
57
|
+
}, [o, e]), /* @__PURE__ */ r(O.Provider, { value: A, children: /* @__PURE__ */ I(_, { $height: x, $minHeight: M, $viewMode: u, children: [
|
58
|
+
C === "STUDENT" && /* @__PURE__ */ r(
|
59
|
+
q,
|
60
|
+
{
|
61
|
+
$gutter: 16,
|
62
|
+
$flexDirection: "row",
|
63
|
+
$alignItems: "center",
|
64
|
+
$background: "BLACK",
|
65
|
+
$justifyContent: "center",
|
66
|
+
children: /* @__PURE__ */ r(K, { $color: "YELLOW_4", $renderAs: "eyebrow2", children: "You are viewing your teacher’s screen" })
|
67
|
+
}
|
68
|
+
),
|
69
|
+
/* @__PURE__ */ r(z, { $viewMode: u, children: f && s && d ? /* @__PURE__ */ r(
|
70
|
+
f,
|
71
|
+
{
|
72
|
+
studentName: $,
|
73
|
+
currentStep: s,
|
74
|
+
isGoalCreation: a,
|
75
|
+
config: c,
|
76
|
+
formData: o,
|
77
|
+
onFormDataChange: k,
|
78
|
+
onChapterExitWarning: h,
|
79
|
+
studentId: v,
|
80
|
+
onPreSubmit: S,
|
81
|
+
milestoneId: j,
|
82
|
+
courseStream: F,
|
83
|
+
classRatio: L || 0,
|
84
|
+
enrollmentType: d
|
85
|
+
}
|
86
|
+
) : void 0 })
|
87
|
+
] }) });
|
69
88
|
}
|
70
89
|
);
|
71
90
|
export {
|
72
|
-
|
91
|
+
re as default
|
73
92
|
};
|
74
93
|
//# sourceMappingURL=milestone-create.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"milestone-create.js","sources":["../../../../src/features/milestone/create/milestone-create.tsx"],"sourcesContent":["import type { MileStoneJourneyMode } from './milestone-create-context';\nimport type { IMileStoneCreateProps, IMilestoneFormData } from './milestone-create-types';\n\nimport React, { memo, useEffect, useMemo } from 'react';\n\nimport ComponentsMap from './milestone-create-components-map';\nimport MilestoneCreateContext from './milestone-create-context';\nimport {\n useFormDataPrefiller,\n useFormTreeTraversal,\n useMilestoneFormTree,\n} from './milestone-create-hooks';\nimport { BodyContainer, Container } from './milestone-create-styled';\n\nconst MilestoneCreate: React.FC<IMileStoneCreateProps> = memo(\n ({\n studentName,\n studentId,\n height,\n minHeight,\n formData: formDataProp,\n config,\n onChapterExitWarning,\n onFormDataChange,\n onPreSubmit: handlePreSubmit,\n onExit: handleExit,\n board,\n schoolData,\n grade,\n flow,\n milestoneId,\n currentCountryCode,\n isGoalCreation,\n courseStream,\n classRatio,\n enrollmentType,\n }) => {\n const { formDataState, setFormData } = useFormDataPrefiller(formDataProp, {\n schoolData,\n board,\n grade,\n config,\n flow,\n currentCountryCode,\n });\n\n const updatedFormTree = useMilestoneFormTree({\n flow,\n formDataState,\n isGoalCreation,\n });\n\n const formData = (onFormDataChange ? formDataState : formDataProp) as IMilestoneFormData; //TODO: make better\n\n const mode: MileStoneJourneyMode = onFormDataChange ? 'edit' : 'view';\n const isViewMode = mode === 'view';\n\n const { currentStep, updateFormData, handleBack } = useFormTreeTraversal({\n flow,\n updatedFormTree,\n formData,\n formDataState,\n setFormData,\n handleExit,\n });\n\n const { name } = currentStep || {};\n const StepComponent = name ? ComponentsMap[name] : undefined;\n\n const contextValue = useMemo(() => ({ handleBack, mode, flow }), [handleBack, mode, flow]);\n\n useEffect(() => {\n if (onFormDataChange) {\n onFormDataChange(formData);\n }\n }, [formData, onFormDataChange]);\n\n return (\n <MilestoneCreateContext.Provider value={contextValue}>\n <Container $height={height} $minHeight={minHeight} $viewMode={isViewMode}>\n <BodyContainer $viewMode={isViewMode}>\n {StepComponent && currentStep && enrollmentType ? (\n <StepComponent\n studentName={studentName}\n currentStep={currentStep}\n isGoalCreation={isGoalCreation}\n config={config}\n formData={formData}\n onFormDataChange={updateFormData}\n onChapterExitWarning={onChapterExitWarning}\n studentId={studentId}\n onPreSubmit={handlePreSubmit}\n milestoneId={milestoneId}\n courseStream={courseStream}\n classRatio={classRatio || 0}\n enrollmentType={enrollmentType}\n />\n ) : undefined}\n </BodyContainer>\n </Container>\n </MilestoneCreateContext.Provider>\n );\n },\n);\n\nexport default MilestoneCreate;\n"],"names":["MilestoneCreate","memo","studentName","studentId","height","minHeight","formDataProp","config","onChapterExitWarning","onFormDataChange","handlePreSubmit","handleExit","board","schoolData","grade","flow","milestoneId","currentCountryCode","isGoalCreation","courseStream","classRatio","enrollmentType","formDataState","setFormData","useFormDataPrefiller","updatedFormTree","useMilestoneFormTree","formData","mode","isViewMode","currentStep","updateFormData","handleBack","useFormTreeTraversal","name","StepComponent","ComponentsMap","contextValue","useMemo","useEffect","jsx","MilestoneCreateContext","Container","BodyContainer"],"mappings":"
|
1
|
+
{"version":3,"file":"milestone-create.js","sources":["../../../../src/features/milestone/create/milestone-create.tsx"],"sourcesContent":["import type { MileStoneJourneyMode } from './milestone-create-context';\nimport type { IMileStoneCreateProps, IMilestoneFormData } from './milestone-create-types';\n\nimport React, { memo, useEffect, useMemo } from 'react';\n\nimport Text from '../../ui/text/text';\nimport ComponentsMap from './milestone-create-components-map';\nimport MilestoneCreateContext from './milestone-create-context';\nimport {\n useFormDataPrefiller,\n useFormTreeTraversal,\n useMilestoneFormTree,\n} from './milestone-create-hooks';\nimport { BodyContainer, Container, SyncIndicator } from './milestone-create-styled';\n\nconst MilestoneCreate: React.FC<IMileStoneCreateProps> = memo(\n ({\n studentName,\n studentId,\n height,\n minHeight,\n formData: formDataProp,\n config,\n onChapterExitWarning,\n onFormDataChange,\n onPreSubmit: handlePreSubmit,\n onExit: handleExit,\n userType,\n board,\n schoolData,\n grade,\n journeysToInclude = [],\n isFirstMilestoneCreated = true,\n flow,\n milestoneId,\n currentCountryCode,\n isGoalCreation,\n courseStream,\n classRatio,\n enrollmentType,\n }) => {\n const { formDataState, setFormData } = useFormDataPrefiller(formDataProp, {\n schoolData,\n board,\n grade,\n config,\n journeysToInclude,\n flow,\n currentCountryCode,\n });\n\n const updatedFormTree = useMilestoneFormTree({\n isFirstMilestoneCreated,\n flow,\n formDataState,\n isGoalCreation,\n });\n\n const formData = (onFormDataChange ? formDataState : formDataProp) as IMilestoneFormData; //TODO: make better\n\n const mode: MileStoneJourneyMode = onFormDataChange ? 'edit' : 'view';\n const isViewMode = mode === 'view';\n\n const { currentStep, updateFormData, handleBack } = useFormTreeTraversal({\n flow,\n updatedFormTree,\n formData,\n formDataState,\n setFormData,\n handleExit,\n });\n\n const { name } = currentStep || {};\n const StepComponent = name ? ComponentsMap[name] : undefined;\n\n const contextValue = useMemo(() => ({ handleBack, mode, flow }), [handleBack, mode, flow]);\n\n useEffect(() => {\n if (onFormDataChange) {\n onFormDataChange(formData);\n }\n }, [formData, onFormDataChange]);\n\n return (\n <MilestoneCreateContext.Provider value={contextValue}>\n <Container $height={height} $minHeight={minHeight} $viewMode={isViewMode}>\n {userType === 'STUDENT' && (\n <SyncIndicator\n $gutter={16}\n $flexDirection=\"row\"\n $alignItems=\"center\"\n $background=\"BLACK\"\n $justifyContent=\"center\"\n >\n <Text $color=\"YELLOW_4\" $renderAs=\"eyebrow2\">\n You are viewing your teacher’s screen\n </Text>\n </SyncIndicator>\n )}\n\n <BodyContainer $viewMode={isViewMode}>\n {StepComponent && currentStep && enrollmentType ? (\n <StepComponent\n studentName={studentName}\n currentStep={currentStep}\n isGoalCreation={isGoalCreation}\n config={config}\n formData={formData}\n onFormDataChange={updateFormData}\n onChapterExitWarning={onChapterExitWarning}\n studentId={studentId}\n onPreSubmit={handlePreSubmit}\n milestoneId={milestoneId}\n courseStream={courseStream}\n classRatio={classRatio || 0}\n enrollmentType={enrollmentType}\n />\n ) : undefined}\n </BodyContainer>\n </Container>\n </MilestoneCreateContext.Provider>\n );\n },\n);\n\nexport default MilestoneCreate;\n"],"names":["MilestoneCreate","memo","studentName","studentId","height","minHeight","formDataProp","config","onChapterExitWarning","onFormDataChange","handlePreSubmit","handleExit","userType","board","schoolData","grade","journeysToInclude","isFirstMilestoneCreated","flow","milestoneId","currentCountryCode","isGoalCreation","courseStream","classRatio","enrollmentType","formDataState","setFormData","useFormDataPrefiller","updatedFormTree","useMilestoneFormTree","formData","mode","isViewMode","currentStep","updateFormData","handleBack","useFormTreeTraversal","name","StepComponent","ComponentsMap","contextValue","useMemo","useEffect","jsx","MilestoneCreateContext","jsxs","Container","SyncIndicator","Text","BodyContainer"],"mappings":";;;;;;;AAeA,MAAMA,KAAmDC;AAAA,EACvD,CAAC;AAAA,IACC,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAUC;AAAA,IACV,QAAAC;AAAA,IACA,sBAAA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