@magmamath/students-features 1.8.4-rc.2 → 1.8.4-rc.4
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/profile/index.js +9 -1
- package/dist/commonjs/features/profile/index.js.map +1 -1
- package/dist/commonjs/features/profile/model/ProfileApi.js.map +1 -1
- package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js +28 -6
- package/dist/commonjs/features/profile/model/ProfileJoinClassModel.js.map +1 -1
- package/dist/commonjs/features/profile/model/ProfileModel.js +2 -1
- package/dist/commonjs/features/profile/model/ProfileModel.js.map +1 -1
- package/dist/commonjs/features/profile/shared/JoinClassError.js +17 -0
- package/dist/commonjs/features/profile/shared/JoinClassError.js.map +1 -0
- package/dist/commonjs/features/profile/shared/profile.constants.js +12 -1
- package/dist/commonjs/features/profile/shared/profile.constants.js.map +1 -1
- package/dist/commonjs/features/profile/shared/profile.helpers.js +13 -1
- package/dist/commonjs/features/profile/shared/profile.helpers.js.map +1 -1
- package/dist/module/features/profile/index.js +1 -0
- package/dist/module/features/profile/index.js.map +1 -1
- package/dist/module/features/profile/model/ProfileApi.js.map +1 -1
- package/dist/module/features/profile/model/ProfileJoinClassModel.js +30 -8
- package/dist/module/features/profile/model/ProfileJoinClassModel.js.map +1 -1
- package/dist/module/features/profile/model/ProfileModel.js +2 -1
- package/dist/module/features/profile/model/ProfileModel.js.map +1 -1
- package/dist/module/features/profile/shared/JoinClassError.js +12 -0
- package/dist/module/features/profile/shared/JoinClassError.js.map +1 -0
- package/dist/module/features/profile/shared/profile.constants.js +13 -0
- package/dist/module/features/profile/shared/profile.constants.js.map +1 -1
- package/dist/module/features/profile/shared/profile.helpers.js +11 -1
- package/dist/module/features/profile/shared/profile.helpers.js.map +1 -1
- package/dist/typescript/commonjs/features/profile/index.d.ts +1 -0
- package/dist/typescript/commonjs/features/profile/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts +3 -3
- package/dist/typescript/commonjs/features/profile/model/ProfileApi.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts +2 -2
- package/dist/typescript/commonjs/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts +3 -2
- package/dist/typescript/commonjs/features/profile/model/ProfileModel.d.ts.map +1 -1
- 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 +9 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts +2 -0
- package/dist/typescript/commonjs/features/profile/shared/profile.helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts +9 -2
- package/dist/typescript/commonjs/features/profile/shared/profile.types.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/index.d.ts +1 -0
- package/dist/typescript/module/features/profile/index.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/model/ProfileApi.d.ts +3 -3
- package/dist/typescript/module/features/profile/model/ProfileApi.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts +2 -2
- package/dist/typescript/module/features/profile/model/ProfileJoinClassModel.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/model/ProfileModel.d.ts +3 -2
- package/dist/typescript/module/features/profile/model/ProfileModel.d.ts.map +1 -1
- 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 +9 -0
- package/dist/typescript/module/features/profile/shared/profile.constants.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts +2 -0
- package/dist/typescript/module/features/profile/shared/profile.helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/profile/shared/profile.types.d.ts +9 -2
- package/dist/typescript/module/features/profile/shared/profile.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/profile/__tests__/ProfileModel.test.ts +27 -7
- package/src/features/profile/index.ts +1 -0
- package/src/features/profile/model/ProfileApi.ts +3 -1
- package/src/features/profile/model/ProfileJoinClassModel.ts +30 -7
- package/src/features/profile/model/ProfileModel.ts +4 -3
- package/src/features/profile/shared/JoinClassError.ts +8 -0
- package/src/features/profile/shared/profile.constants.ts +12 -0
- package/src/features/profile/shared/profile.helpers.ts +14 -1
- package/src/features/profile/shared/profile.types.ts +12 -2
- package/src/i18n/.generated/schema.json +5 -0
|
@@ -7,8 +7,15 @@ var _exportNames = {
|
|
|
7
7
|
Profile: true,
|
|
8
8
|
ProfileModel: true,
|
|
9
9
|
TranslationLanguageModal: true,
|
|
10
|
-
JoinClassModal: true
|
|
10
|
+
JoinClassModal: true,
|
|
11
|
+
JoinClassError: true
|
|
11
12
|
};
|
|
13
|
+
Object.defineProperty(exports, "JoinClassError", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _JoinClassError.JoinClassError;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
12
19
|
Object.defineProperty(exports, "JoinClassModal", {
|
|
13
20
|
enumerable: true,
|
|
14
21
|
get: function () {
|
|
@@ -37,6 +44,7 @@ var _Profile = require("./Profile.js");
|
|
|
37
44
|
var _ProfileModel = require("./model/ProfileModel.js");
|
|
38
45
|
var _TranslationLanguageModal = require("./components/modals/TranslationLanguageModal.js");
|
|
39
46
|
var _JoinClassModal = require("./components/modals/JoinClassModal.js");
|
|
47
|
+
var _JoinClassError = require("./shared/JoinClassError.js");
|
|
40
48
|
var _profileTypes = require("./shared/profile.types.js");
|
|
41
49
|
Object.keys(_profileTypes).forEach(function (key) {
|
|
42
50
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Profile","require","_ProfileModel","_TranslationLanguageModal","_JoinClassModal","_profileTypes","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_profileConstants"],"sourceRoot":"../../../../src","sources":["features/profile/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Profile","require","_ProfileModel","_TranslationLanguageModal","_JoinClassModal","_JoinClassError","_profileTypes","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_profileConstants"],"sourceRoot":"../../../../src","sources":["features/profile/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAGA,IAAAE,yBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,aAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,aAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,aAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAlB,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAW,iBAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,iBAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,iBAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","ProfileApi","constructor","props","updateSettingsFx","createEffect","updateSettings","joinClassFx","joinClass","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileApi.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_effector","require","ProfileApi","constructor","props","updateSettingsFx","createEffect","updateSettings","joinClassFx","joinClass","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileApi.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAeO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAACC,KAAsB,EAAE;IAClC,IAAI,CAACC,gBAAgB,GAAG,IAAAC,sBAAY,EAACF,KAAK,CAACG,cAAc,CAAC;IAC1D,IAAI,CAACC,WAAW,GAAG,IAAAF,sBAAY,EAACF,KAAK,CAACK,SAAS,CAAC;EAClD;AACF;AAACC,OAAA,CAAAR,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -5,18 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ProfileJoinClassModel = void 0;
|
|
7
7
|
var _effector = require("effector");
|
|
8
|
+
var _JoinClassError = require("../shared/JoinClassError.js");
|
|
8
9
|
var _profileConstants = require("../shared/profile.constants.js");
|
|
10
|
+
var _profileHelpers = require("../shared/profile.helpers.js");
|
|
9
11
|
class ProfileJoinClassModel {
|
|
10
12
|
reset = (0, _effector.createEvent)();
|
|
11
13
|
setCode = (0, _effector.createEvent)();
|
|
12
14
|
submit = (0, _effector.createEvent)();
|
|
13
15
|
$code = (0, _effector.restore)(this.setCode, '').reset(this.reset);
|
|
14
16
|
$isComplete = this.$code.map(code => code.length === _profileConstants.CLASS_CODE_LENGTH);
|
|
15
|
-
constructor(api) {
|
|
16
|
-
this.api
|
|
17
|
-
this.init();
|
|
17
|
+
constructor(api, notify) {
|
|
18
|
+
this.init(api, notify);
|
|
18
19
|
}
|
|
19
|
-
init() {
|
|
20
|
+
init(api, notify) {
|
|
21
|
+
const notifyFx = (0, _effector.createEffect)(notify);
|
|
20
22
|
(0, _effector.sample)({
|
|
21
23
|
clock: this.submit,
|
|
22
24
|
source: this.$code,
|
|
@@ -24,10 +26,30 @@ class ProfileJoinClassModel {
|
|
|
24
26
|
fn: classCode => ({
|
|
25
27
|
classCode
|
|
26
28
|
}),
|
|
27
|
-
target:
|
|
29
|
+
target: api.joinClassFx
|
|
28
30
|
});
|
|
29
31
|
(0, _effector.sample)({
|
|
30
|
-
clock:
|
|
32
|
+
clock: api.joinClassFx.done,
|
|
33
|
+
fn: ({
|
|
34
|
+
result
|
|
35
|
+
}) => ({
|
|
36
|
+
status: _profileConstants.JoinClassStatus.SUCCESS,
|
|
37
|
+
message: (0, _profileHelpers.getJoinClassSuccessMessage)(result.name)
|
|
38
|
+
}),
|
|
39
|
+
target: notifyFx
|
|
40
|
+
});
|
|
41
|
+
(0, _effector.sample)({
|
|
42
|
+
clock: api.joinClassFx.fail,
|
|
43
|
+
fn: ({
|
|
44
|
+
error
|
|
45
|
+
}) => ({
|
|
46
|
+
status: _profileConstants.JoinClassStatus.ERROR,
|
|
47
|
+
message: (0, _profileHelpers.getJoinClassErrorMessage)(error instanceof _JoinClassError.JoinClassError ? error.code : null)
|
|
48
|
+
}),
|
|
49
|
+
target: notifyFx
|
|
50
|
+
});
|
|
51
|
+
(0, _effector.sample)({
|
|
52
|
+
clock: api.joinClassFx.done,
|
|
31
53
|
target: this.reset
|
|
32
54
|
});
|
|
33
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_profileConstants","ProfileJoinClassModel","reset","createEvent","setCode","submit","$code","restore","$isComplete","map","code","length","CLASS_CODE_LENGTH","constructor","api","init","sample","clock","source","filter","fn","classCode","target","joinClassFx","done","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileJoinClassModel.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,
|
|
1
|
+
{"version":3,"names":["_effector","require","_JoinClassError","_profileConstants","_profileHelpers","ProfileJoinClassModel","reset","createEvent","setCode","submit","$code","restore","$isComplete","map","code","length","CLASS_CODE_LENGTH","constructor","api","notify","init","notifyFx","createEffect","sample","clock","source","filter","fn","classCode","target","joinClassFx","done","result","status","JoinClassStatus","SUCCESS","message","getJoinClassSuccessMessage","name","fail","error","ERROR","getJoinClassErrorMessage","JoinClassError","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileJoinClassModel.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIO,MAAMI,qBAAqB,CAAC;EACjBC,KAAK,GAAG,IAAAC,qBAAW,EAAC,CAAC;EACrBC,OAAO,GAAG,IAAAD,qBAAW,EAAS,CAAC;EAC/BE,MAAM,GAAG,IAAAF,qBAAW,EAAC,CAAC;EAEtBG,KAAK,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACH,OAAO,EAAE,EAAE,CAAC,CAACF,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EACnDM,WAAW,GAAG,IAAI,CAACF,KAAK,CAACG,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,MAAM,KAAKC,mCAAiB,CAAC;EAEz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AAACsC,OAAA,CAAAvC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -14,11 +14,12 @@ class ProfileModel {
|
|
|
14
14
|
setCanvasType = (0, _effector.createEvent)();
|
|
15
15
|
constructor({
|
|
16
16
|
api,
|
|
17
|
+
notify,
|
|
17
18
|
$user,
|
|
18
19
|
$settings
|
|
19
20
|
}) {
|
|
20
21
|
this.api = new _ProfileApi.ProfileApi(api);
|
|
21
|
-
this.joinClass = new _ProfileJoinClassModel.ProfileJoinClassModel(this.api);
|
|
22
|
+
this.joinClass = new _ProfileJoinClassModel.ProfileJoinClassModel(this.api, notify);
|
|
22
23
|
this.language = new _ProfileLanguageModel.ProfileLanguageModel(this.api);
|
|
23
24
|
this.$user = $user;
|
|
24
25
|
this.$settings = $settings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_ProfileApi","_ProfileJoinClassModel","_ProfileLanguageModel","ProfileModel","setTextToSpeech","createEvent","setTextSize","setCanvasType","constructor","api","$user","$settings","ProfileApi","joinClass","ProfileJoinClassModel","language","ProfileLanguageModel","init","sample","clock","fn","textToSpeech","target","updateSettingsFx","textSize","canvasType","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileModel.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;
|
|
1
|
+
{"version":3,"names":["_effector","require","_ProfileApi","_ProfileJoinClassModel","_ProfileLanguageModel","ProfileModel","setTextToSpeech","createEvent","setTextSize","setCanvasType","constructor","api","notify","$user","$settings","ProfileApi","joinClass","ProfileJoinClassModel","language","ProfileLanguageModel","init","sample","clock","fn","textToSpeech","target","updateSettingsFx","textSize","canvasType","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileModel.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAA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EAAE,IAAI,CAACd,GAAG,CAACe;IACnB,CAAC,CAAC;EACJ;AACF;AAACG,OAAA,CAAAxB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JoinClassError = void 0;
|
|
7
|
+
// The consumer's injected `joinClass` callable rejects with this so the library
|
|
8
|
+
// can map the backend error code to a message without parsing the HTTP error itself.
|
|
9
|
+
class JoinClassError extends Error {
|
|
10
|
+
constructor(code) {
|
|
11
|
+
super(code === null ? 'Join class failed' : `Join class failed (code ${code})`);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.name = 'JoinClassError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.JoinClassError = JoinClassError;
|
|
17
|
+
//# sourceMappingURL=JoinClassError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["JoinClassError","Error","constructor","code","name","exports"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/JoinClassError.ts"],"mappings":";;;;;;AAAA;AACA;AACO,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAWA,CAAiBC,IAAmB,EAAE;IAC/C,KAAK,CAACA,IAAI,KAAK,IAAI,GAAG,mBAAmB,GAAG,2BAA2BA,IAAI,GAAG,CAAC;IAAA,KADrDA,IAAmB,GAAnBA,IAAmB;IAE7C,IAAI,CAACC,IAAI,GAAG,gBAAgB;EAC9B;AACF;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TEXT_SIZE = exports.ProfileCanvasType = exports.CLASS_CODE_LENGTH = exports.ACCOUNT_VALUE_LONG_THRESHOLD = void 0;
|
|
6
|
+
exports.TEXT_SIZE = exports.ProfileCanvasType = exports.JoinClassStatus = exports.JoinClassErrorCode = exports.CLASS_CODE_LENGTH = exports.ACCOUNT_VALUE_LONG_THRESHOLD = void 0;
|
|
7
7
|
let ProfileCanvasType = exports.ProfileCanvasType = /*#__PURE__*/function (ProfileCanvasType) {
|
|
8
8
|
ProfileCanvasType[ProfileCanvasType["DRAWING"] = 1] = "DRAWING";
|
|
9
9
|
ProfileCanvasType[ProfileCanvasType["SPREADSHEET"] = 2] = "SPREADSHEET";
|
|
@@ -16,4 +16,15 @@ const TEXT_SIZE = exports.TEXT_SIZE = {
|
|
|
16
16
|
};
|
|
17
17
|
const CLASS_CODE_LENGTH = exports.CLASS_CODE_LENGTH = 6;
|
|
18
18
|
const ACCOUNT_VALUE_LONG_THRESHOLD = exports.ACCOUNT_VALUE_LONG_THRESHOLD = 24;
|
|
19
|
+
let JoinClassStatus = exports.JoinClassStatus = /*#__PURE__*/function (JoinClassStatus) {
|
|
20
|
+
JoinClassStatus["SUCCESS"] = "success";
|
|
21
|
+
JoinClassStatus["ERROR"] = "error";
|
|
22
|
+
return JoinClassStatus;
|
|
23
|
+
}({}); // Backend error codes the join-class endpoint can return.
|
|
24
|
+
let JoinClassErrorCode = exports.JoinClassErrorCode = /*#__PURE__*/function (JoinClassErrorCode) {
|
|
25
|
+
JoinClassErrorCode[JoinClassErrorCode["CLASS_NOT_FOUND"] = 1021] = "CLASS_NOT_FOUND";
|
|
26
|
+
JoinClassErrorCode[JoinClassErrorCode["ALREADY_JOINED"] = 1030] = "ALREADY_JOINED";
|
|
27
|
+
JoinClassErrorCode[JoinClassErrorCode["OTHER_DISTRICT"] = 1035] = "OTHER_DISTRICT";
|
|
28
|
+
return JoinClassErrorCode;
|
|
29
|
+
}({});
|
|
19
30
|
//# sourceMappingURL=profile.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProfileCanvasType","exports","TEXT_SIZE","MIN","MAX","STEP","CLASS_CODE_LENGTH","ACCOUNT_VALUE_LONG_THRESHOLD"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.constants.ts"],"mappings":";;;;;;IAAYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAKtB,MAAME,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG;EACvBC,GAAG,EAAE,EAAE;EACPC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE;AACR,CAAU;AAEH,MAAMC,iBAAiB,GAAAL,OAAA,CAAAK,iBAAA,GAAG,CAAC;AAE3B,MAAMC,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAG,EAAE","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ProfileCanvasType","exports","TEXT_SIZE","MIN","MAX","STEP","CLASS_CODE_LENGTH","ACCOUNT_VALUE_LONG_THRESHOLD","JoinClassStatus","JoinClassErrorCode"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.constants.ts"],"mappings":";;;;;;IAAYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAKtB,MAAME,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG;EACvBC,GAAG,EAAE,EAAE;EACPC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE;AACR,CAAU;AAEH,MAAMC,iBAAiB,GAAAL,OAAA,CAAAK,iBAAA,GAAG,CAAC;AAE3B,MAAMC,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAG,EAAE;AAAA,IAElCC,eAAe,GAAAP,OAAA,CAAAO,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA,OAK3B;AAAA,IACYC,kBAAkB,GAAAR,OAAA,CAAAQ,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.snapTextSize = exports.isLongAccountValue = exports.isLanguage = exports.getAvailableLanguages = void 0;
|
|
6
|
+
exports.snapTextSize = exports.isLongAccountValue = exports.isLanguage = exports.getJoinClassSuccessMessage = exports.getJoinClassErrorMessage = exports.getAvailableLanguages = void 0;
|
|
7
7
|
var _frontendConfig = require("@magmamath/frontend-config");
|
|
8
|
+
var _i18n = require("../../../i18n/i18n.js");
|
|
8
9
|
var _profileConstants = require("./profile.constants.js");
|
|
9
10
|
const isLanguage = value => Object.values(_frontendConfig.Language).includes(value);
|
|
10
11
|
exports.isLanguage = isLanguage;
|
|
@@ -29,4 +30,15 @@ const snapTextSize = value => {
|
|
|
29
30
|
exports.snapTextSize = snapTextSize;
|
|
30
31
|
const isLongAccountValue = text => text.length > _profileConstants.ACCOUNT_VALUE_LONG_THRESHOLD;
|
|
31
32
|
exports.isLongAccountValue = isLongAccountValue;
|
|
33
|
+
const JOIN_CLASS_ERROR_KEYS = {
|
|
34
|
+
[_profileConstants.JoinClassErrorCode.CLASS_NOT_FOUND]: 'profile.joinClassErrorNotFound',
|
|
35
|
+
[_profileConstants.JoinClassErrorCode.ALREADY_JOINED]: 'profile.joinClassErrorAlreadyJoined',
|
|
36
|
+
[_profileConstants.JoinClassErrorCode.OTHER_DISTRICT]: 'profile.joinClassErrorOtherDistrict'
|
|
37
|
+
};
|
|
38
|
+
const getJoinClassSuccessMessage = className => (0, _i18n.getText)('profile.joinClassSuccess', {
|
|
39
|
+
className
|
|
40
|
+
});
|
|
41
|
+
exports.getJoinClassSuccessMessage = getJoinClassSuccessMessage;
|
|
42
|
+
const getJoinClassErrorMessage = code => (0, _i18n.getText)(code !== null && JOIN_CLASS_ERROR_KEYS[code] || 'profile.joinClassErrorDefault');
|
|
43
|
+
exports.getJoinClassErrorMessage = getJoinClassErrorMessage;
|
|
32
44
|
//# sourceMappingURL=profile.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_frontendConfig","require","_profileConstants","isLanguage","value","Object","values","Language","includes","exports","getAvailableLanguages","search","prioritySet","Set","PRIORITY_LANGUAGES","otherLanguages","filter","language","LANGUAGES_CONFIG","baseName","has","allLanguages","query","toLowerCase","snapTextSize","MIN","MAX","STEP","TEXT_SIZE","clamped","Math","min","max","round","isLongAccountValue","text","length","ACCOUNT_VALUE_LONG_THRESHOLD"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.helpers.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,
|
|
1
|
+
{"version":3,"names":["_frontendConfig","require","_i18n","_profileConstants","isLanguage","value","Object","values","Language","includes","exports","getAvailableLanguages","search","prioritySet","Set","PRIORITY_LANGUAGES","otherLanguages","filter","language","LANGUAGES_CONFIG","baseName","has","allLanguages","query","toLowerCase","snapTextSize","MIN","MAX","STEP","TEXT_SIZE","clamped","Math","min","max","round","isLongAccountValue","text","length","ACCOUNT_VALUE_LONG_THRESHOLD","JOIN_CLASS_ERROR_KEYS","JoinClassErrorCode","CLASS_NOT_FOUND","ALREADY_JOINED","OTHER_DISTRICT","getJoinClassSuccessMessage","className","getText","getJoinClassErrorMessage","code"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.helpers.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AA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C,IAAY,IAC7CA,IAAI,CAACC,MAAM,GAAGC,8CAA4B;AAAA5B,OAAA,CAAAyB,kBAAA,GAAAA,kBAAA;AAE5C,MAAMI,qBAAqD,GAAG;EAC5D,CAACC,oCAAkB,CAACC,eAAe,GAAG,gCAAgC;EACtE,CAACD,oCAAkB,CAACE,cAAc,GAAG,qCAAqC;EAC1E,CAACF,oCAAkB,CAACG,cAAc,GAAG;AACvC,CAAC;AAEM,MAAMC,0BAA0B,GAAIC,SAAiB,IAC1D,IAAAC,aAAO,EAAC,0BAA0B,EAAE;EAAED;AAAU,CAAC,CAAC;AAAAnC,OAAA,CAAAkC,0BAAA,GAAAA,0BAAA;AAE7C,MAAMG,wBAAwB,GAAIC,IAAmB,IAC1D,IAAAF,aAAO,EAAEE,IAAI,KAAK,IAAI,IAAIT,qBAAqB,CAACS,IAAI,CAAC,IAAK,+BAA+B,CAAC;AAAAtC,OAAA,CAAAqC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ export { Profile } from "./Profile.js";
|
|
|
4
4
|
export { ProfileModel } from "./model/ProfileModel.js";
|
|
5
5
|
export { TranslationLanguageModal } from "./components/modals/TranslationLanguageModal.js";
|
|
6
6
|
export { JoinClassModal } from "./components/modals/JoinClassModal.js";
|
|
7
|
+
export { JoinClassError } from "./shared/JoinClassError.js";
|
|
7
8
|
export * from "./shared/profile.types.js";
|
|
8
9
|
export * from "./shared/profile.constants.js";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Profile","ProfileModel","TranslationLanguageModal","JoinClassModal"],"sourceRoot":"../../../../src","sources":["features/profile/index.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,cAAW;AACnC,SAASC,YAAY,QAAQ,yBAAsB;AAGnD,SAASC,wBAAwB,QAAQ,iDAA8C;AACvF,SAASC,cAAc,QAAQ,uCAAoC;AAEnE,cAAc,2BAAwB;AACtC,cAAc,+BAA4B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Profile","ProfileModel","TranslationLanguageModal","JoinClassModal","JoinClassError"],"sourceRoot":"../../../../src","sources":["features/profile/index.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,cAAW;AACnC,SAASC,YAAY,QAAQ,yBAAsB;AAGnD,SAASC,wBAAwB,QAAQ,iDAA8C;AACvF,SAASC,cAAc,QAAQ,uCAAoC;AAEnE,SAASC,cAAc,QAAQ,4BAAyB;AACxD,cAAc,2BAAwB;AACtC,cAAc,+BAA4B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","ProfileApi","constructor","props","updateSettingsFx","updateSettings","joinClassFx","joinClass"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileApi.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"names":["createEffect","ProfileApi","constructor","props","updateSettingsFx","updateSettings","joinClassFx","joinClass"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileApi.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AAevC,OAAO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAACC,KAAsB,EAAE;IAClC,IAAI,CAACC,gBAAgB,GAAGJ,YAAY,CAACG,KAAK,CAACE,cAAc,CAAC;IAC1D,IAAI,CAACC,WAAW,GAAGN,YAAY,CAACG,KAAK,CAACI,SAAS,CAAC;EAClD;AACF","ignoreList":[]}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createEvent, restore, sample } from 'effector';
|
|
4
|
-
import {
|
|
3
|
+
import { createEffect, createEvent, restore, sample } from 'effector';
|
|
4
|
+
import { JoinClassError } from "../shared/JoinClassError.js";
|
|
5
|
+
import { CLASS_CODE_LENGTH, JoinClassStatus } from "../shared/profile.constants.js";
|
|
6
|
+
import { getJoinClassErrorMessage, getJoinClassSuccessMessage } from "../shared/profile.helpers.js";
|
|
5
7
|
export class ProfileJoinClassModel {
|
|
6
8
|
reset = createEvent();
|
|
7
9
|
setCode = createEvent();
|
|
8
10
|
submit = createEvent();
|
|
9
11
|
$code = restore(this.setCode, '').reset(this.reset);
|
|
10
12
|
$isComplete = this.$code.map(code => code.length === CLASS_CODE_LENGTH);
|
|
11
|
-
constructor(api) {
|
|
12
|
-
this.api
|
|
13
|
-
this.init();
|
|
13
|
+
constructor(api, notify) {
|
|
14
|
+
this.init(api, notify);
|
|
14
15
|
}
|
|
15
|
-
init() {
|
|
16
|
+
init(api, notify) {
|
|
17
|
+
const notifyFx = createEffect(notify);
|
|
16
18
|
sample({
|
|
17
19
|
clock: this.submit,
|
|
18
20
|
source: this.$code,
|
|
@@ -20,10 +22,30 @@ export class ProfileJoinClassModel {
|
|
|
20
22
|
fn: classCode => ({
|
|
21
23
|
classCode
|
|
22
24
|
}),
|
|
23
|
-
target:
|
|
25
|
+
target: api.joinClassFx
|
|
24
26
|
});
|
|
25
27
|
sample({
|
|
26
|
-
clock:
|
|
28
|
+
clock: api.joinClassFx.done,
|
|
29
|
+
fn: ({
|
|
30
|
+
result
|
|
31
|
+
}) => ({
|
|
32
|
+
status: JoinClassStatus.SUCCESS,
|
|
33
|
+
message: getJoinClassSuccessMessage(result.name)
|
|
34
|
+
}),
|
|
35
|
+
target: notifyFx
|
|
36
|
+
});
|
|
37
|
+
sample({
|
|
38
|
+
clock: api.joinClassFx.fail,
|
|
39
|
+
fn: ({
|
|
40
|
+
error
|
|
41
|
+
}) => ({
|
|
42
|
+
status: JoinClassStatus.ERROR,
|
|
43
|
+
message: getJoinClassErrorMessage(error instanceof JoinClassError ? error.code : null)
|
|
44
|
+
}),
|
|
45
|
+
target: notifyFx
|
|
46
|
+
});
|
|
47
|
+
sample({
|
|
48
|
+
clock: api.joinClassFx.done,
|
|
27
49
|
target: this.reset
|
|
28
50
|
});
|
|
29
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEvent","restore","sample","CLASS_CODE_LENGTH","ProfileJoinClassModel","reset","setCode","submit","$code","$isComplete","map","code","length","constructor","api","init","clock","source","filter","fn","classCode","target","joinClassFx","done"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileJoinClassModel.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","restore","sample","JoinClassError","CLASS_CODE_LENGTH","JoinClassStatus","getJoinClassErrorMessage","getJoinClassSuccessMessage","ProfileJoinClassModel","reset","setCode","submit","$code","$isComplete","map","code","length","constructor","api","notify","init","notifyFx","clock","source","filter","fn","classCode","target","joinClassFx","done","result","status","SUCCESS","message","name","fail","error","ERROR"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileJoinClassModel.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,UAAU;AAErE,SAASC,cAAc,QAAQ,6BAA0B;AACzD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,gCAA6B;AAChF,SAASC,wBAAwB,EAAEC,0BAA0B,QAAQ,8BAA2B;AAIhG,OAAO,MAAMC,qBAAqB,CAAC;EACjBC,KAAK,GAAGT,WAAW,CAAC,CAAC;EACrBU,OAAO,GAAGV,WAAW,CAAS,CAAC;EAC/BW,MAAM,GAAGX,WAAW,CAAC,CAAC;EAEtBY,KAAK,GAAGX,OAAO,CAAC,IAAI,CAACS,OAAO,EAAE,EAAE,CAAC,CAACD,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;EACnDI,WAAW,GAAG,IAAI,CAACD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,MAAM,KAAKZ,iBAAiB,CAAC;EAEzFa,WAAWA,CAACC,GAAe,EAAEC,MAAuB,EAAE;IACpD,IAAI,CAACC,IAAI,CAACF,GAAG,EAAEC,M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
|
|
13
|
+
notify,
|
|
13
14
|
$user,
|
|
14
15
|
$settings
|
|
15
16
|
}) {
|
|
16
17
|
this.api = new ProfileApi(api);
|
|
17
|
-
this.joinClass = new ProfileJoinClassModel(this.api);
|
|
18
|
+
this.joinClass = new ProfileJoinClassModel(this.api, notify);
|
|
18
19
|
this.language = new ProfileLanguageModel(this.api);
|
|
19
20
|
this.$user = $user;
|
|
20
21
|
this.$settings = $settings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEvent","sample","ProfileApi","ProfileJoinClassModel","ProfileLanguageModel","ProfileModel","setTextToSpeech","setTextSize","setCanvasType","constructor","api","$user","$settings","joinClass","language","init","clock","fn","textToSpeech","target","updateSettingsFx","textSize","canvasType"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileModel.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,QAAoB,UAAU;AAI1D,SAASC,UAAU,QAA8B,iBAAc;AAC/D,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,oBAAoB,QAAQ,2BAAwB;
|
|
1
|
+
{"version":3,"names":["createEvent","sample","ProfileApi","ProfileJoinClassModel","ProfileLanguageModel","ProfileModel","setTextToSpeech","setTextSize","setCanvasType","constructor","api","notify","$user","$settings","joinClass","language","init","clock","fn","textToSpeech","target","updateSettingsFx","textSize","canvasType"],"sourceRoot":"../../../../../src","sources":["features/profile/model/ProfileModel.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,QAAoB,UAAU;AAI1D,SAASC,UAAU,QAA8B,iBAAc;AAC/D,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,oBAAoB,QAAQ,2BAAwB;AAS7D,OAAO,MAAMC,YAAY,CAAC;EAKRC,eAAe,GAAGN,WAAW,CAAU,CAAC;EACxCO,WAAW,GAAGP,WAAW,CAAS,CAAC;EACnCQ,aAAa,GAAGR,WAAW,CAAoB,CAAC;EAKhES,WAAWA,CAAC;IAAEC,GAAG;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAA6B,CAAC,EAAE;IAChE,IAAI,CAACH,GAAG,GAAG,IAAIR,UAAU,CAACQ,GAAG,CAAC;IAC9B,IAAI,CAACI,SAAS,GAAG,IAAIX,qBAAqB,CAAC,IAAI,CAACO,GAAG,EAAEC,MAAM,CAAC;IAC5D,IAAI,CAACI,QAAQ,GAAG,IAAIX,oBAAoB,CAAC,IAAI,CAACM,GAAG,CAAC;IAClD,IAAI,CAACE,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAE1B,IAAI,CAACG,IAAI,CAAC,CAAC;EACb;EAEQA,IAAIA,CAAA,EAAG;IACbf,MAAM,CAAC;MACLgB,KAAK,EAAE,IAAI,CAACX,eAAe;MAC3BY,EAAE,EAAGC,YAAY,KAAM;QAAEA;MAAa,CAAC,CAAC;MACxCC,MAAM,EAAE,IAAI,CAACV,GAAG,CAACW;IACnB,CAAC,CAAC;IAEFpB,MAAM,CAAC;MACLgB,KAAK,EAAE,IAAI,CAACV,WAAW;MACvBW,EAAE,EAAGI,QAAQ,KAAM;QAAEA;MAAS,CAAC,CAAC;MAChCF,MAAM,EAAE,IAAI,CAACV,GAAG,CAACW;IACnB,CAAC,CAAC;IAEFpB,MAAM,CAAC;MACLgB,KAAK,EAAE,IAAI,CAACT,aAAa;MACzBU,EAAE,EAAGK,UAAU,KAAM;QAAEA;MAAW,CAAC,CAAC;MACpCH,MAAM,EAAE,IAAI,CAACV,GAAG,CAACW;IACnB,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The consumer's injected `joinClass` callable rejects with this so the library
|
|
4
|
+
// can map the backend error code to a message without parsing the HTTP error itself.
|
|
5
|
+
export class JoinClassError extends Error {
|
|
6
|
+
constructor(code) {
|
|
7
|
+
super(code === null ? 'Join class failed' : `Join class failed (code ${code})`);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.name = 'JoinClassError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=JoinClassError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["JoinClassError","Error","constructor","code","name"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/JoinClassError.ts"],"mappings":";;AAAA;AACA;AACA,OAAO,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAWA,CAAiBC,IAAmB,EAAE;IAC/C,KAAK,CAACA,IAAI,KAAK,IAAI,GAAG,mBAAmB,GAAG,2BAA2BA,IAAI,GAAG,CAAC;IAAA,KADrDA,IAAmB,GAAnBA,IAAmB;IAE7C,IAAI,CAACC,IAAI,GAAG,gBAAgB;EAC9B;AACF","ignoreList":[]}
|
|
@@ -12,4 +12,17 @@ export const TEXT_SIZE = {
|
|
|
12
12
|
};
|
|
13
13
|
export const CLASS_CODE_LENGTH = 6;
|
|
14
14
|
export const ACCOUNT_VALUE_LONG_THRESHOLD = 24;
|
|
15
|
+
export let JoinClassStatus = /*#__PURE__*/function (JoinClassStatus) {
|
|
16
|
+
JoinClassStatus["SUCCESS"] = "success";
|
|
17
|
+
JoinClassStatus["ERROR"] = "error";
|
|
18
|
+
return JoinClassStatus;
|
|
19
|
+
}({});
|
|
20
|
+
|
|
21
|
+
// Backend error codes the join-class endpoint can return.
|
|
22
|
+
export let JoinClassErrorCode = /*#__PURE__*/function (JoinClassErrorCode) {
|
|
23
|
+
JoinClassErrorCode[JoinClassErrorCode["CLASS_NOT_FOUND"] = 1021] = "CLASS_NOT_FOUND";
|
|
24
|
+
JoinClassErrorCode[JoinClassErrorCode["ALREADY_JOINED"] = 1030] = "ALREADY_JOINED";
|
|
25
|
+
JoinClassErrorCode[JoinClassErrorCode["OTHER_DISTRICT"] = 1035] = "OTHER_DISTRICT";
|
|
26
|
+
return JoinClassErrorCode;
|
|
27
|
+
}({});
|
|
15
28
|
//# sourceMappingURL=profile.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProfileCanvasType","TEXT_SIZE","MIN","MAX","STEP","CLASS_CODE_LENGTH","ACCOUNT_VALUE_LONG_THRESHOLD"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.constants.ts"],"mappings":";;AAAA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAK7B,OAAO,MAAMC,SAAS,GAAG;EACvBC,GAAG,EAAE,EAAE;EACPC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE;AACR,CAAU;AAEV,OAAO,MAAMC,iBAAiB,GAAG,CAAC;AAElC,OAAO,MAAMC,4BAA4B,GAAG,EAAE","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ProfileCanvasType","TEXT_SIZE","MIN","MAX","STEP","CLASS_CODE_LENGTH","ACCOUNT_VALUE_LONG_THRESHOLD","JoinClassStatus","JoinClassErrorCode"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.constants.ts"],"mappings":";;AAAA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAK7B,OAAO,MAAMC,SAAS,GAAG;EACvBC,GAAG,EAAE,EAAE;EACPC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE;AACR,CAAU;AAEV,OAAO,MAAMC,iBAAiB,GAAG,CAAC;AAElC,OAAO,MAAMC,4BAA4B,GAAG,EAAE;AAE9C,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;;AAK3B;AACA,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Language, LANGUAGES_CONFIG, PRIORITY_LANGUAGES } from '@magmamath/frontend-config';
|
|
4
|
-
import {
|
|
4
|
+
import { getText } from "../../../i18n/i18n.js";
|
|
5
|
+
import { ACCOUNT_VALUE_LONG_THRESHOLD, JoinClassErrorCode, TEXT_SIZE } from "./profile.constants.js";
|
|
5
6
|
export const isLanguage = value => Object.values(Language).includes(value);
|
|
6
7
|
export const getAvailableLanguages = search => {
|
|
7
8
|
const prioritySet = new Set(PRIORITY_LANGUAGES);
|
|
@@ -21,4 +22,13 @@ export const snapTextSize = value => {
|
|
|
21
22
|
return Math.round((clamped - MIN) / STEP) * STEP + MIN;
|
|
22
23
|
};
|
|
23
24
|
export const isLongAccountValue = text => text.length > ACCOUNT_VALUE_LONG_THRESHOLD;
|
|
25
|
+
const JOIN_CLASS_ERROR_KEYS = {
|
|
26
|
+
[JoinClassErrorCode.CLASS_NOT_FOUND]: 'profile.joinClassErrorNotFound',
|
|
27
|
+
[JoinClassErrorCode.ALREADY_JOINED]: 'profile.joinClassErrorAlreadyJoined',
|
|
28
|
+
[JoinClassErrorCode.OTHER_DISTRICT]: 'profile.joinClassErrorOtherDistrict'
|
|
29
|
+
};
|
|
30
|
+
export const getJoinClassSuccessMessage = className => getText('profile.joinClassSuccess', {
|
|
31
|
+
className
|
|
32
|
+
});
|
|
33
|
+
export const getJoinClassErrorMessage = code => getText(code !== null && JOIN_CLASS_ERROR_KEYS[code] || 'profile.joinClassErrorDefault');
|
|
24
34
|
//# sourceMappingURL=profile.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Language","LANGUAGES_CONFIG","PRIORITY_LANGUAGES","ACCOUNT_VALUE_LONG_THRESHOLD","TEXT_SIZE","isLanguage","value","Object","values","includes","getAvailableLanguages","search","prioritySet","Set","otherLanguages","filter","language","baseName","has","allLanguages","query","toLowerCase","snapTextSize","MIN","MAX","STEP","clamped","Math","min","max","round","isLongAccountValue","text","length"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.helpers.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAA4B;AAE3F,SAASC,4BAA4B,EAAEC,SAAS,QAAQ,wBAAqB;
|
|
1
|
+
{"version":3,"names":["Language","LANGUAGES_CONFIG","PRIORITY_LANGUAGES","getText","ACCOUNT_VALUE_LONG_THRESHOLD","JoinClassErrorCode","TEXT_SIZE","isLanguage","value","Object","values","includes","getAvailableLanguages","search","prioritySet","Set","otherLanguages","filter","language","baseName","has","allLanguages","query","toLowerCase","snapTextSize","MIN","MAX","STEP","clamped","Math","min","max","round","isLongAccountValue","text","length","JOIN_CLASS_ERROR_KEYS","CLASS_NOT_FOUND","ALREADY_JOINED","OTHER_DISTRICT","getJoinClassSuccessMessage","className","getJoinClassErrorMessage","code"],"sourceRoot":"../../../../../src","sources":["features/profile/shared/profile.helpers.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAA4B;AAE3F,SAASC,OAAO,QAA6B,uBAAoB;AACjE,SAASC,4BAA4B,EAAEC,kBAAkB,EAAEC,SAAS,QAAQ,wBAAqB;AAEjG,OAAO,MAAMC,UAAU,GAAIC,KAAqB,IAC9CC,MAAM,CAACC,MAAM,CAACV,QAAQ,CAAC,CAACW,QAAQ,CAACH,KAAiB,CAAC;AAErD,OAAO,MAAMI,qBAAqB,GAAIC,MAAe,IAAiB;EACpE,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAWb,kBAAkB,CAAC;EAEzD,MAAMc,cAAc,GAAGP,MAAM,CAACC,MAAM,CAACV,QAAQ,CAAC,CAACiB,MAAM,CAClDC,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,IAAI,KAAK,IAAI,IAAIP,qBAAqB,CAACO,IAAI,CAAC,IAAK,+BAA+B,CAAC","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ export type { ProfileContextValue } from './context/ProfileContext';
|
|
|
5
5
|
export { TranslationLanguageModal } from './components/modals/TranslationLanguageModal';
|
|
6
6
|
export { JoinClassModal } from './components/modals/JoinClassModal';
|
|
7
7
|
export type { ProfileModalParams } from './model/profileModal.types';
|
|
8
|
+
export { JoinClassError } from './shared/JoinClassError';
|
|
8
9
|
export * from './shared/profile.types';
|
|
9
10
|
export * from './shared/profile.constants';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JoinClassPayload, JoinClassResult, ProfileSettingsUpdate } from '../shared/profile.types';
|
|
2
2
|
export type ProfileApiProps = {
|
|
3
|
-
updateSettings: (payload: ProfileSettingsUpdate) =>
|
|
3
|
+
updateSettings: (payload: ProfileSettingsUpdate) => void;
|
|
4
4
|
joinClass: (payload: JoinClassPayload) => Promise<JoinClassResult>;
|
|
5
5
|
};
|
|
6
6
|
export declare class ProfileApi {
|
|
7
|
-
readonly updateSettingsFx: import("effector").Effect<Partial<import("../shared/profile.types").ProfileSettings>,
|
|
8
|
-
readonly joinClassFx: import("effector").Effect<JoinClassPayload,
|
|
7
|
+
readonly updateSettingsFx: import("effector").Effect<Partial<import("../shared/profile.types").ProfileSettings>, void, Error>;
|
|
8
|
+
readonly joinClassFx: import("effector").Effect<JoinClassPayload, JoinClassResult, Error>;
|
|
9
9
|
constructor(props: ProfileApiProps);
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=ProfileApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACtB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,eAAe,GAAG;
|
|
1
|
+
{"version":3,"file":"ProfileApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACtB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,eAAe,GAAG;IAG5B,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACxD,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;CACnE,CAAA;AAED,qBAAa,UAAU;IACrB,SAAgB,gBAAgB,qGAAA;IAChC,SAAgB,WAAW,sEAAA;gBAEf,KAAK,EAAE,eAAe;CAInC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { NotifyJoinClass } from '../shared/profile.types';
|
|
1
2
|
import type { ProfileApi } from './ProfileApi';
|
|
2
3
|
export declare class ProfileJoinClassModel {
|
|
3
|
-
private readonly api;
|
|
4
4
|
readonly reset: import("effector").EventCallable<void>;
|
|
5
5
|
readonly setCode: import("effector").EventCallable<string>;
|
|
6
6
|
readonly submit: import("effector").EventCallable<void>;
|
|
7
7
|
readonly $code: import("effector").StoreWritable<string>;
|
|
8
8
|
readonly $isComplete: import("effector").Store<boolean>;
|
|
9
|
-
constructor(api: ProfileApi);
|
|
9
|
+
constructor(api: ProfileApi, notify: NotifyJoinClass);
|
|
10
10
|
private init;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=ProfileJoinClassModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileJoinClassModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileJoinClassModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProfileJoinClassModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileJoinClassModel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,qBAAa,qBAAqB;IAChC,SAAgB,KAAK,yCAAgB;IACrC,SAAgB,OAAO,2CAAwB;IAC/C,SAAgB,MAAM,yCAAgB;IAEtC,SAAgB,KAAK,2CAA8C;IACnE,SAAgB,WAAW,oCAA8D;gBAE7E,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe;IAIpD,OAAO,CAAC,IAAI;CAkCb"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type Store } from 'effector';
|
|
2
2
|
import type { ProfileCanvasType } from '../shared/profile.constants';
|
|
3
|
-
import type { ProfileSettings, ProfileUser } from '../shared/profile.types';
|
|
3
|
+
import type { NotifyJoinClass, ProfileSettings, ProfileUser } from '../shared/profile.types';
|
|
4
4
|
import { ProfileApi, type ProfileApiProps } from './ProfileApi';
|
|
5
5
|
import { ProfileJoinClassModel } from './ProfileJoinClassModel';
|
|
6
6
|
import { ProfileLanguageModel } from './ProfileLanguageModel';
|
|
7
7
|
type ProfileModelProps = {
|
|
8
8
|
api: ProfileApiProps;
|
|
9
|
+
notify: NotifyJoinClass;
|
|
9
10
|
$user: Store<ProfileUser | null>;
|
|
10
11
|
$settings: Store<ProfileSettings>;
|
|
11
12
|
};
|
|
@@ -18,7 +19,7 @@ export declare class ProfileModel {
|
|
|
18
19
|
readonly setCanvasType: import("effector").EventCallable<ProfileCanvasType>;
|
|
19
20
|
readonly $user: Store<ProfileUser | null>;
|
|
20
21
|
readonly $settings: Store<ProfileSettings>;
|
|
21
|
-
constructor({ api, $user, $settings }: ProfileModelProps);
|
|
22
|
+
constructor({ api, notify, $user, $settings }: ProfileModelProps);
|
|
22
23
|
private init;
|
|
23
24
|
}
|
|
24
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,KA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,IAAI;CAmBb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoinClassError.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/JoinClassError.ts"],"names":[],"mappings":"AAEA,qBAAa,cAAe,SAAQ,KAAK;aACX,IAAI,EAAE,MAAM,GAAG,IAAI;gBAAnB,IAAI,EAAE,MAAM,GAAG,IAAI;CAIhD"}
|
|
@@ -9,4 +9,13 @@ export declare const TEXT_SIZE: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const CLASS_CODE_LENGTH = 6;
|
|
11
11
|
export declare const ACCOUNT_VALUE_LONG_THRESHOLD = 24;
|
|
12
|
+
export declare enum JoinClassStatus {
|
|
13
|
+
SUCCESS = "success",
|
|
14
|
+
ERROR = "error"
|
|
15
|
+
}
|
|
16
|
+
export declare enum JoinClassErrorCode {
|
|
17
|
+
CLASS_NOT_FOUND = 1021,
|
|
18
|
+
ALREADY_JOINED = 1030,
|
|
19
|
+
OTHER_DISTRICT = 1035
|
|
20
|
+
}
|
|
12
21
|
//# sourceMappingURL=profile.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.constants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.constants.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,OAAO,IAAI;IACX,WAAW,IAAI;CAChB;AAED,eAAO,MAAM,SAAS;;;;CAIZ,CAAA;AAEV,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,4BAA4B,KAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"profile.constants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.constants.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,OAAO,IAAI;IACX,WAAW,IAAI;CAChB;AAED,eAAO,MAAM,SAAS;;;;CAIZ,CAAA;AAEV,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAGD,oBAAY,kBAAkB;IAC5B,eAAe,OAAO;IACtB,cAAc,OAAO;IACrB,cAAc,OAAO;CACtB"}
|
|
@@ -3,4 +3,6 @@ export declare const isLanguage: (value?: string | null) => value is Language;
|
|
|
3
3
|
export declare const getAvailableLanguages: (search?: string) => Language[];
|
|
4
4
|
export declare const snapTextSize: (value: number) => number;
|
|
5
5
|
export declare const isLongAccountValue: (text: string) => boolean;
|
|
6
|
+
export declare const getJoinClassSuccessMessage: (className: string) => string;
|
|
7
|
+
export declare const getJoinClassErrorMessage: (code: number | null) => string;
|
|
6
8
|
//# sourceMappingURL=profile.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,4BAA4B,CAAA;AAK3F,eAAO,MAAM,UAAU,WAAY,MAAM,GAAG,IAAI,KAAG,KAAK,IAAI,QACP,CAAA;AAErD,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,QAAQ,EAY/D,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MAI5C,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,KAAG,OACN,CAAA;AAQ5C,eAAO,MAAM,0BAA0B,cAAe,MAAM,KAAG,MACX,CAAA;AAEpD,eAAO,MAAM,wBAAwB,SAAU,MAAM,GAAG,IAAI,KAAG,MAC6B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Language } from '@magmamath/frontend-config';
|
|
2
|
-
import type { ProfileCanvasType } from './profile.constants';
|
|
2
|
+
import type { JoinClassStatus, ProfileCanvasType } from './profile.constants';
|
|
3
3
|
export type ProfileUser = {
|
|
4
4
|
fullName: string;
|
|
5
5
|
username: string;
|
|
@@ -16,5 +16,12 @@ export type ProfileSettingsUpdate = Partial<ProfileSettings>;
|
|
|
16
16
|
export type JoinClassPayload = {
|
|
17
17
|
classCode: string;
|
|
18
18
|
};
|
|
19
|
-
export type JoinClassResult =
|
|
19
|
+
export type JoinClassResult = {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
export type JoinClassNotification = {
|
|
23
|
+
status: JoinClassStatus;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export type NotifyJoinClass = (notification: JoinClassNotification) => void;
|
|
20
27
|
//# sourceMappingURL=profile.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE7E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,OAAO,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,QAAQ,GAAG,IAAI,CAAA;IACpC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,mBAAmB,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,qBAAqB,KAAK,IAAI,CAAA"}
|
|
@@ -5,6 +5,7 @@ export type { ProfileContextValue } from './context/ProfileContext';
|
|
|
5
5
|
export { TranslationLanguageModal } from './components/modals/TranslationLanguageModal';
|
|
6
6
|
export { JoinClassModal } from './components/modals/JoinClassModal';
|
|
7
7
|
export type { ProfileModalParams } from './model/profileModal.types';
|
|
8
|
+
export { JoinClassError } from './shared/JoinClassError';
|
|
8
9
|
export * from './shared/profile.types';
|
|
9
10
|
export * from './shared/profile.constants';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JoinClassPayload, JoinClassResult, ProfileSettingsUpdate } from '../shared/profile.types';
|
|
2
2
|
export type ProfileApiProps = {
|
|
3
|
-
updateSettings: (payload: ProfileSettingsUpdate) =>
|
|
3
|
+
updateSettings: (payload: ProfileSettingsUpdate) => void;
|
|
4
4
|
joinClass: (payload: JoinClassPayload) => Promise<JoinClassResult>;
|
|
5
5
|
};
|
|
6
6
|
export declare class ProfileApi {
|
|
7
|
-
readonly updateSettingsFx: import("effector").Effect<Partial<import("../shared/profile.types").ProfileSettings>,
|
|
8
|
-
readonly joinClassFx: import("effector").Effect<JoinClassPayload,
|
|
7
|
+
readonly updateSettingsFx: import("effector").Effect<Partial<import("../shared/profile.types").ProfileSettings>, void, Error>;
|
|
8
|
+
readonly joinClassFx: import("effector").Effect<JoinClassPayload, JoinClassResult, Error>;
|
|
9
9
|
constructor(props: ProfileApiProps);
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=ProfileApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACtB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,eAAe,GAAG;
|
|
1
|
+
{"version":3,"file":"ProfileApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACtB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,eAAe,GAAG;IAG5B,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACxD,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;CACnE,CAAA;AAED,qBAAa,UAAU;IACrB,SAAgB,gBAAgB,qGAAA;IAChC,SAAgB,WAAW,sEAAA;gBAEf,KAAK,EAAE,eAAe;CAInC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { NotifyJoinClass } from '../shared/profile.types';
|
|
1
2
|
import type { ProfileApi } from './ProfileApi';
|
|
2
3
|
export declare class ProfileJoinClassModel {
|
|
3
|
-
private readonly api;
|
|
4
4
|
readonly reset: import("effector").EventCallable<void>;
|
|
5
5
|
readonly setCode: import("effector").EventCallable<string>;
|
|
6
6
|
readonly submit: import("effector").EventCallable<void>;
|
|
7
7
|
readonly $code: import("effector").StoreWritable<string>;
|
|
8
8
|
readonly $isComplete: import("effector").Store<boolean>;
|
|
9
|
-
constructor(api: ProfileApi);
|
|
9
|
+
constructor(api: ProfileApi, notify: NotifyJoinClass);
|
|
10
10
|
private init;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=ProfileJoinClassModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileJoinClassModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileJoinClassModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProfileJoinClassModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileJoinClassModel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,qBAAa,qBAAqB;IAChC,SAAgB,KAAK,yCAAgB;IACrC,SAAgB,OAAO,2CAAwB;IAC/C,SAAgB,MAAM,yCAAgB;IAEtC,SAAgB,KAAK,2CAA8C;IACnE,SAAgB,WAAW,oCAA8D;gBAE7E,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe;IAIpD,OAAO,CAAC,IAAI;CAkCb"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type Store } from 'effector';
|
|
2
2
|
import type { ProfileCanvasType } from '../shared/profile.constants';
|
|
3
|
-
import type { ProfileSettings, ProfileUser } from '../shared/profile.types';
|
|
3
|
+
import type { NotifyJoinClass, ProfileSettings, ProfileUser } from '../shared/profile.types';
|
|
4
4
|
import { ProfileApi, type ProfileApiProps } from './ProfileApi';
|
|
5
5
|
import { ProfileJoinClassModel } from './ProfileJoinClassModel';
|
|
6
6
|
import { ProfileLanguageModel } from './ProfileLanguageModel';
|
|
7
7
|
type ProfileModelProps = {
|
|
8
8
|
api: ProfileApiProps;
|
|
9
|
+
notify: NotifyJoinClass;
|
|
9
10
|
$user: Store<ProfileUser | null>;
|
|
10
11
|
$settings: Store<ProfileSettings>;
|
|
11
12
|
};
|
|
@@ -18,7 +19,7 @@ export declare class ProfileModel {
|
|
|
18
19
|
readonly setCanvasType: import("effector").EventCallable<ProfileCanvasType>;
|
|
19
20
|
readonly $user: Store<ProfileUser | null>;
|
|
20
21
|
readonly $settings: Store<ProfileSettings>;
|
|
21
|
-
constructor({ api, $user, $settings }: ProfileModelProps);
|
|
22
|
+
constructor({ api, notify, $user, $settings }: ProfileModelProps);
|
|
22
23
|
private init;
|
|
23
24
|
}
|
|
24
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"ProfileModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/model/ProfileModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC5F,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,eAAe,CAAA;IACpB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAChC,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;CAClC,CAAA;AAED,qBAAa,YAAY;IACvB,SAAgB,GAAG,EAAE,UAAU,CAAA;IAC/B,SAAgB,SAAS,EAAE,qBAAqB,CAAA;IAChD,SAAgB,QAAQ,EAAE,oBAAoB,CAAA;IAE9C,SAAgB,eAAe,4CAAyB;IACxD,SAAgB,WAAW,2CAAwB;IACnD,SAAgB,aAAa,sDAAmC;IAEhE,SAAgB,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAChD,SAAgB,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;gBAErC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,iBAAiB;IAUhE,OAAO,CAAC,IAAI;CAmBb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoinClassError.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/JoinClassError.ts"],"names":[],"mappings":"AAEA,qBAAa,cAAe,SAAQ,KAAK;aACX,IAAI,EAAE,MAAM,GAAG,IAAI;gBAAnB,IAAI,EAAE,MAAM,GAAG,IAAI;CAIhD"}
|
|
@@ -9,4 +9,13 @@ export declare const TEXT_SIZE: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const CLASS_CODE_LENGTH = 6;
|
|
11
11
|
export declare const ACCOUNT_VALUE_LONG_THRESHOLD = 24;
|
|
12
|
+
export declare enum JoinClassStatus {
|
|
13
|
+
SUCCESS = "success",
|
|
14
|
+
ERROR = "error"
|
|
15
|
+
}
|
|
16
|
+
export declare enum JoinClassErrorCode {
|
|
17
|
+
CLASS_NOT_FOUND = 1021,
|
|
18
|
+
ALREADY_JOINED = 1030,
|
|
19
|
+
OTHER_DISTRICT = 1035
|
|
20
|
+
}
|
|
12
21
|
//# sourceMappingURL=profile.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.constants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.constants.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,OAAO,IAAI;IACX,WAAW,IAAI;CAChB;AAED,eAAO,MAAM,SAAS;;;;CAIZ,CAAA;AAEV,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,4BAA4B,KAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"profile.constants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.constants.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,OAAO,IAAI;IACX,WAAW,IAAI;CAChB;AAED,eAAO,MAAM,SAAS;;;;CAIZ,CAAA;AAEV,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAGD,oBAAY,kBAAkB;IAC5B,eAAe,OAAO;IACtB,cAAc,OAAO;IACrB,cAAc,OAAO;CACtB"}
|
|
@@ -3,4 +3,6 @@ export declare const isLanguage: (value?: string | null) => value is Language;
|
|
|
3
3
|
export declare const getAvailableLanguages: (search?: string) => Language[];
|
|
4
4
|
export declare const snapTextSize: (value: number) => number;
|
|
5
5
|
export declare const isLongAccountValue: (text: string) => boolean;
|
|
6
|
+
export declare const getJoinClassSuccessMessage: (className: string) => string;
|
|
7
|
+
export declare const getJoinClassErrorMessage: (code: number | null) => string;
|
|
6
8
|
//# sourceMappingURL=profile.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,4BAA4B,CAAA;AAK3F,eAAO,MAAM,UAAU,WAAY,MAAM,GAAG,IAAI,KAAG,KAAK,IAAI,QACP,CAAA;AAErD,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,QAAQ,EAY/D,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MAI5C,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,KAAG,OACN,CAAA;AAQ5C,eAAO,MAAM,0BAA0B,cAAe,MAAM,KAAG,MACX,CAAA;AAEpD,eAAO,MAAM,wBAAwB,SAAU,MAAM,GAAG,IAAI,KAAG,MAC6B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Language } from '@magmamath/frontend-config';
|
|
2
|
-
import type { ProfileCanvasType } from './profile.constants';
|
|
2
|
+
import type { JoinClassStatus, ProfileCanvasType } from './profile.constants';
|
|
3
3
|
export type ProfileUser = {
|
|
4
4
|
fullName: string;
|
|
5
5
|
username: string;
|
|
@@ -16,5 +16,12 @@ export type ProfileSettingsUpdate = Partial<ProfileSettings>;
|
|
|
16
16
|
export type JoinClassPayload = {
|
|
17
17
|
classCode: string;
|
|
18
18
|
};
|
|
19
|
-
export type JoinClassResult =
|
|
19
|
+
export type JoinClassResult = {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
export type JoinClassNotification = {
|
|
23
|
+
status: JoinClassStatus;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export type NotifyJoinClass = (notification: JoinClassNotification) => void;
|
|
20
27
|
//# sourceMappingURL=profile.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/profile/shared/profile.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE7E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,OAAO,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,QAAQ,GAAG,IAAI,CAAA;IACpC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,mBAAmB,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,qBAAqB,KAAK,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createStore } from 'effector'
|
|
2
2
|
import { Language } from '@magmamath/frontend-config'
|
|
3
3
|
|
|
4
|
+
import { JoinClassError } from '../shared/JoinClassError'
|
|
4
5
|
import { ProfileModel } from '../model/ProfileModel'
|
|
5
|
-
import { ProfileCanvasType } from '../shared/profile.constants'
|
|
6
|
-
import type { ProfileSettings, ProfileUser } from '../shared/profile.types'
|
|
6
|
+
import { JoinClassStatus, ProfileCanvasType } from '../shared/profile.constants'
|
|
7
|
+
import type { JoinClassResult, ProfileSettings, ProfileUser } from '../shared/profile.types'
|
|
7
8
|
|
|
8
9
|
const baseSettings: ProfileSettings = {
|
|
9
10
|
textToSpeech: false,
|
|
@@ -13,15 +14,16 @@ const baseSettings: ProfileSettings = {
|
|
|
13
14
|
isTranslationLocked: false,
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
const createModel = () => {
|
|
17
|
+
const createModel = (joinClass = jest.fn<Promise<JoinClassResult>, [unknown]>().mockResolvedValue({ name: 'Math' })) => {
|
|
17
18
|
const updateSettings = jest.fn().mockResolvedValue(undefined)
|
|
18
|
-
const
|
|
19
|
+
const notify = jest.fn()
|
|
19
20
|
const model = new ProfileModel({
|
|
20
21
|
api: { updateSettings, joinClass },
|
|
22
|
+
notify,
|
|
21
23
|
$user: createStore<ProfileUser | null>(null),
|
|
22
24
|
$settings: createStore<ProfileSettings>(baseSettings),
|
|
23
25
|
})
|
|
24
|
-
return { model, updateSettings, joinClass }
|
|
26
|
+
return { model, updateSettings, joinClass, notify }
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
describe('ProfileModel settings', () => {
|
|
@@ -65,8 +67,8 @@ describe('ProfileModel join class', () => {
|
|
|
65
67
|
expect(joinClass).not.toHaveBeenCalled()
|
|
66
68
|
})
|
|
67
69
|
|
|
68
|
-
it('submits a complete code and resets
|
|
69
|
-
const { model, joinClass } = createModel()
|
|
70
|
+
it('submits a complete code, notifies success and resets', async () => {
|
|
71
|
+
const { model, joinClass, notify } = createModel()
|
|
70
72
|
model.joinClass.setCode('ABCDEF')
|
|
71
73
|
expect(model.joinClass.$isComplete.getState()).toBe(true)
|
|
72
74
|
|
|
@@ -74,6 +76,24 @@ describe('ProfileModel join class', () => {
|
|
|
74
76
|
expect(joinClass).toHaveBeenCalledWith({ classCode: 'ABCDEF' })
|
|
75
77
|
|
|
76
78
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
79
|
+
expect(notify).toHaveBeenCalledWith(
|
|
80
|
+
expect.objectContaining({ status: JoinClassStatus.SUCCESS })
|
|
81
|
+
)
|
|
77
82
|
expect(model.joinClass.$code.getState()).toBe('')
|
|
78
83
|
})
|
|
84
|
+
|
|
85
|
+
it('notifies an error when the request fails', async () => {
|
|
86
|
+
const joinClass = jest
|
|
87
|
+
.fn<Promise<JoinClassResult>, [unknown]>()
|
|
88
|
+
.mockRejectedValue(new JoinClassError(1021))
|
|
89
|
+
const { model, notify } = createModel(joinClass)
|
|
90
|
+
|
|
91
|
+
model.joinClass.setCode('ABCDEF')
|
|
92
|
+
model.joinClass.submit()
|
|
93
|
+
|
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
95
|
+
expect(notify).toHaveBeenCalledWith(
|
|
96
|
+
expect.objectContaining({ status: JoinClassStatus.ERROR })
|
|
97
|
+
)
|
|
98
|
+
})
|
|
79
99
|
})
|
|
@@ -5,5 +5,6 @@ export type { ProfileContextValue } from './context/ProfileContext'
|
|
|
5
5
|
export { TranslationLanguageModal } from './components/modals/TranslationLanguageModal'
|
|
6
6
|
export { JoinClassModal } from './components/modals/JoinClassModal'
|
|
7
7
|
export type { ProfileModalParams } from './model/profileModal.types'
|
|
8
|
+
export { JoinClassError } from './shared/JoinClassError'
|
|
8
9
|
export * from './shared/profile.types'
|
|
9
10
|
export * from './shared/profile.constants'
|
|
@@ -7,7 +7,9 @@ import type {
|
|
|
7
7
|
} from '../shared/profile.types'
|
|
8
8
|
|
|
9
9
|
export type ProfileApiProps = {
|
|
10
|
-
|
|
10
|
+
// `=> void` (not `=> void | Promise`) so consumers can wire an effector event,
|
|
11
|
+
// an effect, or nothing without tripping TS's union-with-void assignability rule.
|
|
12
|
+
updateSettings: (payload: ProfileSettingsUpdate) => void
|
|
11
13
|
joinClass: (payload: JoinClassPayload) => Promise<JoinClassResult>
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { createEvent, restore, sample } from 'effector'
|
|
1
|
+
import { createEffect, createEvent, restore, sample } from 'effector'
|
|
2
2
|
|
|
3
|
-
import {
|
|
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'
|
|
4
7
|
import type { ProfileApi } from './ProfileApi'
|
|
5
8
|
|
|
6
9
|
export class ProfileJoinClassModel {
|
|
@@ -11,21 +14,41 @@ export class ProfileJoinClassModel {
|
|
|
11
14
|
public readonly $code = restore(this.setCode, '').reset(this.reset)
|
|
12
15
|
public readonly $isComplete = this.$code.map((code) => code.length === CLASS_CODE_LENGTH)
|
|
13
16
|
|
|
14
|
-
constructor(
|
|
15
|
-
this.init()
|
|
17
|
+
constructor(api: ProfileApi, notify: NotifyJoinClass) {
|
|
18
|
+
this.init(api, notify)
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
private init() {
|
|
21
|
+
private init(api: ProfileApi, notify: NotifyJoinClass) {
|
|
22
|
+
const notifyFx = createEffect(notify)
|
|
23
|
+
|
|
19
24
|
sample({
|
|
20
25
|
clock: this.submit,
|
|
21
26
|
source: this.$code,
|
|
22
27
|
filter: (code) => code.length === CLASS_CODE_LENGTH,
|
|
23
28
|
fn: (classCode) => ({ classCode }),
|
|
24
|
-
target:
|
|
29
|
+
target: api.joinClassFx,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
sample({
|
|
33
|
+
clock: api.joinClassFx.done,
|
|
34
|
+
fn: ({ result }) => ({
|
|
35
|
+
status: JoinClassStatus.SUCCESS,
|
|
36
|
+
message: getJoinClassSuccessMessage(result.name),
|
|
37
|
+
}),
|
|
38
|
+
target: notifyFx,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
sample({
|
|
42
|
+
clock: api.joinClassFx.fail,
|
|
43
|
+
fn: ({ error }) => ({
|
|
44
|
+
status: JoinClassStatus.ERROR,
|
|
45
|
+
message: getJoinClassErrorMessage(error instanceof JoinClassError ? error.code : null),
|
|
46
|
+
}),
|
|
47
|
+
target: notifyFx,
|
|
25
48
|
})
|
|
26
49
|
|
|
27
50
|
sample({
|
|
28
|
-
clock:
|
|
51
|
+
clock: api.joinClassFx.done,
|
|
29
52
|
target: this.reset,
|
|
30
53
|
})
|
|
31
54
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createEvent, sample, type Store } from 'effector'
|
|
2
2
|
|
|
3
3
|
import type { ProfileCanvasType } from '../shared/profile.constants'
|
|
4
|
-
import type { ProfileSettings, ProfileUser } from '../shared/profile.types'
|
|
4
|
+
import type { NotifyJoinClass, ProfileSettings, ProfileUser } from '../shared/profile.types'
|
|
5
5
|
import { ProfileApi, type ProfileApiProps } from './ProfileApi'
|
|
6
6
|
import { ProfileJoinClassModel } from './ProfileJoinClassModel'
|
|
7
7
|
import { ProfileLanguageModel } from './ProfileLanguageModel'
|
|
8
8
|
|
|
9
9
|
type ProfileModelProps = {
|
|
10
10
|
api: ProfileApiProps
|
|
11
|
+
notify: NotifyJoinClass
|
|
11
12
|
$user: Store<ProfileUser | null>
|
|
12
13
|
$settings: Store<ProfileSettings>
|
|
13
14
|
}
|
|
@@ -24,9 +25,9 @@ export class ProfileModel {
|
|
|
24
25
|
public readonly $user: Store<ProfileUser | null>
|
|
25
26
|
public readonly $settings: Store<ProfileSettings>
|
|
26
27
|
|
|
27
|
-
constructor({ api, $user, $settings }: ProfileModelProps) {
|
|
28
|
+
constructor({ api, notify, $user, $settings }: ProfileModelProps) {
|
|
28
29
|
this.api = new ProfileApi(api)
|
|
29
|
-
this.joinClass = new ProfileJoinClassModel(this.api)
|
|
30
|
+
this.joinClass = new ProfileJoinClassModel(this.api, notify)
|
|
30
31
|
this.language = new ProfileLanguageModel(this.api)
|
|
31
32
|
this.$user = $user
|
|
32
33
|
this.$settings = $settings
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The consumer's injected `joinClass` callable rejects with this so the library
|
|
2
|
+
// can map the backend error code to a message without parsing the HTTP error itself.
|
|
3
|
+
export class JoinClassError extends Error {
|
|
4
|
+
constructor(public readonly code: number | null) {
|
|
5
|
+
super(code === null ? 'Join class failed' : `Join class failed (code ${code})`)
|
|
6
|
+
this.name = 'JoinClassError'
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -12,3 +12,15 @@ export const TEXT_SIZE = {
|
|
|
12
12
|
export const CLASS_CODE_LENGTH = 6
|
|
13
13
|
|
|
14
14
|
export const ACCOUNT_VALUE_LONG_THRESHOLD = 24
|
|
15
|
+
|
|
16
|
+
export enum JoinClassStatus {
|
|
17
|
+
SUCCESS = 'success',
|
|
18
|
+
ERROR = 'error',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Backend error codes the join-class endpoint can return.
|
|
22
|
+
export enum JoinClassErrorCode {
|
|
23
|
+
CLASS_NOT_FOUND = 1021,
|
|
24
|
+
ALREADY_JOINED = 1030,
|
|
25
|
+
OTHER_DISTRICT = 1035,
|
|
26
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Language, LANGUAGES_CONFIG, PRIORITY_LANGUAGES } from '@magmamath/frontend-config'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getText, type TranslationKey } from '../../../i18n/i18n'
|
|
4
|
+
import { ACCOUNT_VALUE_LONG_THRESHOLD, JoinClassErrorCode, TEXT_SIZE } from './profile.constants'
|
|
4
5
|
|
|
5
6
|
export const isLanguage = (value?: string | null): value is Language =>
|
|
6
7
|
Object.values(Language).includes(value as Language)
|
|
@@ -27,3 +28,15 @@ export const snapTextSize = (value: number): number => {
|
|
|
27
28
|
|
|
28
29
|
export const isLongAccountValue = (text: string): boolean =>
|
|
29
30
|
text.length > ACCOUNT_VALUE_LONG_THRESHOLD
|
|
31
|
+
|
|
32
|
+
const JOIN_CLASS_ERROR_KEYS: Record<number, TranslationKey> = {
|
|
33
|
+
[JoinClassErrorCode.CLASS_NOT_FOUND]: 'profile.joinClassErrorNotFound',
|
|
34
|
+
[JoinClassErrorCode.ALREADY_JOINED]: 'profile.joinClassErrorAlreadyJoined',
|
|
35
|
+
[JoinClassErrorCode.OTHER_DISTRICT]: 'profile.joinClassErrorOtherDistrict',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const getJoinClassSuccessMessage = (className: string): string =>
|
|
39
|
+
getText('profile.joinClassSuccess', { className })
|
|
40
|
+
|
|
41
|
+
export const getJoinClassErrorMessage = (code: number | null): string =>
|
|
42
|
+
getText((code !== null && JOIN_CLASS_ERROR_KEYS[code]) || 'profile.joinClassErrorDefault')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Language } from '@magmamath/frontend-config'
|
|
2
2
|
|
|
3
|
-
import type { ProfileCanvasType } from './profile.constants'
|
|
3
|
+
import type { JoinClassStatus, ProfileCanvasType } from './profile.constants'
|
|
4
4
|
|
|
5
5
|
export type ProfileUser = {
|
|
6
6
|
fullName: string
|
|
@@ -22,4 +22,14 @@ export type JoinClassPayload = {
|
|
|
22
22
|
classCode: string
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export type JoinClassResult =
|
|
25
|
+
export type JoinClassResult = {
|
|
26
|
+
name: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The library decides the outcome + (translated) message; the consumer only renders it.
|
|
30
|
+
export type JoinClassNotification = {
|
|
31
|
+
status: JoinClassStatus
|
|
32
|
+
message: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type NotifyJoinClass = (notification: JoinClassNotification) => void
|
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
"changePasswordNote": "Ask your teacher if you need to change password",
|
|
60
60
|
"fullName": "Full name",
|
|
61
61
|
"joinClassButton": "Join new class",
|
|
62
|
+
"joinClassErrorAlreadyJoined": "You have already joined this class",
|
|
63
|
+
"joinClassErrorDefault": "Default error! Code not found",
|
|
64
|
+
"joinClassErrorNotFound": "The class doesn’t exist, try another class code",
|
|
65
|
+
"joinClassErrorOtherDistrict": "You can only join classes in your district",
|
|
66
|
+
"joinClassSuccess": "You have joined class {{className}}",
|
|
62
67
|
"joinClassTitle": "Write your new class code",
|
|
63
68
|
"joinNewClass": "Join a new class",
|
|
64
69
|
"languageSettings": "Language settings",
|