@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.
Files changed (71) hide show
  1. package/dist/commonjs/features/pmProgress/components/chart/components/SlicesPaths.js +1 -1
  2. package/dist/commonjs/features/pmProgress/components/chart/components/SlicesPaths.js.map +1 -1
  3. package/dist/commonjs/features/pmProgress/components/header/NextUp.js +5 -9
  4. package/dist/commonjs/features/pmProgress/components/header/NextUp.js.map +1 -1
  5. package/dist/commonjs/features/pmProgress/components/insights/PmInsights.js +1 -1
  6. package/dist/commonjs/features/pmProgress/components/insights/PmInsights.js.map +1 -1
  7. package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js +1 -1
  8. package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js.map +1 -1
  9. package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js +8 -3
  10. package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js.map +1 -1
  11. package/dist/commonjs/features/pmProgress/hooks/useNextUpDomain.js +42 -0
  12. package/dist/commonjs/features/pmProgress/hooks/useNextUpDomain.js.map +1 -0
  13. package/dist/commonjs/features/pmProgress/model/PmTreeModel.js +18 -16
  14. package/dist/commonjs/features/pmProgress/model/PmTreeModel.js.map +1 -1
  15. package/dist/commonjs/features/pmProgress/shared/pmProgress.constants.js +1 -1
  16. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js +6 -2
  17. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  18. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +37 -32
  19. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
  20. package/dist/module/features/pmProgress/components/chart/components/SlicesPaths.js +1 -1
  21. package/dist/module/features/pmProgress/components/chart/components/SlicesPaths.js.map +1 -1
  22. package/dist/module/features/pmProgress/components/header/NextUp.js +6 -10
  23. package/dist/module/features/pmProgress/components/header/NextUp.js.map +1 -1
  24. package/dist/module/features/pmProgress/components/insights/PmInsights.js +1 -1
  25. package/dist/module/features/pmProgress/components/insights/PmInsights.js.map +1 -1
  26. package/dist/module/features/pmProgress/components/list/PmDomainList.js +1 -1
  27. package/dist/module/features/pmProgress/components/list/PmDomainList.js.map +1 -1
  28. package/dist/module/features/pmProgress/components/standard/StandardTag.js +8 -3
  29. package/dist/module/features/pmProgress/components/standard/StandardTag.js.map +1 -1
  30. package/dist/module/features/pmProgress/hooks/useNextUpDomain.js +37 -0
  31. package/dist/module/features/pmProgress/hooks/useNextUpDomain.js.map +1 -0
  32. package/dist/module/features/pmProgress/model/PmTreeModel.js +20 -18
  33. package/dist/module/features/pmProgress/model/PmTreeModel.js.map +1 -1
  34. package/dist/module/features/pmProgress/shared/pmProgress.constants.js +1 -1
  35. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js +2 -0
  36. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  37. package/dist/module/features/voice/recording/components/VoiceRecordButton.js +37 -32
  38. package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -1
  39. package/dist/typescript/commonjs/features/pmProgress/components/header/NextUp.d.ts.map +1 -1
  40. package/dist/typescript/commonjs/features/pmProgress/components/standard/StandardTag.d.ts.map +1 -1
  41. package/dist/typescript/commonjs/features/pmProgress/hooks/useNextUpDomain.d.ts +5 -0
  42. package/dist/typescript/commonjs/features/pmProgress/hooks/useNextUpDomain.d.ts.map +1 -0
  43. package/dist/typescript/commonjs/features/pmProgress/model/PmTreeModel.d.ts +3 -3
  44. package/dist/typescript/commonjs/features/pmProgress/model/PmTreeModel.d.ts.map +1 -1
  45. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.constants.d.ts +1 -1
  46. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.constants.d.ts.map +1 -1
  47. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts +4 -0
  48. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  49. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
  50. package/dist/typescript/module/features/pmProgress/components/header/NextUp.d.ts.map +1 -1
  51. package/dist/typescript/module/features/pmProgress/components/standard/StandardTag.d.ts.map +1 -1
  52. package/dist/typescript/module/features/pmProgress/hooks/useNextUpDomain.d.ts +5 -0
  53. package/dist/typescript/module/features/pmProgress/hooks/useNextUpDomain.d.ts.map +1 -0
  54. package/dist/typescript/module/features/pmProgress/model/PmTreeModel.d.ts +3 -3
  55. package/dist/typescript/module/features/pmProgress/model/PmTreeModel.d.ts.map +1 -1
  56. package/dist/typescript/module/features/pmProgress/shared/pmProgress.constants.d.ts +1 -1
  57. package/dist/typescript/module/features/pmProgress/shared/pmProgress.constants.d.ts.map +1 -1
  58. package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts +4 -0
  59. package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  60. package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/features/pmProgress/components/chart/components/SlicesPaths.tsx +1 -1
  63. package/src/features/pmProgress/components/header/NextUp.tsx +6 -13
  64. package/src/features/pmProgress/components/insights/PmInsights.tsx +1 -1
  65. package/src/features/pmProgress/components/list/PmDomainList.tsx +1 -1
  66. package/src/features/pmProgress/components/standard/StandardTag.tsx +4 -3
  67. package/src/features/pmProgress/hooks/useNextUpDomain.ts +31 -0
  68. package/src/features/pmProgress/model/PmTreeModel.ts +26 -17
  69. package/src/features/pmProgress/shared/pmProgress.constants.ts +1 -1
  70. package/src/features/pmProgress/shared/pmProgress.helpers.ts +11 -0
  71. 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 = restore(this.setDomains, [])
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.setupDomainStructure()
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 setupDomainStructure() {
156
+ private setupDomainsInTree() {
154
157
  sample({
155
- clock: [this.$grade, this.initTreeFx.doneData],
156
- source: { tree: this.$tree, stats: this.$stats, user: this.$user, grade: this.$grade },
157
- filter: isTreeDataReady,
158
- fn: ({ tree, stats, user, grade }) => {
159
- const [treeWithUserStats] = enhanceProgressMatrixData(
160
- Object.values(tree.treeMapping),
161
- stats,
162
- [{ entityId: user._id, name: user.fullName }],
163
- grade as number,
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.setDomains,
177
+ target: this.$domains,
169
178
  })
170
179
  }
171
180
  }
@@ -35,7 +35,7 @@ export enum PmProgressStatus {
35
35
  export enum SessionStorageKeys {
36
36
  SOLVING_QUEUE = 'PM_SOLVING_QUEUE',
37
37
  GRADE = 'PM_GRADE',
38
- DOMAINS = 'PM_DOMAINS',
38
+ DOMAINS = 'PM_DOMAINS_IN_TREE',
39
39
  }
40
40
 
41
41
  /**
@@ -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, View } from 'react-native'
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
  })