@magmamath/students-features 1.8.4 → 1.8.5-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.
- package/dist/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
- package/dist/commonjs/features/profile/Profile.js +90 -0
- package/dist/commonjs/features/profile/Profile.js.map +1 -0
- package/dist/commonjs/features/profile/components/actions/ProfileActions.js +70 -0
- package/dist/commonjs/features/profile/components/actions/ProfileActions.js.map +1 -0
- package/dist/commonjs/features/profile/components/cards/ProfileCard.js +57 -0
- package/dist/commonjs/features/profile/components/cards/ProfileCard.js.map +1 -0
- package/dist/commonjs/features/profile/components/info/AccountInfoCard.js +91 -0
- package/dist/commonjs/features/profile/components/info/AccountInfoCard.js.map +1 -0
- package/dist/commonjs/features/profile/components/modals/JoinClassModal.js +190 -0
- package/dist/commonjs/features/profile/components/modals/JoinClassModal.js.map +1 -0
- package/dist/commonjs/features/profile/components/modals/LogoutConfirmModal.js +61 -0
- package/dist/commonjs/features/profile/components/modals/LogoutConfirmModal.js.map +1 -0
- package/dist/commonjs/features/profile/components/modals/TranslationLanguageModal.js +128 -0
- package/dist/commonjs/features/profile/components/modals/TranslationLanguageModal.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/LanguageSettingsCard.js +22 -0
- package/dist/commonjs/features/profile/components/settings/LanguageSettingsCard.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/PreferencesCard.js +69 -0
- package/dist/commonjs/features/profile/components/settings/PreferencesCard.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/SettingRow.js +48 -0
- package/dist/commonjs/features/profile/components/settings/SettingRow.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/TextSettingsCard.js +77 -0
- package/dist/commonjs/features/profile/components/settings/TextSettingsCard.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/TextSizeSlider.js +119 -0
- package/dist/commonjs/features/profile/components/settings/TextSizeSlider.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/TextToSpeechRow.js +37 -0
- package/dist/commonjs/features/profile/components/settings/TextToSpeechRow.js.map +1 -0
- package/dist/commonjs/features/profile/components/settings/TranslationLanguageRow.js +62 -0
- package/dist/commonjs/features/profile/components/settings/TranslationLanguageRow.js.map +1 -0
- package/dist/commonjs/features/profile/context/ProfileContext.js +18 -0
- package/dist/commonjs/features/profile/context/ProfileContext.js.map +1 -0
- package/dist/commonjs/features/profile/index.js +80 -0
- package/dist/commonjs/features/profile/index.js.map +1 -0
- package/dist/commonjs/features/profile/model/ProfileApi.js +15 -0
- package/dist/commonjs/features/profile/model/ProfileApi.js.map +1 -0
- package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js +60 -0
- package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js.map +1 -0
- package/dist/commonjs/features/profile/model/ProfileLanguageModel.js +30 -0
- package/dist/commonjs/features/profile/model/ProfileLanguageModel.js.map +1 -0
- package/dist/commonjs/features/profile/model/ProfileModel.js +53 -0
- package/dist/commonjs/features/profile/model/ProfileModel.js.map +1 -0
- package/dist/commonjs/features/profile/model/profileModal.types.js +6 -0
- package/dist/commonjs/features/profile/model/profileModal.types.js.map +1 -0
- package/dist/commonjs/features/profile/shared/JoinClassError.js +16 -0
- package/dist/commonjs/features/profile/shared/JoinClassError.js.map +1 -0
- package/dist/commonjs/features/profile/shared/profile.constants.js +29 -0
- package/dist/commonjs/features/profile/shared/profile.constants.js.map +1 -0
- package/dist/commonjs/features/profile/shared/profile.helpers.js +40 -0
- package/dist/commonjs/features/profile/shared/profile.helpers.js.map +1 -0
- package/dist/commonjs/features/profile/shared/profile.types.js +6 -0
- package/dist/commonjs/features/profile/shared/profile.types.js.map +1 -0
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/shared/hooks/useKeyboardOffset.js +54 -0
- package/dist/commonjs/shared/hooks/useKeyboardOffset.js.map +1 -0
- package/dist/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
- package/dist/module/features/profile/Profile.js +84 -0
- package/dist/module/features/profile/Profile.js.map +1 -0
- package/dist/module/features/profile/components/actions/ProfileActions.js +64 -0
- package/dist/module/features/profile/components/actions/ProfileActions.js.map +1 -0
- package/dist/module/features/profile/components/cards/ProfileCard.js +51 -0
- package/dist/module/features/profile/components/cards/ProfileCard.js.map +1 -0
- package/dist/module/features/profile/components/info/AccountInfoCard.js +85 -0
- package/dist/module/features/profile/components/info/AccountInfoCard.js.map +1 -0
- package/dist/module/features/profile/components/modals/JoinClassModal.js +183 -0
- package/dist/module/features/profile/components/modals/JoinClassModal.js.map +1 -0
- package/dist/module/features/profile/components/modals/LogoutConfirmModal.js +55 -0
- package/dist/module/features/profile/components/modals/LogoutConfirmModal.js.map +1 -0
- package/dist/module/features/profile/components/modals/TranslationLanguageModal.js +122 -0
- package/dist/module/features/profile/components/modals/TranslationLanguageModal.js.map +1 -0
- package/dist/module/features/profile/components/settings/LanguageSettingsCard.js +16 -0
- package/dist/module/features/profile/components/settings/LanguageSettingsCard.js.map +1 -0
- package/dist/module/features/profile/components/settings/PreferencesCard.js +63 -0
- package/dist/module/features/profile/components/settings/PreferencesCard.js.map +1 -0
- package/dist/module/features/profile/components/settings/SettingRow.js +42 -0
- package/dist/module/features/profile/components/settings/SettingRow.js.map +1 -0
- package/dist/module/features/profile/components/settings/TextSettingsCard.js +71 -0
- package/dist/module/features/profile/components/settings/TextSettingsCard.js.map +1 -0
- package/dist/module/features/profile/components/settings/TextSizeSlider.js +112 -0
- package/dist/module/features/profile/components/settings/TextSizeSlider.js.map +1 -0
- package/dist/module/features/profile/components/settings/TextToSpeechRow.js +31 -0
- package/dist/module/features/profile/components/settings/TextToSpeechRow.js.map +1 -0
- package/dist/module/features/profile/components/settings/TranslationLanguageRow.js +56 -0
- package/dist/module/features/profile/components/settings/TranslationLanguageRow.js.map +1 -0
- package/dist/module/features/profile/context/ProfileContext.js +13 -0
- package/dist/module/features/profile/context/ProfileContext.js.map +1 -0
- package/dist/module/features/profile/index.js +11 -0
- package/dist/module/features/profile/index.js.map +1 -0
- package/dist/module/features/profile/model/ProfileApi.js +10 -0
- package/dist/module/features/profile/model/ProfileApi.js.map +1 -0
- package/dist/module/features/profile/model/ProfileJoinClassModel.js +55 -0
- package/dist/module/features/profile/model/ProfileJoinClassModel.js.map +1 -0
- package/dist/module/features/profile/model/ProfileLanguageModel.js +25 -0
- package/dist/module/features/profile/model/ProfileLanguageModel.js.map +1 -0
- package/dist/module/features/profile/model/ProfileModel.js +48 -0
- package/dist/module/features/profile/model/ProfileModel.js.map +1 -0
- package/dist/module/features/profile/model/profileModal.types.js +4 -0
- package/dist/module/features/profile/model/profileModal.types.js.map +1 -0
- package/dist/module/features/profile/shared/JoinClassError.js +11 -0
- package/dist/module/features/profile/shared/JoinClassError.js.map +1 -0
- package/dist/module/features/profile/shared/profile.constants.js +25 -0
- package/dist/module/features/profile/shared/profile.constants.js.map +1 -0
- package/dist/module/features/profile/shared/profile.helpers.js +32 -0
- package/dist/module/features/profile/shared/profile.helpers.js.map +1 -0
- package/dist/module/features/profile/shared/profile.types.js +4 -0
- package/dist/module/features/profile/shared/profile.types.js.map +1 -0
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/shared/hooks/useKeyboardOffset.js +49 -0
- package/dist/module/shared/hooks/useKeyboardOffset.js.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/Profile.d.ts +6 -0
- package/dist/typescript/commonjs/features/profile/Profile.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/__tests__/ProfileModel.test.d.ts +2 -0
- package/dist/typescript/commonjs/features/profile/__tests__/ProfileModel.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/__tests__/profile.helpers.test.d.ts +2 -0
- package/dist/typescript/commonjs/features/profile/__tests__/profile.helpers.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/actions/ProfileActions.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/actions/ProfileActions.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/cards/ProfileCard.d.ts +10 -0
- package/dist/typescript/commonjs/features/profile/components/cards/ProfileCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/info/AccountInfoCard.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/info/AccountInfoCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/modals/JoinClassModal.d.ts +4 -0
- package/dist/typescript/commonjs/features/profile/components/modals/JoinClassModal.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/modals/LogoutConfirmModal.d.ts +4 -0
- package/dist/typescript/commonjs/features/profile/components/modals/LogoutConfirmModal.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/modals/TranslationLanguageModal.d.ts +4 -0
- package/dist/typescript/commonjs/features/profile/components/modals/TranslationLanguageModal.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/LanguageSettingsCard.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/settings/LanguageSettingsCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/PreferencesCard.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/settings/PreferencesCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/SettingRow.d.ts +11 -0
- package/dist/typescript/commonjs/features/profile/components/settings/SettingRow.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextSettingsCard.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextSettingsCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextSizeSlider.d.ts +8 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextSizeSlider.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextToSpeechRow.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TextToSpeechRow.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TranslationLanguageRow.d.ts +3 -0
- package/dist/typescript/commonjs/features/profile/components/settings/TranslationLanguageRow.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/context/ProfileContext.d.ts +13 -0
- package/dist/typescript/commonjs/features/profile/context/ProfileContext.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/index.d.ts +12 -0
- package/dist/typescript/commonjs/features/profile/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts +11 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts +14 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileLanguageModel.d.ts +13 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileLanguageModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts +26 -0
- package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/model/profileModal.types.d.ts +14 -0
- package/dist/typescript/commonjs/features/profile/model/profileModal.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/shared/JoinClassError.d.ts +5 -0
- package/dist/typescript/commonjs/features/profile/shared/JoinClassError.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.constants.d.ts +20 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts +6 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts +27 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/hooks/useKeyboardOffset.d.ts +11 -0
- package/dist/typescript/commonjs/shared/hooks/useKeyboardOffset.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/Profile.d.ts +6 -0
- package/dist/typescript/module/features/profile/Profile.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/__tests__/ProfileModel.test.d.ts +2 -0
- package/dist/typescript/module/features/profile/__tests__/ProfileModel.test.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/__tests__/profile.helpers.test.d.ts +2 -0
- package/dist/typescript/module/features/profile/__tests__/profile.helpers.test.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/actions/ProfileActions.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/actions/ProfileActions.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/cards/ProfileCard.d.ts +10 -0
- package/dist/typescript/module/features/profile/components/cards/ProfileCard.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/info/AccountInfoCard.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/info/AccountInfoCard.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/modals/JoinClassModal.d.ts +4 -0
- package/dist/typescript/module/features/profile/components/modals/JoinClassModal.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/modals/LogoutConfirmModal.d.ts +4 -0
- package/dist/typescript/module/features/profile/components/modals/LogoutConfirmModal.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/modals/TranslationLanguageModal.d.ts +4 -0
- package/dist/typescript/module/features/profile/components/modals/TranslationLanguageModal.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/LanguageSettingsCard.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/settings/LanguageSettingsCard.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/PreferencesCard.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/settings/PreferencesCard.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/SettingRow.d.ts +11 -0
- package/dist/typescript/module/features/profile/components/settings/SettingRow.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/TextSettingsCard.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/settings/TextSettingsCard.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/TextSizeSlider.d.ts +8 -0
- package/dist/typescript/module/features/profile/components/settings/TextSizeSlider.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/TextToSpeechRow.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/settings/TextToSpeechRow.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/components/settings/TranslationLanguageRow.d.ts +3 -0
- package/dist/typescript/module/features/profile/components/settings/TranslationLanguageRow.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/context/ProfileContext.d.ts +13 -0
- package/dist/typescript/module/features/profile/context/ProfileContext.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/index.d.ts +12 -0
- package/dist/typescript/module/features/profile/index.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/model/ProfileApi.d.ts +11 -0
- package/dist/typescript/module/features/profile/model/ProfileApi.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts +14 -0
- package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/model/ProfileLanguageModel.d.ts +13 -0
- package/dist/typescript/module/features/profile/model/ProfileLanguageModel.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/model/ProfileModel.d.ts +26 -0
- package/dist/typescript/module/features/profile/model/ProfileModel.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/model/profileModal.types.d.ts +14 -0
- package/dist/typescript/module/features/profile/model/profileModal.types.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/shared/JoinClassError.d.ts +5 -0
- package/dist/typescript/module/features/profile/shared/JoinClassError.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/shared/profile.constants.d.ts +20 -0
- package/dist/typescript/module/features/profile/shared/profile.constants.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts +6 -0
- package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/profile/shared/profile.types.d.ts +27 -0
- package/dist/typescript/module/features/profile/shared/profile.types.d.ts.map +1 -0
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/shared/hooks/useKeyboardOffset.d.ts +11 -0
- package/dist/typescript/module/shared/hooks/useKeyboardOffset.d.ts.map +1 -0
- package/package.json +4 -2
- package/src/features/chatbot/components/ChatInput/FreeText/ChatTextInput.tsx +0 -1
- package/src/features/profile/Profile.tsx +83 -0
- package/src/features/profile/__tests__/ProfileModel.test.ts +99 -0
- package/src/features/profile/__tests__/profile.helpers.test.ts +57 -0
- package/src/features/profile/components/actions/ProfileActions.tsx +68 -0
- package/src/features/profile/components/cards/ProfileCard.tsx +53 -0
- package/src/features/profile/components/info/AccountInfoCard.tsx +74 -0
- package/src/features/profile/components/modals/JoinClassModal.tsx +180 -0
- package/src/features/profile/components/modals/LogoutConfirmModal.tsx +64 -0
- package/src/features/profile/components/modals/TranslationLanguageModal.tsx +126 -0
- package/src/features/profile/components/settings/LanguageSettingsCard.tsx +16 -0
- package/src/features/profile/components/settings/PreferencesCard.tsx +67 -0
- package/src/features/profile/components/settings/SettingRow.tsx +42 -0
- package/src/features/profile/components/settings/TextSettingsCard.tsx +64 -0
- package/src/features/profile/components/settings/TextSizeSlider.tsx +117 -0
- package/src/features/profile/components/settings/TextToSpeechRow.tsx +29 -0
- package/src/features/profile/components/settings/TranslationLanguageRow.tsx +60 -0
- package/src/features/profile/context/ProfileContext.tsx +24 -0
- package/src/features/profile/index.ts +11 -0
- package/src/features/profile/model/ProfileApi.ts +23 -0
- package/src/features/profile/model/ProfileJoinClassModel.ts +58 -0
- package/src/features/profile/model/ProfileLanguageModel.ts +26 -0
- package/src/features/profile/model/ProfileModel.ts +57 -0
- package/src/features/profile/model/profileModal.types.ts +16 -0
- package/src/features/profile/shared/JoinClassError.ts +7 -0
- package/src/features/profile/shared/profile.constants.ts +23 -0
- package/src/features/profile/shared/profile.helpers.ts +36 -0
- package/src/features/profile/shared/profile.types.ts +34 -0
- package/src/i18n/.generated/schema.json +9 -1
- package/src/index.ts +1 -0
- 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
|
@@ -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
|
+
}
|