@cuemath/leap 2.8.22 → 2.8.23
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 +0 -12
- package/dist/assets/images/images.js.map +1 -1
- package/dist/features/chapters/chapter/chapter.js +43 -45
- package/dist/features/chapters/chapter/chapter.js.map +1 -1
- package/dist/features/chapters/chapter/comps/core-lessons/core-lessons.js +21 -23
- package/dist/features/chapters/chapter/comps/core-lessons/core-lessons.js.map +1 -1
- package/dist/features/milestone/constants.js +18 -53
- package/dist/features/milestone/constants.js.map +1 -1
- package/dist/features/milestone/create/comps/chapters-selection-step/chapters-selection-step-styled.js +4 -16
- 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 +47 -56
- package/dist/features/milestone/create/milestone-create-container.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-helpers.js +113 -132
- package/dist/features/milestone/create/milestone-create-helpers.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-hooks.js +90 -92
- package/dist/features/milestone/create/milestone-create-hooks.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-styled.js +20 -34
- package/dist/features/milestone/create/milestone-create-styled.js.map +1 -1
- package/dist/features/milestone/create/milestone-create.js +53 -72
- package/dist/features/milestone/create/milestone-create.js.map +1 -1
- package/dist/features/milestone/create/submit-modal/use-submit-milestone.js +46 -53
- 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/edit/comps/delete-milestone/styled.js +8 -11
- package/dist/features/milestone/edit/comps/delete-milestone/styled.js.map +1 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone.js +82 -79
- 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 +112 -136
- package/dist/features/milestone/edit/comps/edit-milestone-modal/index.js.map +1 -1
- package/dist/features/milestone/{drafts/goal-edit → edit/goal-drafts}/goal-draft-edit-container.js +22 -24
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-container.js.map +1 -0
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-helpers.js +17 -0
- package/dist/features/milestone/edit/goal-drafts/goal-draft-edit-helpers.js.map +1 -0
- package/dist/features/milestone/edit/goal-edit-helpers.js +5 -6
- package/dist/features/milestone/edit/goal-edit-helpers.js.map +1 -1
- package/dist/features/milestone/edit/milestone-edit-helpers.js +16 -17
- package/dist/features/milestone/edit/milestone-edit-helpers.js.map +1 -1
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-list.js +46 -48
- 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 +58 -60
- 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 +39 -41
- package/dist/features/milestone/outcome/comps/past-milestone/past-milestone-container.js.map +1 -1
- package/dist/index.d.ts +7 -125
- package/dist/index.js +244 -258
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/constants/urls.js +0 -5
- package/dist/constants/urls.js.map +0 -1
- package/dist/features/milestone/drafts/create/draft-create-container.js +0 -54
- package/dist/features/milestone/drafts/create/draft-create-container.js.map +0 -1
- package/dist/features/milestone/drafts/edit/draft-edit-container.js +0 -77
- package/dist/features/milestone/drafts/edit/draft-edit-container.js.map +0 -1
- package/dist/features/milestone/drafts/edit/draft-edit-helpers.js +0 -69
- package/dist/features/milestone/drafts/edit/draft-edit-helpers.js.map +0 -1
- package/dist/features/milestone/drafts/goal-edit/goal-draft-edit-container.js.map +0 -1
- package/dist/features/milestone/drafts/review/draft-review-container.js +0 -76
- package/dist/features/milestone/drafts/review/draft-review-container.js.map +0 -1
- package/dist/features/milestone/edit/comps/delete-milestone/add-remove-nudge.js +0 -48
- package/dist/features/milestone/edit/comps/delete-milestone/add-remove-nudge.js.map +0 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone-modal-styled.js +0 -23
- package/dist/features/milestone/edit/comps/edit-milestone-modal/edit-milestone-modal-styled.js.map +0 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/share-screen.js +0 -68
- package/dist/features/milestone/edit/comps/edit-milestone-modal/share-screen.js.map +0 -1
- package/dist/features/milestone/help-modals/index.js +0 -22
- package/dist/features/milestone/help-modals/index.js.map +0 -1
- package/dist/features/milestone/help-modals/milestone-lesson.js +0 -17
- package/dist/features/milestone/help-modals/milestone-lesson.js.map +0 -1
- package/dist/features/milestone/help-modals/milestone-list.js +0 -17
- package/dist/features/milestone/help-modals/milestone-list.js.map +0 -1
- package/dist/features/milestone/help-modals/utils.js +0 -20
- package/dist/features/milestone/help-modals/utils.js.map +0 -1
- package/dist/features/milestone/intro-modal/index.js +0 -24
- package/dist/features/milestone/intro-modal/index.js.map +0 -1
- package/dist/features/notifications/api/notification.js +0 -13
- package/dist/features/notifications/api/notification.js.map +0 -1
- package/dist/features/notifications/use-student-journey.js +0 -20
- package/dist/features/notifications/use-student-journey.js.map +0 -1
- package/dist/features/sheets/constants/lessons.js +0 -28
- package/dist/features/sheets/constants/lessons.js.map +0 -1
- package/dist/features/ui/modals/info-modal/index.js +0 -117
- package/dist/features/ui/modals/info-modal/index.js.map +0 -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
@@ -1,144 +1,142 @@
|
|
1
|
-
import { useState as P, useMemo as
|
2
|
-
import j from "../../notifications/use-student-journey.js";
|
1
|
+
import { useState as P, useMemo as w, useRef as B, useCallback as N } from "react";
|
3
2
|
import { TEST_TYPE_TO_TEST_NAME as v } from "../constants.js";
|
4
|
-
import { checkIfCommittedFieldIsUpdated as
|
5
|
-
import { GOAL_EDIT_FLOWS as p, BRANCHING_FIELDS as
|
6
|
-
import
|
3
|
+
import { checkIfCommittedFieldIsUpdated as k } from "../edit/goal-edit-helpers.js";
|
4
|
+
import { GOAL_EDIT_FLOWS as p, BRANCHING_FIELDS as F } from "./milestone-create-constants.js";
|
5
|
+
import W, { CHAPTERS_SELECTION_FORM_TREE as j, ADD_CUSTOM_CHAPTERS as H, SET_COMPLETION_DATE as y } from "./milestone-create-form-tree.js";
|
7
6
|
import { appendSchoolDataToFormState as V, generateFormStateWithPrefilledSchoolData as Y, getCurrenStep as h, clearNextFields as q } from "./milestone-create-helpers.js";
|
8
|
-
const
|
9
|
-
schoolData:
|
10
|
-
board:
|
11
|
-
grade:
|
7
|
+
const $ = (l, {
|
8
|
+
schoolData: c,
|
9
|
+
board: t,
|
10
|
+
grade: r,
|
12
11
|
currentCountryCode: T,
|
13
|
-
flow:
|
12
|
+
flow: d
|
14
13
|
}) => {
|
15
|
-
const [
|
14
|
+
const [m, o] = P(() => l && p.includes(d) ? V(l, c, t, r) : {
|
16
15
|
...Y(
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
c,
|
17
|
+
t,
|
18
|
+
r,
|
20
19
|
T
|
21
20
|
)
|
22
21
|
});
|
23
|
-
return { formDataState:
|
24
|
-
},
|
25
|
-
flow:
|
26
|
-
formDataState:
|
27
|
-
isGoalCreation:
|
22
|
+
return { formDataState: m, setFormData: o };
|
23
|
+
}, x = ({
|
24
|
+
flow: l,
|
25
|
+
formDataState: c,
|
26
|
+
isGoalCreation: t
|
28
27
|
}) => {
|
29
|
-
const { testType:
|
30
|
-
return
|
31
|
-
if (p.includes(
|
32
|
-
const
|
33
|
-
...
|
28
|
+
const { testType: r } = c;
|
29
|
+
return w(() => {
|
30
|
+
if (p.includes(l) && r) {
|
31
|
+
const d = {
|
32
|
+
...j,
|
34
33
|
isRootNode: !0,
|
35
|
-
title: v[
|
36
|
-
},
|
37
|
-
return
|
34
|
+
title: v[r]
|
35
|
+
}, m = Object.assign({}, H), o = Object.assign({}, y);
|
36
|
+
return t || (m.buttonLabel = "Add to learning plan", d.buttonLabel = "Update"), l === "EDIT" && (o.buttonLabel = "Update goal"), (!t || r === "no-test") && (d.next = [m, o]), d;
|
38
37
|
}
|
39
|
-
return
|
40
|
-
}, [
|
41
|
-
},
|
42
|
-
flow:
|
43
|
-
updatedFormTree:
|
44
|
-
formData:
|
45
|
-
formDataState:
|
38
|
+
return W;
|
39
|
+
}, [l, r, t]);
|
40
|
+
}, a = ({
|
41
|
+
flow: l,
|
42
|
+
updatedFormTree: c,
|
43
|
+
formData: t,
|
44
|
+
formDataState: r,
|
46
45
|
setFormData: T,
|
47
|
-
handleExit:
|
46
|
+
handleExit: d
|
48
47
|
}) => {
|
49
|
-
const
|
50
|
-
() => h(
|
51
|
-
[
|
52
|
-
), O =
|
53
|
-
(
|
54
|
-
T((
|
55
|
-
const S =
|
56
|
-
if (p.includes(
|
57
|
-
const
|
58
|
-
...
|
59
|
-
...
|
48
|
+
const m = B(r), o = (t == null ? void 0 : t.currentFlow) ?? l, i = w(
|
49
|
+
() => h(c, t, o),
|
50
|
+
[c, t, o]
|
51
|
+
), O = i == null ? void 0 : i.name, b = !!(i != null && i.isRootNode), E = N(
|
52
|
+
(e) => {
|
53
|
+
T((s) => {
|
54
|
+
const S = s.testType;
|
55
|
+
if (p.includes(o)) {
|
56
|
+
const A = {
|
57
|
+
...s.committed,
|
58
|
+
...e.committed
|
60
59
|
}, C = [];
|
61
|
-
if (Object.entries((
|
62
|
-
const
|
63
|
-
if (
|
64
|
-
field:
|
65
|
-
isFieldCommited:
|
66
|
-
prevFormData:
|
67
|
-
newValueOfField:
|
68
|
-
formDataStateRef:
|
60
|
+
if (Object.entries((e == null ? void 0 : e.committed) || {}).forEach((R) => {
|
61
|
+
const n = R[0], U = !!R[1], M = e[n] ?? s[n];
|
62
|
+
if (k({
|
63
|
+
field: n,
|
64
|
+
isFieldCommited: U,
|
65
|
+
prevFormData: s,
|
66
|
+
newValueOfField: M,
|
67
|
+
formDataStateRef: m.current
|
69
68
|
})) {
|
70
69
|
let _ = [];
|
71
|
-
S && S === "no-test" && (_ = _.concat(["board"])), _.includes(
|
70
|
+
S && S === "no-test" && (_ = _.concat(["board"])), _.includes(n) || C.push(n);
|
72
71
|
}
|
73
|
-
}), C.length > 0 && C.some((
|
74
|
-
const
|
75
|
-
|
76
|
-
|
72
|
+
}), C.length > 0 && C.some((n) => F.includes(n))) {
|
73
|
+
const n = q(
|
74
|
+
c,
|
75
|
+
s,
|
77
76
|
O,
|
78
|
-
|
77
|
+
b,
|
79
78
|
[]
|
80
79
|
);
|
81
|
-
if (
|
80
|
+
if (n)
|
82
81
|
return {
|
83
|
-
...
|
84
|
-
...
|
82
|
+
...n,
|
83
|
+
...e,
|
85
84
|
committed: {
|
86
|
-
...
|
87
|
-
...
|
85
|
+
...n.committed,
|
86
|
+
...e.committed
|
88
87
|
},
|
89
88
|
reviewed: {
|
90
|
-
...
|
89
|
+
...A
|
91
90
|
},
|
92
91
|
currentFlow: "CREATE"
|
93
92
|
};
|
94
93
|
}
|
95
94
|
return {
|
96
|
-
...
|
97
|
-
...
|
95
|
+
...s,
|
96
|
+
...e,
|
98
97
|
committed: {
|
99
|
-
...
|
100
|
-
...
|
98
|
+
...s.committed,
|
99
|
+
...e.committed
|
101
100
|
},
|
102
|
-
reviewed:
|
101
|
+
reviewed: A
|
103
102
|
};
|
104
103
|
}
|
105
|
-
const { committed:
|
104
|
+
const { committed: u, reviewed: f, ...L } = s;
|
106
105
|
return {
|
107
106
|
...L,
|
108
|
-
...
|
107
|
+
...e,
|
109
108
|
committed: {
|
110
|
-
...
|
111
|
-
...
|
109
|
+
...u,
|
110
|
+
...e.committed
|
112
111
|
},
|
113
112
|
reviewed: {}
|
114
113
|
};
|
115
114
|
});
|
116
115
|
},
|
117
|
-
[T,
|
118
|
-
),
|
119
|
-
if (
|
120
|
-
const { reset:
|
116
|
+
[T, o, c, O, b]
|
117
|
+
), I = N(() => {
|
118
|
+
if (i) {
|
119
|
+
const { reset: e, rollback: s, isRootNode: S } = i;
|
121
120
|
if (S) {
|
122
|
-
|
121
|
+
d == null || d();
|
123
122
|
return;
|
124
123
|
}
|
125
|
-
const
|
124
|
+
const u = {
|
126
125
|
committed: {},
|
127
126
|
reviewed: {}
|
128
127
|
};
|
129
|
-
p.includes(
|
130
|
-
|
131
|
-
}) :
|
132
|
-
|
133
|
-
}), E(
|
128
|
+
p.includes(o) ? s.forEach((f) => {
|
129
|
+
u.reviewed[f] = void 0;
|
130
|
+
}) : e.forEach((f) => (u[f] = void 0, !0)), s.forEach((f) => {
|
131
|
+
u.committed[f] = void 0;
|
132
|
+
}), E(u);
|
134
133
|
}
|
135
|
-
}, [
|
136
|
-
return { currentStep:
|
134
|
+
}, [i, o, E, d]);
|
135
|
+
return { currentStep: i, updateFormData: E, handleBack: I };
|
137
136
|
};
|
138
137
|
export {
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
g as useMilestoneInfoTransitionsControl
|
138
|
+
$ as useFormDataPrefiller,
|
139
|
+
a as useFormTreeTraversal,
|
140
|
+
x as useMilestoneFormTree
|
143
141
|
};
|
144
142
|
//# 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 { 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,EAAa,cAAc,WAGzBf,MAAS,WACXoB,EAAkB,cAAc,iBAG9B,CAACR,KAAkBC,MAAa,eACrBE,EAAA,OAAO,CAACG,GAAkBE,CAAiB,IAGnDL;AAAA,IACT;AAEO,WAAAO;AAAA,EAC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,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
|
+
{"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,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,GAKMK,IAAuB,CAAC;AAAA,EAC5B,MAAAP;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAO;AACF,MAIM;AACE,QAAA,EAAE,UAAAC,EAAa,IAAAR;AAkCd,SAhC4BS,EAAQ,MAAM;AAC/C,QAAIN,EAAgB,SAASJ,CAAI,KAAKS,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,EAAa,cAAc,WAGzBX,MAAS,WAC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B,GAAY;AACD,QAAA9B,KAAA,QAAAA;AAEb;AAAA,MACF;AAEA,YAAM+B,IAA2B;AAAA,QAC/B,WAAW,CAAC;AAAA,QACZ,UAAU,CAAC;AAAA,MAAA;AAGb,MAAKjD,EAAgB,SAASqB,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 l = r.div(
|
4
|
+
({ $height: o, $viewMode: e, $minHeight: t }) => `
|
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: ${t || "auto"};
|
9
|
+
${e ? `
|
10
10
|
cursor: not-allowed;
|
11
11
|
border: 2px solid black;
|
12
12
|
border-radius: 8px;
|
@@ -16,8 +16,8 @@ const d = r.div(
|
|
16
16
|
}
|
17
17
|
` : ""}
|
18
18
|
`
|
19
|
-
),
|
20
|
-
({ theme: o, $viewMode:
|
19
|
+
), d = r.div(
|
20
|
+
({ theme: o, $viewMode: e }) => `
|
21
21
|
position: relative;
|
22
22
|
display: flex;
|
23
23
|
flex-direction: column;
|
@@ -25,7 +25,7 @@ const d = 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
|
+
${e ? `
|
29
29
|
pointer-events: none;
|
30
30
|
// opacity: 0.85;
|
31
31
|
` : ""}
|
@@ -45,34 +45,25 @@ const d = r.div(
|
|
45
45
|
position: fixed;
|
46
46
|
bottom: 24px;
|
47
47
|
right: 24px;
|
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 }) => {
|
48
|
+
`), x = r.img(({ theme: o, $backgroundColor: e }) => {
|
58
49
|
const {
|
59
|
-
layout: { gutter:
|
50
|
+
layout: { gutter: t },
|
60
51
|
colors: i
|
61
52
|
} = o;
|
62
53
|
return `
|
63
|
-
width: ${
|
64
|
-
height: ${
|
65
|
-
background: ${i[
|
66
|
-
border-radius: ${
|
54
|
+
width: ${t * 6}px;
|
55
|
+
height: ${t * 6}px;
|
56
|
+
background: ${i[e]};
|
57
|
+
border-radius: ${t * 0.5}px;
|
67
58
|
`;
|
68
|
-
}), f = r(n)(({ theme: o, $viewMode:
|
59
|
+
}), f = r(n)(({ theme: o, $viewMode: e }) => {
|
69
60
|
const {
|
70
|
-
layout: { gutter:
|
61
|
+
layout: { gutter: t }
|
71
62
|
} = o;
|
72
63
|
return `
|
73
64
|
position:relative;
|
74
|
-
min-height:${
|
75
|
-
${
|
65
|
+
min-height:${t * 2.75}px;
|
66
|
+
${e ? `
|
76
67
|
pointer-events: none;
|
77
68
|
opacity: 0.85;
|
78
69
|
` : ""}
|
@@ -81,20 +72,15 @@ const x = r.img(({ theme: o, $backgroundColor: t }) => {
|
|
81
72
|
position: absolute;
|
82
73
|
left: 50%;
|
83
74
|
transform: translateX(-50%);
|
84
|
-
`, b = r(n)`
|
85
|
-
border-radius: 0 0 8px 8px;
|
86
|
-
margin: auto;
|
87
|
-
width: 328px;
|
88
75
|
`;
|
89
76
|
export {
|
90
|
-
|
91
|
-
|
77
|
+
d as BodyContainer,
|
78
|
+
l as Container,
|
92
79
|
a as ContentContainer,
|
93
80
|
c as FooterWrapper,
|
94
81
|
u as HeaderContainer,
|
95
82
|
f as HeaderWrapper,
|
96
83
|
x as RadioCardIcon,
|
97
|
-
$ as StepperWrapper
|
98
|
-
b as SyncIndicator
|
84
|
+
$ as StepperWrapper
|
99
85
|
};
|
100
86
|
//# 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\
|
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","gutter","colors","HeaderWrapper","StepperWrapper"],"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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IA,EACN;AAAA;AAEJ,CAAC,GAEKc,IAAiBhB,EAAO;AAAA;AAAA;AAAA;AAAA;"}
|
@@ -1,93 +1,74 @@
|
|
1
|
-
import { jsx as r
|
2
|
-
import { memo as
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
8
|
-
const re = V(
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
2
|
+
import { memo as H, useMemo as R, useEffect as q } from "react";
|
3
|
+
import y from "./milestone-create-components-map.js";
|
4
|
+
import z from "./milestone-create-context.js";
|
5
|
+
import { useFormDataPrefiller as A, useMilestoneFormTree as I, useFormTreeTraversal as J } from "./milestone-create-hooks.js";
|
6
|
+
import { Container as K, BodyContainer as L } from "./milestone-create-styled.js";
|
7
|
+
const Y = H(
|
9
8
|
({
|
10
|
-
studentName:
|
11
|
-
studentId:
|
9
|
+
studentName: M,
|
10
|
+
studentId: l,
|
12
11
|
height: x,
|
13
|
-
minHeight:
|
14
|
-
formData:
|
15
|
-
config:
|
12
|
+
minHeight: S,
|
13
|
+
formData: n,
|
14
|
+
config: a,
|
16
15
|
onChapterExitWarning: h,
|
17
16
|
onFormDataChange: e,
|
18
|
-
onPreSubmit:
|
19
|
-
onExit:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
grade: y,
|
24
|
-
journeysToInclude: D = [],
|
25
|
-
isFirstMilestoneCreated: E = !0,
|
17
|
+
onPreSubmit: $,
|
18
|
+
onExit: C,
|
19
|
+
board: F,
|
20
|
+
schoolData: P,
|
21
|
+
grade: T,
|
26
22
|
flow: t,
|
27
|
-
milestoneId:
|
23
|
+
milestoneId: b,
|
28
24
|
currentCountryCode: B,
|
29
|
-
isGoalCreation:
|
30
|
-
courseStream:
|
31
|
-
classRatio:
|
25
|
+
isGoalCreation: c,
|
26
|
+
courseStream: D,
|
27
|
+
classRatio: E,
|
32
28
|
enrollmentType: d
|
33
29
|
}) => {
|
34
|
-
const { formDataState: i, setFormData:
|
35
|
-
schoolData:
|
36
|
-
board:
|
37
|
-
grade:
|
38
|
-
config:
|
39
|
-
journeysToInclude: D,
|
30
|
+
const { formDataState: i, setFormData: V } = A(n, {
|
31
|
+
schoolData: P,
|
32
|
+
board: F,
|
33
|
+
grade: T,
|
34
|
+
config: a,
|
40
35
|
flow: t,
|
41
36
|
currentCountryCode: B
|
42
|
-
}),
|
43
|
-
isFirstMilestoneCreated: E,
|
37
|
+
}), j = I({
|
44
38
|
flow: t,
|
45
39
|
formDataState: i,
|
46
|
-
isGoalCreation:
|
47
|
-
}), o = e ? i :
|
40
|
+
isGoalCreation: c
|
41
|
+
}), o = e ? i : n, m = e ? "edit" : "view", u = m === "view", { currentStep: s, updateFormData: k, handleBack: p } = J({
|
48
42
|
flow: t,
|
49
|
-
updatedFormTree:
|
43
|
+
updatedFormTree: j,
|
50
44
|
formData: o,
|
51
45
|
formDataState: i,
|
52
|
-
setFormData:
|
53
|
-
handleExit:
|
54
|
-
}), { name:
|
55
|
-
return
|
46
|
+
setFormData: V,
|
47
|
+
handleExit: C
|
48
|
+
}), { name: v } = s || {}, f = v ? y[v] : void 0, w = R(() => ({ handleBack: p, mode: m, flow: t }), [p, m, t]);
|
49
|
+
return q(() => {
|
56
50
|
e && e(o);
|
57
|
-
}, [o, e]), /* @__PURE__ */ r(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
] }) });
|
51
|
+
}, [o, e]), /* @__PURE__ */ r(z.Provider, { value: w, children: /* @__PURE__ */ r(K, { $height: x, $minHeight: S, $viewMode: u, children: /* @__PURE__ */ r(L, { $viewMode: u, children: f && s && d ? /* @__PURE__ */ r(
|
52
|
+
f,
|
53
|
+
{
|
54
|
+
studentName: M,
|
55
|
+
currentStep: s,
|
56
|
+
isGoalCreation: c,
|
57
|
+
config: a,
|
58
|
+
formData: o,
|
59
|
+
onFormDataChange: k,
|
60
|
+
onChapterExitWarning: h,
|
61
|
+
studentId: l,
|
62
|
+
onPreSubmit: $,
|
63
|
+
milestoneId: b,
|
64
|
+
courseStream: D,
|
65
|
+
classRatio: E || 0,
|
66
|
+
enrollmentType: d
|
67
|
+
}
|
68
|
+
) : void 0 }) }) });
|
88
69
|
}
|
89
70
|
);
|
90
71
|
export {
|
91
|
-
|
72
|
+
Y as default
|
92
73
|
};
|
93
74
|
//# 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
|
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":";;;;;;AAcA,MAAMA,IAAmDC;AAAA,EACvD,CAAC;AAAA,IACC,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAUC;AAAA,IACV,QAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,aAAaC;AAAA,IACb,QAAQC;AAAA,IACR,OAAAC;AAAA,IACA,YAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,aAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,gBAAAC;AAAA,EAAA,MACI;AACJ,UAAM,EAAE,eAAAC,GAAe,aAAAC,MAAgBC,EAAqBlB,GAAc;AAAA,MACxE,YAAAO;AAAA,MACA,OAAAD;AAAA,MACA,OAAAE;AAAA,MACA,QAAAP;AAAA,MACA,MAAAQ;AAAA,MACA,oBAAAE;AAAA,IAAA,CACD,GAEKQ,IAAkBC,EAAqB;AAAA,MAC3C,MAAAX;AAAA,MACA,eAAAO;AAAA,MACA,gBAAAJ;AAAA,IAAA,CACD,GAEKS,IAAYlB,IAAmBa,IAAgBhB,GAE/CsB,IAA6BnB,IAAmB,SAAS,QACzDoB,IAAaD,MAAS,QAEtB,EAAE,aAAAE,GAAa,gBAAAC,GAAgB,YAAAC,EAAA,IAAeC,EAAqB;AAAA,MACvE,MAAAlB;AAAA,MACA,iBAAAU;AAAA,MACA,UAAAE;AAAA,MACA,eAAAL;AAAA,MACA,aAAAC;AAAA,MACA,YAAAZ;AAAA,IAAA,C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