@glissandoo/lib 1.3.16 → 1.3.18
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/helpers/plans.d.ts +12 -0
- package/helpers/plans.js +16 -0
- package/models/Group/index.d.ts +3 -2
- package/models/Group/index.js +8 -0
- package/package.json +1 -1
package/helpers/plans.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.membersPerPlan = exports.PlansGroup = void 0;
|
|
4
|
+
var PlansGroup;
|
|
5
|
+
(function (PlansGroup) {
|
|
6
|
+
PlansGroup["Piano"] = "piano";
|
|
7
|
+
PlansGroup["Mezzo"] = "mezzo";
|
|
8
|
+
PlansGroup["Forte"] = "forte";
|
|
9
|
+
PlansGroup["Tutti"] = "tutti";
|
|
10
|
+
})(PlansGroup = exports.PlansGroup || (exports.PlansGroup = {}));
|
|
11
|
+
exports.membersPerPlan = {
|
|
12
|
+
[PlansGroup.Piano]: 10,
|
|
13
|
+
[PlansGroup.Mezzo]: 30,
|
|
14
|
+
[PlansGroup.Forte]: 60,
|
|
15
|
+
[PlansGroup.Tutti]: 1000,
|
|
16
|
+
};
|
package/models/Group/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
|
|
2
2
|
import { LanguagesTypes } from '../../lang';
|
|
3
3
|
import GroupBasic from './basic';
|
|
4
|
-
import { GroupData, SocialNetwork } from './types';
|
|
4
|
+
import { GroupData, GroupStatus, SocialNetwork } from './types';
|
|
5
5
|
export default class Group extends GroupBasic<GroupData> {
|
|
6
6
|
constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
|
|
7
7
|
get owner(): DocumentReference;
|
|
@@ -36,7 +36,7 @@ export default class Group extends GroupBasic<GroupData> {
|
|
|
36
36
|
getSocialNetworkUrl(id: SocialNetwork): string | null;
|
|
37
37
|
get config(): Record<import("./types").GroupConfig, boolean>;
|
|
38
38
|
get templates(): Record<string, import("./types").GroupTemplateData>;
|
|
39
|
-
get status():
|
|
39
|
+
get status(): GroupStatus;
|
|
40
40
|
get templatesList(): (import("./types").GroupTemplateData & {
|
|
41
41
|
id: string;
|
|
42
42
|
})[];
|
|
@@ -47,4 +47,5 @@ export default class Group extends GroupBasic<GroupData> {
|
|
|
47
47
|
getPlayer: (userId: string) => import("../Player/types").PlayerBasicData | null;
|
|
48
48
|
isAdmin: (userId: string) => boolean;
|
|
49
49
|
isPlayer: (userId: string) => boolean;
|
|
50
|
+
get isExpiredTrial(): boolean;
|
|
50
51
|
}
|
package/models/Group/index.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const date_fns_1 = require("date-fns");
|
|
6
7
|
const lodash_1 = require("lodash");
|
|
7
8
|
const orders_1 = require("../../helpers/musicStyles/orders");
|
|
9
|
+
const plans_1 = require("../../helpers/plans");
|
|
8
10
|
const lang_1 = require("../../lang");
|
|
9
11
|
const basic_1 = __importDefault(require("./basic"));
|
|
10
12
|
const types_1 = require("./types");
|
|
@@ -132,5 +134,11 @@ class Group extends basic_1.default {
|
|
|
132
134
|
get satisfactionIndex() {
|
|
133
135
|
return this.data.satisfactionIndex || { current: 0, last: 0 };
|
|
134
136
|
}
|
|
137
|
+
get isExpiredTrial() {
|
|
138
|
+
const isOutDateTrial = date_fns_1.isBefore(this.createdAt.toDate(), date_fns_1.subMonths(new Date(), 1));
|
|
139
|
+
const members = this.activePlayers.length;
|
|
140
|
+
const isAboveMembersLimitPlanFree = members >= plans_1.membersPerPlan[plans_1.PlansGroup.Piano];
|
|
141
|
+
return this.status !== types_1.GroupStatus.Premium && isOutDateTrial && isAboveMembersLimitPlanFree;
|
|
142
|
+
}
|
|
135
143
|
}
|
|
136
144
|
exports.default = Group;
|