@glissandoo/lib 1.68.0 → 1.70.0

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.
@@ -1,4 +1,5 @@
1
1
  import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
+ import { CustomerData } from '../models/Customer/types';
2
3
  export declare namespace CustomerFbFunctionsTypes {
3
4
  interface PublishParams {
4
5
  customerId: string;
@@ -69,4 +70,21 @@ export declare namespace CustomerFbFunctionsTypes {
69
70
  interface GetInvoicesResult {
70
71
  invoices: InvoiceItem[];
71
72
  }
73
+ interface CustomerItem {
74
+ id: string;
75
+ displayName: CustomerData['displayName'];
76
+ displayAddress: string;
77
+ CIF: CustomerData['CIF'];
78
+ stripeId: CustomerData['stripeId'];
79
+ }
80
+ interface GetByGroupParams {
81
+ groupId: string;
82
+ }
83
+ interface GetByGroupResult {
84
+ customer: CustomerItem;
85
+ }
86
+ type GetByUserParams = void;
87
+ interface GetByUserResult {
88
+ customers: CustomerItem[];
89
+ }
72
90
  }
@@ -5,6 +5,8 @@ export declare enum FbFunctionName {
5
5
  CustomerCreate = "customer-create",
6
6
  CustomerRemove = "customer-remove",
7
7
  CustomerEdit = "customer-edit",
8
+ CustomerGetByGroup = "customer-getByGroup",
9
+ CustomerGetByUser = "customer-getByUser",
8
10
  CustomerGetInvoices = "customer-getInvoices",
9
11
  CustomerGetGocardlessMandate = "customer-getGocardlessMandate",
10
12
  CustomerOnUpdate = "customer-onUpdate",
@@ -9,6 +9,8 @@ var FbFunctionName;
9
9
  FbFunctionName["CustomerCreate"] = "customer-create";
10
10
  FbFunctionName["CustomerRemove"] = "customer-remove";
11
11
  FbFunctionName["CustomerEdit"] = "customer-edit";
12
+ FbFunctionName["CustomerGetByGroup"] = "customer-getByGroup";
13
+ FbFunctionName["CustomerGetByUser"] = "customer-getByUser";
12
14
  FbFunctionName["CustomerGetInvoices"] = "customer-getInvoices";
13
15
  FbFunctionName["CustomerGetGocardlessMandate"] = "customer-getGocardlessMandate";
14
16
  FbFunctionName["CustomerOnUpdate"] = "customer-onUpdate";
@@ -22,6 +22,8 @@ const regionByFunctions = {
22
22
  [index_1.FbFunctionName.CustomerCreate]: GCloudRegions.EuropeWest6,
23
23
  [index_1.FbFunctionName.CustomerRemove]: GCloudRegions.EuropeWest6,
24
24
  [index_1.FbFunctionName.CustomerEdit]: GCloudRegions.EuropeWest6,
25
+ [index_1.FbFunctionName.CustomerGetByGroup]: GCloudRegions.EuropeWest6,
26
+ [index_1.FbFunctionName.CustomerGetByUser]: GCloudRegions.EuropeWest6,
25
27
  [index_1.FbFunctionName.CustomerGetInvoices]: GCloudRegions.EuropeWest6,
26
28
  [index_1.FbFunctionName.CustomerGetGocardlessMandate]: GCloudRegions.EuropeWest6,
27
29
  [index_1.FbFunctionName.CustomerOnUpdate]: GCloudRegions.EuropeWest6,
@@ -66,6 +66,7 @@ export default class Group extends GroupBasic<GroupData> {
66
66
  isAdmin: (userId: string) => boolean;
67
67
  isPlayer: (userId: string) => boolean;
68
68
  get isExpiredTrial(): boolean;
69
+ get isOutOfMembersLimit(): boolean;
69
70
  get isUpgradePlanRequired(): boolean;
70
71
  get firstAnswerAt(): FirebaseFirestore.Timestamp | null;
71
72
  get repertoireTags(): Record<string, import("./types").GroupRepertoireTag>;
@@ -179,10 +179,16 @@ class Group extends basic_1.default {
179
179
  const isAboveMembersLimitPlanFree = members > plans_1.membersPerPlan[plans_1.PlansGroup.Piano];
180
180
  return this.status !== types_1.GroupStatus.Premium && isOutDateTrial && isAboveMembersLimitPlanFree;
181
181
  }
182
- get isUpgradePlanRequired() {
182
+ get isOutOfMembersLimit() {
183
183
  const members = this.activePlayers.length;
184
184
  return members > plans_1.membersPerPlan[this.planId];
185
185
  }
186
+ get isUpgradePlanRequired() {
187
+ const graceMembers = 4;
188
+ const planMembers = plans_1.membersPerPlan[this.planId] + graceMembers;
189
+ const members = this.activePlayers.length;
190
+ return members > planMembers;
191
+ }
186
192
  get firstAnswerAt() {
187
193
  return this.data.firstAnswerAt || null;
188
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.68.0",
3
+ "version": "1.70.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",