@magmamath/students-features 1.3.13 → 1.3.15
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/commonjs/features/pmProgress/components/chart/components/SlicesPaths.js +1 -1
- package/dist/commonjs/features/pmProgress/components/chart/components/SlicesPaths.js.map +1 -1
- package/dist/commonjs/features/pmProgress/components/header/NextUp.js +5 -9
- package/dist/commonjs/features/pmProgress/components/header/NextUp.js.map +1 -1
- package/dist/commonjs/features/pmProgress/components/insights/PmInsights.js +1 -1
- package/dist/commonjs/features/pmProgress/components/insights/PmInsights.js.map +1 -1
- package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js +1 -1
- package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js.map +1 -1
- package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js +8 -3
- package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js.map +1 -1
- package/dist/commonjs/features/pmProgress/hooks/useNextUpDomain.js +42 -0
- package/dist/commonjs/features/pmProgress/hooks/useNextUpDomain.js.map +1 -0
- package/dist/commonjs/features/pmProgress/model/PmTreeModel.js +18 -16
- package/dist/commonjs/features/pmProgress/model/PmTreeModel.js.map +1 -1
- package/dist/commonjs/features/pmProgress/shared/pmProgress.constants.js +1 -1
- package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js +6 -2
- package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +37 -32
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
- package/dist/module/features/pmProgress/components/chart/components/SlicesPaths.js +1 -1
- package/dist/module/features/pmProgress/components/chart/components/SlicesPaths.js.map +1 -1
- package/dist/module/features/pmProgress/components/header/NextUp.js +6 -10
- package/dist/module/features/pmProgress/components/header/NextUp.js.map +1 -1
- package/dist/module/features/pmProgress/components/insights/PmInsights.js +1 -1
- package/dist/module/features/pmProgress/components/insights/PmInsights.js.map +1 -1
- package/dist/module/features/pmProgress/components/list/PmDomainList.js +1 -1
- package/dist/module/features/pmProgress/components/list/PmDomainList.js.map +1 -1
- package/dist/module/features/pmProgress/components/standard/StandardTag.js +8 -3
- package/dist/module/features/pmProgress/components/standard/StandardTag.js.map +1 -1
- package/dist/module/features/pmProgress/hooks/useNextUpDomain.js +37 -0
- package/dist/module/features/pmProgress/hooks/useNextUpDomain.js.map +1 -0
- package/dist/module/features/pmProgress/model/PmTreeModel.js +20 -18
- package/dist/module/features/pmProgress/model/PmTreeModel.js.map +1 -1
- package/dist/module/features/pmProgress/shared/pmProgress.constants.js +1 -1
- package/dist/module/features/pmProgress/shared/pmProgress.helpers.js +2 -0
- package/dist/module/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js +37 -32
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/components/header/NextUp.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/components/standard/StandardTag.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/hooks/useNextUpDomain.d.ts +5 -0
- package/dist/typescript/commonjs/features/pmProgress/hooks/useNextUpDomain.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/model/PmTreeModel.d.ts +3 -3
- package/dist/typescript/commonjs/features/pmProgress/model/PmTreeModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.constants.d.ts +1 -1
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts +4 -0
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/components/header/NextUp.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/components/standard/StandardTag.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/hooks/useNextUpDomain.d.ts +5 -0
- package/dist/typescript/module/features/pmProgress/hooks/useNextUpDomain.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/model/PmTreeModel.d.ts +3 -3
- package/dist/typescript/module/features/pmProgress/model/PmTreeModel.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.constants.d.ts +1 -1
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.constants.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts +4 -0
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/pmProgress/components/chart/components/SlicesPaths.tsx +1 -1
- package/src/features/pmProgress/components/header/NextUp.tsx +6 -13
- package/src/features/pmProgress/components/insights/PmInsights.tsx +1 -1
- package/src/features/pmProgress/components/list/PmDomainList.tsx +1 -1
- package/src/features/pmProgress/components/standard/StandardTag.tsx +4 -3
- package/src/features/pmProgress/hooks/useNextUpDomain.ts +31 -0
- package/src/features/pmProgress/model/PmTreeModel.ts +26 -17
- package/src/features/pmProgress/shared/pmProgress.constants.ts +1 -1
- package/src/features/pmProgress/shared/pmProgress.helpers.ts +11 -0
- package/src/features/voice/recording/components/VoiceRecordButton.tsx +49 -42
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attach, createEffect, createEvent, createStore, restore, sample } from 'effector'
|
|
1
|
+
import { attach, combine, createEffect, createEvent, createStore, restore, sample } from 'effector'
|
|
2
2
|
import { createAction } from 'effector-action'
|
|
3
3
|
import {
|
|
4
4
|
Domain,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getInitialPmGrade,
|
|
19
19
|
getTreeGrades,
|
|
20
20
|
isTreeDataReady,
|
|
21
|
+
isTreeDataWithoutGradeReady,
|
|
21
22
|
} from '../shared/pmProgress.helpers'
|
|
22
23
|
import { TreeNormalizer } from '../shared/TreeNormalizer'
|
|
23
24
|
import { persist } from 'effector-storage/session'
|
|
@@ -30,12 +31,14 @@ export class PmTreeModel {
|
|
|
30
31
|
private readonly $user = createStore<User | null>(null)
|
|
31
32
|
|
|
32
33
|
private readonly setupInitialGrade = createEvent<SetupInitialGradeProps>()
|
|
33
|
-
private readonly setDomains = createEvent<Domain[]>()
|
|
34
34
|
public readonly setGrade = createEvent<number | null>()
|
|
35
35
|
|
|
36
36
|
public readonly $isInitialized = createStore(false)
|
|
37
37
|
public readonly $grade = restore(this.setGrade, null)
|
|
38
|
-
public readonly $domains =
|
|
38
|
+
public readonly $domains = createStore<Record<number, Domain[]>>({})
|
|
39
|
+
public readonly $domainsInGrade = combine(this.$domains, this.$grade, (domains, grade) =>
|
|
40
|
+
grade !== null ? (domains[grade] ?? []) : [],
|
|
41
|
+
)
|
|
39
42
|
public readonly $grades = createStore<Grade[]>([])
|
|
40
43
|
public readonly $status = createStore<PmProgressStatus | null>(null)
|
|
41
44
|
|
|
@@ -48,7 +51,7 @@ export class PmTreeModel {
|
|
|
48
51
|
this.setupFailedAndLockedStatus()
|
|
49
52
|
this.setupTreeInit()
|
|
50
53
|
this.setupGradeInit()
|
|
51
|
-
this.
|
|
54
|
+
this.setupDomainsInTree()
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
public readonly initTreeFx = createEffect(async ({ user }: PmProgressGateProps) => {
|
|
@@ -150,22 +153,28 @@ export class PmTreeModel {
|
|
|
150
153
|
})
|
|
151
154
|
}
|
|
152
155
|
|
|
153
|
-
private
|
|
156
|
+
private setupDomainsInTree() {
|
|
154
157
|
sample({
|
|
155
|
-
clock:
|
|
156
|
-
source: { tree: this.$tree, stats: this.$stats, user: this.$user
|
|
157
|
-
filter:
|
|
158
|
-
fn: ({ tree, stats, user
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
grade
|
|
158
|
+
clock: this.initTreeFx.doneData,
|
|
159
|
+
source: { tree: this.$tree, stats: this.$stats, user: this.$user },
|
|
160
|
+
filter: isTreeDataWithoutGradeReady,
|
|
161
|
+
fn: ({ tree, stats, user }) => {
|
|
162
|
+
const treeNodes = Object.values(tree.treeMapping)
|
|
163
|
+
const grades = getTreeGrades(tree, user).filter((g) => !g.isLocked)
|
|
164
|
+
|
|
165
|
+
return Object.fromEntries(
|
|
166
|
+
grades.map((grade) => {
|
|
167
|
+
const [treeWithStats] = enhanceProgressMatrixData(
|
|
168
|
+
treeNodes,
|
|
169
|
+
stats,
|
|
170
|
+
[{ entityId: user._id, name: user.fullName }],
|
|
171
|
+
grade.value,
|
|
172
|
+
)
|
|
173
|
+
return [grade.value, getDomainStructure(treeWithStats, tree.treeMapping)]
|
|
174
|
+
}),
|
|
164
175
|
)
|
|
165
|
-
|
|
166
|
-
return getDomainStructure(treeWithUserStats, tree.treeMapping)
|
|
167
176
|
},
|
|
168
|
-
target: this
|
|
177
|
+
target: this.$domains,
|
|
169
178
|
})
|
|
170
179
|
}
|
|
171
180
|
}
|
|
@@ -171,6 +171,14 @@ type TreeDataReady = {
|
|
|
171
171
|
export const isTreeDataReady = (source: TreeDataSource): source is TreeDataReady =>
|
|
172
172
|
source.tree !== null && source.stats !== null && source.user !== null && source.grade !== null
|
|
173
173
|
|
|
174
|
+
type TreeDataWithoutGrade = Omit<TreeDataSource, 'grade'>
|
|
175
|
+
type TreeDataWithoutGradeReady = Omit<TreeDataReady, 'grade'>
|
|
176
|
+
|
|
177
|
+
export const isTreeDataWithoutGradeReady = (
|
|
178
|
+
source: TreeDataWithoutGrade,
|
|
179
|
+
): source is TreeDataWithoutGradeReady =>
|
|
180
|
+
source.tree !== null && source.stats !== null && source.user !== null
|
|
181
|
+
|
|
174
182
|
export const createChartConfig = (size: number): PieChartManagerConfig => {
|
|
175
183
|
const OUTER_MARGIN = 5
|
|
176
184
|
return {
|
|
@@ -261,6 +269,9 @@ export const withoutDuplicates = (skills: (Skill | undefined)[]): Skill[] => {
|
|
|
261
269
|
})
|
|
262
270
|
}
|
|
263
271
|
|
|
272
|
+
export const findDomainBySkillId = (skillId: string, domains: Domain[]): Domain | undefined =>
|
|
273
|
+
domains.find((d) => d.standards.some((s) => s.skillIds.includes(skillId)))
|
|
274
|
+
|
|
264
275
|
// Reorders grades starting from the given grade, wrapping around. [1,2,3] with start=2 → [2,3,1]
|
|
265
276
|
export const startGradesFrom = (grades: Grade[], startGrade: number): Grade[] => {
|
|
266
277
|
const index = grades.findIndex(({ value }) => value === startGrade)
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
IS_WEB,
|
|
13
13
|
MicrophoneIcon,
|
|
14
14
|
} from '@magmamath/react-native-ui'
|
|
15
|
-
import { Pressable, StyleSheet
|
|
15
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
16
16
|
import { VoiceRecordModel } from '../model/VoiceRecord.model'
|
|
17
17
|
import { useUnit } from 'effector-react'
|
|
18
18
|
import { VOICE_RECORD_SHADOWS, VoiceRecorderState } from '../../constants'
|
|
@@ -31,6 +31,51 @@ const defaultButtonStyles: ButtonStyle = {
|
|
|
31
31
|
},
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
type AdvancedButtonProps = {
|
|
35
|
+
isRecording: boolean
|
|
36
|
+
disabled: boolean
|
|
37
|
+
onPressIn: () => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const AdvancedButton = ({ isRecording, disabled, onPressIn }: AdvancedButtonProps) => {
|
|
41
|
+
return (
|
|
42
|
+
<Pressable
|
|
43
|
+
style={[styles.advancedButtonContainer, disabled && styles.disabledCursor]}
|
|
44
|
+
onPressIn={onPressIn}
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
>
|
|
47
|
+
<Button
|
|
48
|
+
customColorScheme={{
|
|
49
|
+
[ButtonStates.ACTIVE]: {
|
|
50
|
+
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
51
|
+
borderColor: COLORS.PRIMARY_BLUE,
|
|
52
|
+
raiseColor: COLORS.PRIMARY_BLUE,
|
|
53
|
+
color: COLORS.PRIMARY_BLUE,
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
style={{
|
|
57
|
+
button: styles.advancedButton,
|
|
58
|
+
}}
|
|
59
|
+
isActive={isRecording}
|
|
60
|
+
variant={ButtonVariant.TERTIARY}
|
|
61
|
+
onPressIn={onPressIn}
|
|
62
|
+
icon={
|
|
63
|
+
isRecording ? (
|
|
64
|
+
<CheckIcon size={25} color={COLORS.NEUTRAL_1} />
|
|
65
|
+
) : (
|
|
66
|
+
<MicrophoneIcon
|
|
67
|
+
style={styles.advancedMicrophoneIcon}
|
|
68
|
+
color={
|
|
69
|
+
disabled ? COLORS.NEUTRAL_5 : isRecording ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_9
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
</Pressable>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
34
79
|
export const VoiceRecordButton = ({ model, buttonVariant }: VoiceRecordButtonProps) => {
|
|
35
80
|
const t = useText()
|
|
36
81
|
|
|
@@ -40,7 +85,6 @@ export const VoiceRecordButton = ({ model, buttonVariant }: VoiceRecordButtonPro
|
|
|
40
85
|
const isInitializing = useUnit(model.initializeRecording.pending)
|
|
41
86
|
|
|
42
87
|
const isRecording = voiceRecordState === VoiceRecorderState.RECORDING
|
|
43
|
-
const isIdle = voiceRecordState === VoiceRecorderState.IDLE
|
|
44
88
|
const hasInputs = availableInputs.length > 0
|
|
45
89
|
|
|
46
90
|
return (
|
|
@@ -56,7 +100,6 @@ export const VoiceRecordButton = ({ model, buttonVariant }: VoiceRecordButtonPro
|
|
|
56
100
|
{buttonVariant === RecordButtonVariant.ADVANCED ? (
|
|
57
101
|
<AdvancedButton
|
|
58
102
|
isRecording={isRecording}
|
|
59
|
-
isIdle={isIdle}
|
|
60
103
|
disabled={isButtonDisabled}
|
|
61
104
|
onPressIn={() => model.recorderButtonHandler()}
|
|
62
105
|
/>
|
|
@@ -83,45 +126,6 @@ export const VoiceRecordButton = ({ model, buttonVariant }: VoiceRecordButtonPro
|
|
|
83
126
|
)
|
|
84
127
|
}
|
|
85
128
|
|
|
86
|
-
type AdvancedButtonProps = {
|
|
87
|
-
isRecording: boolean
|
|
88
|
-
isIdle: boolean
|
|
89
|
-
disabled: boolean
|
|
90
|
-
onPressIn: () => void
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const AdvancedButton = ({ isRecording, isIdle, disabled, onPressIn }: AdvancedButtonProps) => (
|
|
94
|
-
<Pressable
|
|
95
|
-
style={[styles.advancedButtonContainer, disabled && styles.disabledCursor]}
|
|
96
|
-
onPressIn={onPressIn}
|
|
97
|
-
disabled={disabled}
|
|
98
|
-
>
|
|
99
|
-
<Button
|
|
100
|
-
customColorScheme={{
|
|
101
|
-
[ButtonStates.ACTIVE]: {
|
|
102
|
-
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
103
|
-
borderColor: COLORS.PRIMARY_BLUE,
|
|
104
|
-
raiseColor: COLORS.PRIMARY_BLUE,
|
|
105
|
-
color: COLORS.PRIMARY_BLUE,
|
|
106
|
-
},
|
|
107
|
-
}}
|
|
108
|
-
isActive={isRecording}
|
|
109
|
-
variant={ButtonVariant.TERTIARY}
|
|
110
|
-
onPressIn={onPressIn}
|
|
111
|
-
icon={
|
|
112
|
-
isRecording ? (
|
|
113
|
-
<CheckIcon size={25} color={COLORS.NEUTRAL_1} />
|
|
114
|
-
) : (
|
|
115
|
-
<MicrophoneIcon
|
|
116
|
-
style={styles.advancedMicrophoneIcon}
|
|
117
|
-
color={disabled ? COLORS.NEUTRAL_5 : isIdle ? COLORS.NEUTRAL_9 : COLORS.NEUTRAL_1}
|
|
118
|
-
/>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
/>
|
|
122
|
-
</Pressable>
|
|
123
|
-
)
|
|
124
|
-
|
|
125
129
|
const styles = StyleSheet.create({
|
|
126
130
|
advancedButtonContainer: {
|
|
127
131
|
width: 52,
|
|
@@ -158,4 +162,7 @@ const styles = StyleSheet.create({
|
|
|
158
162
|
width: 14,
|
|
159
163
|
height: 19,
|
|
160
164
|
},
|
|
165
|
+
advancedButton: {
|
|
166
|
+
boxShadow: 'none',
|
|
167
|
+
},
|
|
161
168
|
})
|