@magmamath/students-features 1.8.4 → 1.8.6-rc.1

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 (260) hide show
  1. package/dist/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
  2. package/dist/commonjs/features/profile/Profile.js +90 -0
  3. package/dist/commonjs/features/profile/Profile.js.map +1 -0
  4. package/dist/commonjs/features/profile/components/actions/ProfileActions.js +70 -0
  5. package/dist/commonjs/features/profile/components/actions/ProfileActions.js.map +1 -0
  6. package/dist/commonjs/features/profile/components/cards/ProfileCard.js +57 -0
  7. package/dist/commonjs/features/profile/components/cards/ProfileCard.js.map +1 -0
  8. package/dist/commonjs/features/profile/components/info/AccountInfoCard.js +91 -0
  9. package/dist/commonjs/features/profile/components/info/AccountInfoCard.js.map +1 -0
  10. package/dist/commonjs/features/profile/components/modals/JoinClassModal.js +190 -0
  11. package/dist/commonjs/features/profile/components/modals/JoinClassModal.js.map +1 -0
  12. package/dist/commonjs/features/profile/components/modals/LogoutConfirmModal.js +61 -0
  13. package/dist/commonjs/features/profile/components/modals/LogoutConfirmModal.js.map +1 -0
  14. package/dist/commonjs/features/profile/components/modals/TranslationLanguageModal.js +128 -0
  15. package/dist/commonjs/features/profile/components/modals/TranslationLanguageModal.js.map +1 -0
  16. package/dist/commonjs/features/profile/components/settings/LanguageSettingsCard.js +22 -0
  17. package/dist/commonjs/features/profile/components/settings/LanguageSettingsCard.js.map +1 -0
  18. package/dist/commonjs/features/profile/components/settings/PreferencesCard.js +69 -0
  19. package/dist/commonjs/features/profile/components/settings/PreferencesCard.js.map +1 -0
  20. package/dist/commonjs/features/profile/components/settings/SettingRow.js +48 -0
  21. package/dist/commonjs/features/profile/components/settings/SettingRow.js.map +1 -0
  22. package/dist/commonjs/features/profile/components/settings/TextSettingsCard.js +77 -0
  23. package/dist/commonjs/features/profile/components/settings/TextSettingsCard.js.map +1 -0
  24. package/dist/commonjs/features/profile/components/settings/TextSizeSlider.js +119 -0
  25. package/dist/commonjs/features/profile/components/settings/TextSizeSlider.js.map +1 -0
  26. package/dist/commonjs/features/profile/components/settings/TextToSpeechRow.js +37 -0
  27. package/dist/commonjs/features/profile/components/settings/TextToSpeechRow.js.map +1 -0
  28. package/dist/commonjs/features/profile/components/settings/TranslationLanguageRow.js +62 -0
  29. package/dist/commonjs/features/profile/components/settings/TranslationLanguageRow.js.map +1 -0
  30. package/dist/commonjs/features/profile/context/ProfileContext.js +18 -0
  31. package/dist/commonjs/features/profile/context/ProfileContext.js.map +1 -0
  32. package/dist/commonjs/features/profile/index.js +80 -0
  33. package/dist/commonjs/features/profile/index.js.map +1 -0
  34. package/dist/commonjs/features/profile/model/ProfileApi.js +15 -0
  35. package/dist/commonjs/features/profile/model/ProfileApi.js.map +1 -0
  36. package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js +60 -0
  37. package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js.map +1 -0
  38. package/dist/commonjs/features/profile/model/ProfileLanguageModel.js +30 -0
  39. package/dist/commonjs/features/profile/model/ProfileLanguageModel.js.map +1 -0
  40. package/dist/commonjs/features/profile/model/ProfileModel.js +53 -0
  41. package/dist/commonjs/features/profile/model/ProfileModel.js.map +1 -0
  42. package/dist/commonjs/features/profile/model/profileModal.types.js +6 -0
  43. package/dist/commonjs/features/profile/model/profileModal.types.js.map +1 -0
  44. package/dist/commonjs/features/profile/shared/JoinClassError.js +16 -0
  45. package/dist/commonjs/features/profile/shared/JoinClassError.js.map +1 -0
  46. package/dist/commonjs/features/profile/shared/profile.constants.js +29 -0
  47. package/dist/commonjs/features/profile/shared/profile.constants.js.map +1 -0
  48. package/dist/commonjs/features/profile/shared/profile.helpers.js +40 -0
  49. package/dist/commonjs/features/profile/shared/profile.helpers.js.map +1 -0
  50. package/dist/commonjs/features/profile/shared/profile.types.js +6 -0
  51. package/dist/commonjs/features/profile/shared/profile.types.js.map +1 -0
  52. package/dist/commonjs/index.js +12 -0
  53. package/dist/commonjs/index.js.map +1 -1
  54. package/dist/commonjs/shared/hooks/useKeyboardOffset.js +54 -0
  55. package/dist/commonjs/shared/hooks/useKeyboardOffset.js.map +1 -0
  56. package/dist/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
  57. package/dist/module/features/profile/Profile.js +84 -0
  58. package/dist/module/features/profile/Profile.js.map +1 -0
  59. package/dist/module/features/profile/components/actions/ProfileActions.js +64 -0
  60. package/dist/module/features/profile/components/actions/ProfileActions.js.map +1 -0
  61. package/dist/module/features/profile/components/cards/ProfileCard.js +51 -0
  62. package/dist/module/features/profile/components/cards/ProfileCard.js.map +1 -0
  63. package/dist/module/features/profile/components/info/AccountInfoCard.js +85 -0
  64. package/dist/module/features/profile/components/info/AccountInfoCard.js.map +1 -0
  65. package/dist/module/features/profile/components/modals/JoinClassModal.js +183 -0
  66. package/dist/module/features/profile/components/modals/JoinClassModal.js.map +1 -0
  67. package/dist/module/features/profile/components/modals/LogoutConfirmModal.js +55 -0
  68. package/dist/module/features/profile/components/modals/LogoutConfirmModal.js.map +1 -0
  69. package/dist/module/features/profile/components/modals/TranslationLanguageModal.js +122 -0
  70. package/dist/module/features/profile/components/modals/TranslationLanguageModal.js.map +1 -0
  71. package/dist/module/features/profile/components/settings/LanguageSettingsCard.js +16 -0
  72. package/dist/module/features/profile/components/settings/LanguageSettingsCard.js.map +1 -0
  73. package/dist/module/features/profile/components/settings/PreferencesCard.js +63 -0
  74. package/dist/module/features/profile/components/settings/PreferencesCard.js.map +1 -0
  75. package/dist/module/features/profile/components/settings/SettingRow.js +42 -0
  76. package/dist/module/features/profile/components/settings/SettingRow.js.map +1 -0
  77. package/dist/module/features/profile/components/settings/TextSettingsCard.js +71 -0
  78. package/dist/module/features/profile/components/settings/TextSettingsCard.js.map +1 -0
  79. package/dist/module/features/profile/components/settings/TextSizeSlider.js +112 -0
  80. package/dist/module/features/profile/components/settings/TextSizeSlider.js.map +1 -0
  81. package/dist/module/features/profile/components/settings/TextToSpeechRow.js +31 -0
  82. package/dist/module/features/profile/components/settings/TextToSpeechRow.js.map +1 -0
  83. package/dist/module/features/profile/components/settings/TranslationLanguageRow.js +56 -0
  84. package/dist/module/features/profile/components/settings/TranslationLanguageRow.js.map +1 -0
  85. package/dist/module/features/profile/context/ProfileContext.js +13 -0
  86. package/dist/module/features/profile/context/ProfileContext.js.map +1 -0
  87. package/dist/module/features/profile/index.js +11 -0
  88. package/dist/module/features/profile/index.js.map +1 -0
  89. package/dist/module/features/profile/model/ProfileApi.js +10 -0
  90. package/dist/module/features/profile/model/ProfileApi.js.map +1 -0
  91. package/dist/module/features/profile/model/ProfileJoinClassModel.js +55 -0
  92. package/dist/module/features/profile/model/ProfileJoinClassModel.js.map +1 -0
  93. package/dist/module/features/profile/model/ProfileLanguageModel.js +25 -0
  94. package/dist/module/features/profile/model/ProfileLanguageModel.js.map +1 -0
  95. package/dist/module/features/profile/model/ProfileModel.js +48 -0
  96. package/dist/module/features/profile/model/ProfileModel.js.map +1 -0
  97. package/dist/module/features/profile/model/profileModal.types.js +4 -0
  98. package/dist/module/features/profile/model/profileModal.types.js.map +1 -0
  99. package/dist/module/features/profile/shared/JoinClassError.js +11 -0
  100. package/dist/module/features/profile/shared/JoinClassError.js.map +1 -0
  101. package/dist/module/features/profile/shared/profile.constants.js +25 -0
  102. package/dist/module/features/profile/shared/profile.constants.js.map +1 -0
  103. package/dist/module/features/profile/shared/profile.helpers.js +32 -0
  104. package/dist/module/features/profile/shared/profile.helpers.js.map +1 -0
  105. package/dist/module/features/profile/shared/profile.types.js +4 -0
  106. package/dist/module/features/profile/shared/profile.types.js.map +1 -0
  107. package/dist/module/index.js +1 -0
  108. package/dist/module/index.js.map +1 -1
  109. package/dist/module/shared/hooks/useKeyboardOffset.js +49 -0
  110. package/dist/module/shared/hooks/useKeyboardOffset.js.map +1 -0
  111. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.d.ts.map +1 -1
  112. package/dist/typescript/commonjs/features/profile/Profile.d.ts +6 -0
  113. package/dist/typescript/commonjs/features/profile/Profile.d.ts.map +1 -0
  114. package/dist/typescript/commonjs/features/profile/__tests__/ProfileModel.test.d.ts +2 -0
  115. package/dist/typescript/commonjs/features/profile/__tests__/ProfileModel.test.d.ts.map +1 -0
  116. package/dist/typescript/commonjs/features/profile/__tests__/profile.helpers.test.d.ts +2 -0
  117. package/dist/typescript/commonjs/features/profile/__tests__/profile.helpers.test.d.ts.map +1 -0
  118. package/dist/typescript/commonjs/features/profile/components/actions/ProfileActions.d.ts +3 -0
  119. package/dist/typescript/commonjs/features/profile/components/actions/ProfileActions.d.ts.map +1 -0
  120. package/dist/typescript/commonjs/features/profile/components/cards/ProfileCard.d.ts +10 -0
  121. package/dist/typescript/commonjs/features/profile/components/cards/ProfileCard.d.ts.map +1 -0
  122. package/dist/typescript/commonjs/features/profile/components/info/AccountInfoCard.d.ts +3 -0
  123. package/dist/typescript/commonjs/features/profile/components/info/AccountInfoCard.d.ts.map +1 -0
  124. package/dist/typescript/commonjs/features/profile/components/modals/JoinClassModal.d.ts +4 -0
  125. package/dist/typescript/commonjs/features/profile/components/modals/JoinClassModal.d.ts.map +1 -0
  126. package/dist/typescript/commonjs/features/profile/components/modals/LogoutConfirmModal.d.ts +4 -0
  127. package/dist/typescript/commonjs/features/profile/components/modals/LogoutConfirmModal.d.ts.map +1 -0
  128. package/dist/typescript/commonjs/features/profile/components/modals/TranslationLanguageModal.d.ts +4 -0
  129. package/dist/typescript/commonjs/features/profile/components/modals/TranslationLanguageModal.d.ts.map +1 -0
  130. package/dist/typescript/commonjs/features/profile/components/settings/LanguageSettingsCard.d.ts +3 -0
  131. package/dist/typescript/commonjs/features/profile/components/settings/LanguageSettingsCard.d.ts.map +1 -0
  132. package/dist/typescript/commonjs/features/profile/components/settings/PreferencesCard.d.ts +3 -0
  133. package/dist/typescript/commonjs/features/profile/components/settings/PreferencesCard.d.ts.map +1 -0
  134. package/dist/typescript/commonjs/features/profile/components/settings/SettingRow.d.ts +11 -0
  135. package/dist/typescript/commonjs/features/profile/components/settings/SettingRow.d.ts.map +1 -0
  136. package/dist/typescript/commonjs/features/profile/components/settings/TextSettingsCard.d.ts +3 -0
  137. package/dist/typescript/commonjs/features/profile/components/settings/TextSettingsCard.d.ts.map +1 -0
  138. package/dist/typescript/commonjs/features/profile/components/settings/TextSizeSlider.d.ts +8 -0
  139. package/dist/typescript/commonjs/features/profile/components/settings/TextSizeSlider.d.ts.map +1 -0
  140. package/dist/typescript/commonjs/features/profile/components/settings/TextToSpeechRow.d.ts +3 -0
  141. package/dist/typescript/commonjs/features/profile/components/settings/TextToSpeechRow.d.ts.map +1 -0
  142. package/dist/typescript/commonjs/features/profile/components/settings/TranslationLanguageRow.d.ts +3 -0
  143. package/dist/typescript/commonjs/features/profile/components/settings/TranslationLanguageRow.d.ts.map +1 -0
  144. package/dist/typescript/commonjs/features/profile/context/ProfileContext.d.ts +13 -0
  145. package/dist/typescript/commonjs/features/profile/context/ProfileContext.d.ts.map +1 -0
  146. package/dist/typescript/commonjs/features/profile/index.d.ts +12 -0
  147. package/dist/typescript/commonjs/features/profile/index.d.ts.map +1 -0
  148. package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts +11 -0
  149. package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts.map +1 -0
  150. package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts +14 -0
  151. package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -0
  152. package/dist/typescript/commonjs/features/profile/model/ProfileLanguageModel.d.ts +13 -0
  153. package/dist/typescript/commonjs/features/profile/model/ProfileLanguageModel.d.ts.map +1 -0
  154. package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts +26 -0
  155. package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts.map +1 -0
  156. package/dist/typescript/commonjs/features/profile/model/profileModal.types.d.ts +14 -0
  157. package/dist/typescript/commonjs/features/profile/model/profileModal.types.d.ts.map +1 -0
  158. package/dist/typescript/commonjs/features/profile/shared/JoinClassError.d.ts +5 -0
  159. package/dist/typescript/commonjs/features/profile/shared/JoinClassError.d.ts.map +1 -0
  160. package/dist/typescript/commonjs/features/profile/shared/profile.constants.d.ts +20 -0
  161. package/dist/typescript/commonjs/features/profile/shared/profile.constants.d.ts.map +1 -0
  162. package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts +6 -0
  163. package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts.map +1 -0
  164. package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts +27 -0
  165. package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts.map +1 -0
  166. package/dist/typescript/commonjs/index.d.ts +1 -0
  167. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  168. package/dist/typescript/commonjs/shared/hooks/useKeyboardOffset.d.ts +11 -0
  169. package/dist/typescript/commonjs/shared/hooks/useKeyboardOffset.d.ts.map +1 -0
  170. package/dist/typescript/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.d.ts.map +1 -1
  171. package/dist/typescript/module/features/profile/Profile.d.ts +6 -0
  172. package/dist/typescript/module/features/profile/Profile.d.ts.map +1 -0
  173. package/dist/typescript/module/features/profile/__tests__/ProfileModel.test.d.ts +2 -0
  174. package/dist/typescript/module/features/profile/__tests__/ProfileModel.test.d.ts.map +1 -0
  175. package/dist/typescript/module/features/profile/__tests__/profile.helpers.test.d.ts +2 -0
  176. package/dist/typescript/module/features/profile/__tests__/profile.helpers.test.d.ts.map +1 -0
  177. package/dist/typescript/module/features/profile/components/actions/ProfileActions.d.ts +3 -0
  178. package/dist/typescript/module/features/profile/components/actions/ProfileActions.d.ts.map +1 -0
  179. package/dist/typescript/module/features/profile/components/cards/ProfileCard.d.ts +10 -0
  180. package/dist/typescript/module/features/profile/components/cards/ProfileCard.d.ts.map +1 -0
  181. package/dist/typescript/module/features/profile/components/info/AccountInfoCard.d.ts +3 -0
  182. package/dist/typescript/module/features/profile/components/info/AccountInfoCard.d.ts.map +1 -0
  183. package/dist/typescript/module/features/profile/components/modals/JoinClassModal.d.ts +4 -0
  184. package/dist/typescript/module/features/profile/components/modals/JoinClassModal.d.ts.map +1 -0
  185. package/dist/typescript/module/features/profile/components/modals/LogoutConfirmModal.d.ts +4 -0
  186. package/dist/typescript/module/features/profile/components/modals/LogoutConfirmModal.d.ts.map +1 -0
  187. package/dist/typescript/module/features/profile/components/modals/TranslationLanguageModal.d.ts +4 -0
  188. package/dist/typescript/module/features/profile/components/modals/TranslationLanguageModal.d.ts.map +1 -0
  189. package/dist/typescript/module/features/profile/components/settings/LanguageSettingsCard.d.ts +3 -0
  190. package/dist/typescript/module/features/profile/components/settings/LanguageSettingsCard.d.ts.map +1 -0
  191. package/dist/typescript/module/features/profile/components/settings/PreferencesCard.d.ts +3 -0
  192. package/dist/typescript/module/features/profile/components/settings/PreferencesCard.d.ts.map +1 -0
  193. package/dist/typescript/module/features/profile/components/settings/SettingRow.d.ts +11 -0
  194. package/dist/typescript/module/features/profile/components/settings/SettingRow.d.ts.map +1 -0
  195. package/dist/typescript/module/features/profile/components/settings/TextSettingsCard.d.ts +3 -0
  196. package/dist/typescript/module/features/profile/components/settings/TextSettingsCard.d.ts.map +1 -0
  197. package/dist/typescript/module/features/profile/components/settings/TextSizeSlider.d.ts +8 -0
  198. package/dist/typescript/module/features/profile/components/settings/TextSizeSlider.d.ts.map +1 -0
  199. package/dist/typescript/module/features/profile/components/settings/TextToSpeechRow.d.ts +3 -0
  200. package/dist/typescript/module/features/profile/components/settings/TextToSpeechRow.d.ts.map +1 -0
  201. package/dist/typescript/module/features/profile/components/settings/TranslationLanguageRow.d.ts +3 -0
  202. package/dist/typescript/module/features/profile/components/settings/TranslationLanguageRow.d.ts.map +1 -0
  203. package/dist/typescript/module/features/profile/context/ProfileContext.d.ts +13 -0
  204. package/dist/typescript/module/features/profile/context/ProfileContext.d.ts.map +1 -0
  205. package/dist/typescript/module/features/profile/index.d.ts +12 -0
  206. package/dist/typescript/module/features/profile/index.d.ts.map +1 -0
  207. package/dist/typescript/module/features/profile/model/ProfileApi.d.ts +11 -0
  208. package/dist/typescript/module/features/profile/model/ProfileApi.d.ts.map +1 -0
  209. package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts +14 -0
  210. package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -0
  211. package/dist/typescript/module/features/profile/model/ProfileLanguageModel.d.ts +13 -0
  212. package/dist/typescript/module/features/profile/model/ProfileLanguageModel.d.ts.map +1 -0
  213. package/dist/typescript/module/features/profile/model/ProfileModel.d.ts +26 -0
  214. package/dist/typescript/module/features/profile/model/ProfileModel.d.ts.map +1 -0
  215. package/dist/typescript/module/features/profile/model/profileModal.types.d.ts +14 -0
  216. package/dist/typescript/module/features/profile/model/profileModal.types.d.ts.map +1 -0
  217. package/dist/typescript/module/features/profile/shared/JoinClassError.d.ts +5 -0
  218. package/dist/typescript/module/features/profile/shared/JoinClassError.d.ts.map +1 -0
  219. package/dist/typescript/module/features/profile/shared/profile.constants.d.ts +20 -0
  220. package/dist/typescript/module/features/profile/shared/profile.constants.d.ts.map +1 -0
  221. package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts +6 -0
  222. package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts.map +1 -0
  223. package/dist/typescript/module/features/profile/shared/profile.types.d.ts +27 -0
  224. package/dist/typescript/module/features/profile/shared/profile.types.d.ts.map +1 -0
  225. package/dist/typescript/module/index.d.ts +1 -0
  226. package/dist/typescript/module/index.d.ts.map +1 -1
  227. package/dist/typescript/module/shared/hooks/useKeyboardOffset.d.ts +11 -0
  228. package/dist/typescript/module/shared/hooks/useKeyboardOffset.d.ts.map +1 -0
  229. package/package.json +4 -2
  230. package/src/features/chatbot/components/ChatInput/FreeText/ChatTextInput.tsx +0 -1
  231. package/src/features/profile/Profile.tsx +83 -0
  232. package/src/features/profile/__tests__/ProfileModel.test.ts +99 -0
  233. package/src/features/profile/__tests__/profile.helpers.test.ts +57 -0
  234. package/src/features/profile/components/actions/ProfileActions.tsx +68 -0
  235. package/src/features/profile/components/cards/ProfileCard.tsx +53 -0
  236. package/src/features/profile/components/info/AccountInfoCard.tsx +74 -0
  237. package/src/features/profile/components/modals/JoinClassModal.tsx +180 -0
  238. package/src/features/profile/components/modals/LogoutConfirmModal.tsx +64 -0
  239. package/src/features/profile/components/modals/TranslationLanguageModal.tsx +126 -0
  240. package/src/features/profile/components/settings/LanguageSettingsCard.tsx +16 -0
  241. package/src/features/profile/components/settings/PreferencesCard.tsx +67 -0
  242. package/src/features/profile/components/settings/SettingRow.tsx +42 -0
  243. package/src/features/profile/components/settings/TextSettingsCard.tsx +64 -0
  244. package/src/features/profile/components/settings/TextSizeSlider.tsx +117 -0
  245. package/src/features/profile/components/settings/TextToSpeechRow.tsx +29 -0
  246. package/src/features/profile/components/settings/TranslationLanguageRow.tsx +60 -0
  247. package/src/features/profile/context/ProfileContext.tsx +24 -0
  248. package/src/features/profile/index.ts +11 -0
  249. package/src/features/profile/model/ProfileApi.ts +23 -0
  250. package/src/features/profile/model/ProfileJoinClassModel.ts +58 -0
  251. package/src/features/profile/model/ProfileLanguageModel.ts +26 -0
  252. package/src/features/profile/model/ProfileModel.ts +57 -0
  253. package/src/features/profile/model/profileModal.types.ts +16 -0
  254. package/src/features/profile/shared/JoinClassError.ts +7 -0
  255. package/src/features/profile/shared/profile.constants.ts +23 -0
  256. package/src/features/profile/shared/profile.helpers.ts +36 -0
  257. package/src/features/profile/shared/profile.types.ts +34 -0
  258. package/src/i18n/.generated/schema.json +9 -1
  259. package/src/index.ts +1 -0
  260. package/src/shared/hooks/useKeyboardOffset.ts +57 -0
@@ -0,0 +1,58 @@
1
+ import { createEffect, createEvent, restore, sample } from 'effector'
2
+
3
+ import { JoinClassError } from '../shared/JoinClassError'
4
+ import { CLASS_CODE_LENGTH, JoinClassStatus } from '../shared/profile.constants'
5
+ import { getJoinClassErrorMessage, getJoinClassSuccessMessage } from '../shared/profile.helpers'
6
+ import type { NotifyJoinClass } from '../shared/profile.types'
7
+ import type { ProfileApi } from './ProfileApi'
8
+
9
+ export class ProfileJoinClassModel {
10
+ public readonly reset = createEvent()
11
+ public readonly setCode = createEvent<string>()
12
+ public readonly submit = createEvent()
13
+
14
+ public readonly $code = restore(this.setCode, '').reset(this.reset)
15
+ public readonly $isComplete = this.$code.map((code) => code.length === CLASS_CODE_LENGTH)
16
+
17
+ constructor(
18
+ private readonly api: ProfileApi,
19
+ private readonly notify: NotifyJoinClass
20
+ ) {
21
+ this.init()
22
+ }
23
+
24
+ private init() {
25
+ const notifyFx = createEffect(this.notify)
26
+
27
+ sample({
28
+ clock: this.submit,
29
+ source: this.$code,
30
+ filter: (code) => code.length === CLASS_CODE_LENGTH,
31
+ fn: (classCode) => ({ classCode }),
32
+ target: this.api.joinClassFx,
33
+ })
34
+
35
+ sample({
36
+ clock: this.api.joinClassFx.done,
37
+ fn: ({ result }) => ({
38
+ status: JoinClassStatus.SUCCESS,
39
+ message: getJoinClassSuccessMessage(result.name),
40
+ }),
41
+ target: notifyFx,
42
+ })
43
+
44
+ sample({
45
+ clock: this.api.joinClassFx.fail,
46
+ fn: ({ error }) => ({
47
+ status: JoinClassStatus.ERROR,
48
+ message: getJoinClassErrorMessage(error instanceof JoinClassError ? error.code : null),
49
+ }),
50
+ target: notifyFx,
51
+ })
52
+
53
+ sample({
54
+ clock: this.api.joinClassFx.done,
55
+ target: this.reset,
56
+ })
57
+ }
58
+ }
@@ -0,0 +1,26 @@
1
+ import { createEvent, restore, sample } from 'effector'
2
+ import type { Language } from '@magmamath/frontend-config'
3
+
4
+ import { getAvailableLanguages } from '../shared/profile.helpers'
5
+ import type { ProfileApi } from './ProfileApi'
6
+
7
+ export class ProfileLanguageModel {
8
+ public readonly reset = createEvent()
9
+ public readonly setSearch = createEvent<string>()
10
+ public readonly selectLanguage = createEvent<Language | null>()
11
+
12
+ public readonly $search = restore(this.setSearch, '').reset(this.reset)
13
+ public readonly $languages = this.$search.map((search) => getAvailableLanguages(search))
14
+
15
+ constructor(private readonly api: ProfileApi) {
16
+ this.init()
17
+ }
18
+
19
+ private init() {
20
+ sample({
21
+ clock: this.selectLanguage,
22
+ fn: (translationLanguage) => ({ translationLanguage }),
23
+ target: this.api.updateSettingsFx,
24
+ })
25
+ }
26
+ }
@@ -0,0 +1,57 @@
1
+ import { createEvent, sample, type Store } from 'effector'
2
+
3
+ import type { ProfileCanvasType } from '../shared/profile.constants'
4
+ import type { NotifyJoinClass, ProfileSettings, ProfileUser } from '../shared/profile.types'
5
+ import { ProfileApi, type ProfileApiProps } from './ProfileApi'
6
+ import { ProfileJoinClassModel } from './ProfileJoinClassModel'
7
+ import { ProfileLanguageModel } from './ProfileLanguageModel'
8
+
9
+ type ProfileModelProps = {
10
+ api: ProfileApiProps
11
+ notify: NotifyJoinClass
12
+ $user: Store<ProfileUser | null>
13
+ $settings: Store<ProfileSettings>
14
+ }
15
+
16
+ export class ProfileModel {
17
+ public readonly api: ProfileApi
18
+ public readonly joinClass: ProfileJoinClassModel
19
+ public readonly language: ProfileLanguageModel
20
+
21
+ public readonly setTextToSpeech = createEvent<boolean>()
22
+ public readonly setTextSize = createEvent<number>()
23
+ public readonly setCanvasType = createEvent<ProfileCanvasType>()
24
+
25
+ public readonly $user: Store<ProfileUser | null>
26
+ public readonly $settings: Store<ProfileSettings>
27
+
28
+ constructor({ api, notify, $user, $settings }: ProfileModelProps) {
29
+ this.api = new ProfileApi(api)
30
+ this.joinClass = new ProfileJoinClassModel(this.api, notify)
31
+ this.language = new ProfileLanguageModel(this.api)
32
+ this.$user = $user
33
+ this.$settings = $settings
34
+
35
+ this.init()
36
+ }
37
+
38
+ private init() {
39
+ sample({
40
+ clock: this.setTextToSpeech,
41
+ fn: (textToSpeech) => ({ textToSpeech }),
42
+ target: this.api.updateSettingsFx,
43
+ })
44
+
45
+ sample({
46
+ clock: this.setTextSize,
47
+ fn: (textSize) => ({ textSize }),
48
+ target: this.api.updateSettingsFx,
49
+ })
50
+
51
+ sample({
52
+ clock: this.setCanvasType,
53
+ fn: (canvasType) => ({ canvasType }),
54
+ target: this.api.updateSettingsFx,
55
+ })
56
+ }
57
+ }
@@ -0,0 +1,16 @@
1
+ import type { ProfileModel } from './ProfileModel'
2
+
3
+ export type ProfileModalParams = {
4
+ model: ProfileModel
5
+ }
6
+
7
+ export type LogoutModalParams = {
8
+ onConfirm: () => void
9
+ }
10
+
11
+ export type ProfileModalProps<Params = ProfileModalParams> = {
12
+ modal: {
13
+ closeModal: () => void
14
+ params: Params
15
+ }
16
+ }
@@ -0,0 +1,7 @@
1
+ // Carries the backend error code so the library can map it to a message without parsing HTTP errors.
2
+ export class JoinClassError extends Error {
3
+ constructor(public readonly code: number | null) {
4
+ super(code === null ? 'Join class failed' : `Join class failed (code ${code})`)
5
+ this.name = 'JoinClassError'
6
+ }
7
+ }
@@ -0,0 +1,23 @@
1
+ export enum ProfileCanvasType {
2
+ DRAWING = 1,
3
+ SPREADSHEET = 2,
4
+ }
5
+
6
+ export const TEXT_SIZE = {
7
+ MIN: 16,
8
+ MAX: 32,
9
+ STEP: 4,
10
+ } as const
11
+
12
+ export const CLASS_CODE_LENGTH = 6
13
+
14
+ export enum JoinClassStatus {
15
+ SUCCESS = 'success',
16
+ ERROR = 'error',
17
+ }
18
+
19
+ export enum JoinClassErrorCode {
20
+ CLASS_NOT_FOUND = 1021,
21
+ ALREADY_JOINED = 1030,
22
+ OTHER_DISTRICT = 1035,
23
+ }
@@ -0,0 +1,36 @@
1
+ import { Language, LANGUAGES_CONFIG, PRIORITY_LANGUAGES } from '@magmamath/frontend-config'
2
+
3
+ import { getText, type TranslationKey } from '../../../i18n/i18n'
4
+ import { JoinClassErrorCode, TEXT_SIZE } from './profile.constants'
5
+
6
+ export const getAvailableLanguages = (search?: string): Language[] => {
7
+ const prioritySet = new Set<Language>(PRIORITY_LANGUAGES)
8
+
9
+ const otherLanguages = Object.values(Language).filter(
10
+ (language) => !LANGUAGES_CONFIG[language]?.baseName && !prioritySet.has(language)
11
+ )
12
+
13
+ const allLanguages = [...PRIORITY_LANGUAGES, ...otherLanguages]
14
+ if (!search) return allLanguages
15
+
16
+ const query = search.toLowerCase()
17
+ return allLanguages.filter((language) => language.toLowerCase().includes(query))
18
+ }
19
+
20
+ export const snapTextSize = (value: number): number => {
21
+ const { MIN, MAX, STEP } = TEXT_SIZE
22
+ const clamped = Math.min(MAX, Math.max(MIN, value))
23
+ return Math.round((clamped - MIN) / STEP) * STEP + MIN
24
+ }
25
+
26
+ const JOIN_CLASS_ERROR_KEYS: Record<number, TranslationKey> = {
27
+ [JoinClassErrorCode.CLASS_NOT_FOUND]: 'profile.joinClassErrorNotFound',
28
+ [JoinClassErrorCode.ALREADY_JOINED]: 'profile.joinClassErrorAlreadyJoined',
29
+ [JoinClassErrorCode.OTHER_DISTRICT]: 'profile.joinClassErrorOtherDistrict',
30
+ }
31
+
32
+ export const getJoinClassSuccessMessage = (className: string): string =>
33
+ getText('profile.joinClassSuccess', { className })
34
+
35
+ export const getJoinClassErrorMessage = (code: number | null): string =>
36
+ getText((code !== null && JOIN_CLASS_ERROR_KEYS[code]) || 'profile.joinClassErrorDefault')
@@ -0,0 +1,34 @@
1
+ import type { Language } from '@magmamath/frontend-config'
2
+
3
+ import type { JoinClassStatus, ProfileCanvasType } from './profile.constants'
4
+
5
+ export type ProfileUser = {
6
+ fullName: string
7
+ username: string
8
+ schoolName: string
9
+ }
10
+
11
+ export type ProfileSettings = {
12
+ textToSpeech: boolean
13
+ textSize: number
14
+ translationLanguage: Language | null
15
+ canvasType: ProfileCanvasType
16
+ isTranslationLocked: boolean
17
+ }
18
+
19
+ export type ProfileSettingsUpdate = Partial<ProfileSettings>
20
+
21
+ export type JoinClassPayload = {
22
+ classCode: string
23
+ }
24
+
25
+ export type JoinClassResult = {
26
+ name: string
27
+ }
28
+
29
+ export type JoinClassNotification = {
30
+ status: JoinClassStatus
31
+ message: string
32
+ }
33
+
34
+ export type NotifyJoinClass = (notification: JoinClassNotification) => void
@@ -56,13 +56,20 @@
56
56
  },
57
57
  "profile": {
58
58
  "accountInfo": "Account info",
59
+ "cancel": "Cancel",
59
60
  "changePasswordNote": "Ask your teacher if you need to change password",
60
61
  "fullName": "Full name",
61
62
  "joinClassButton": "Join new class",
63
+ "joinClassErrorAlreadyJoined": "You have already joined this class",
64
+ "joinClassErrorDefault": "Default error! Code not found",
65
+ "joinClassErrorNotFound": "The class doesn’t exist, try another class code",
66
+ "joinClassErrorOtherDistrict": "You can only join classes in your district",
67
+ "joinClassSuccess": "You have joined class {{className}}",
62
68
  "joinClassTitle": "Write your new class code",
63
69
  "joinNewClass": "Join a new class",
64
70
  "languageSettings": "Language settings",
65
71
  "logOut": "Log out",
72
+ "logOutConfirmMessage": "Are you sure you want to log out?",
66
73
  "noLanguage": "No language",
67
74
  "preferences": "Preferences",
68
75
  "school": "School",
@@ -74,7 +81,8 @@
74
81
  "textToSpeech": "Text-to-speech",
75
82
  "translationLanguage": "Translation language",
76
83
  "translationModalTitle": "Translation language",
77
- "username": "Username"
84
+ "username": "Username",
85
+ "yes": "Yes"
78
86
  },
79
87
  "student": {
80
88
  "fluency": {
package/src/index.ts CHANGED
@@ -16,3 +16,4 @@ export * from './features/uiMode'
16
16
  export * from './features/fluency'
17
17
  export * from './features/fluency-teacher'
18
18
  export * from './features/translation'
19
+ export * from './features/profile'
@@ -0,0 +1,57 @@
1
+ import { useEffect, useRef } from 'react'
2
+ import { Animated, Keyboard, Platform, type KeyboardEvent } from 'react-native'
3
+
4
+ import { isWeb } from '../common.constants'
5
+
6
+ const SHOW_EVENT = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'
7
+ const HIDE_EVENT = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'
8
+ const ANIMATION_DURATION = 220
9
+
10
+ /**
11
+ * Returns an animated value tracking the on-screen keyboard height.
12
+ *
13
+ * - native: subscribes to the platform `Keyboard` events.
14
+ * - web: reads `visualViewport`, so it only reacts to a *virtual* keyboard
15
+ * (mobile browsers). A physical desktop keyboard never shrinks the viewport,
16
+ * so the value stays 0 and nothing moves.
17
+ */
18
+ export const useKeyboardOffset = () => {
19
+ const keyboardHeight = useRef(new Animated.Value(0)).current
20
+
21
+ useEffect(() => {
22
+ const animateTo = (toValue: number) =>
23
+ Animated.timing(keyboardHeight, {
24
+ toValue,
25
+ duration: ANIMATION_DURATION,
26
+ useNativeDriver: !isWeb,
27
+ }).start()
28
+
29
+ if (isWeb) {
30
+ const viewport = window.visualViewport
31
+ if (!viewport) return
32
+
33
+ const update = () => {
34
+ const overlap = Math.max(0, window.innerHeight - viewport.height - viewport.offsetTop)
35
+ animateTo(overlap)
36
+ }
37
+
38
+ viewport.addEventListener('resize', update)
39
+ viewport.addEventListener('scroll', update)
40
+ return () => {
41
+ viewport.removeEventListener('resize', update)
42
+ viewport.removeEventListener('scroll', update)
43
+ }
44
+ }
45
+
46
+ const showSub = Keyboard.addListener(SHOW_EVENT, (event: KeyboardEvent) =>
47
+ animateTo(event.endCoordinates.height),
48
+ )
49
+ const hideSub = Keyboard.addListener(HIDE_EVENT, () => animateTo(0))
50
+ return () => {
51
+ showSub.remove()
52
+ hideSub.remove()
53
+ }
54
+ }, [keyboardHeight])
55
+
56
+ return keyboardHeight
57
+ }