@glissandoo/lib 1.39.3 → 1.40.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.
- package/functions/group.d.ts +2 -1
- package/helpers/fileSections/orders.js +1 -1
- package/helpers/musicStyles/index.d.ts +2 -0
- package/helpers/musicStyles/index.js +15 -1
- package/helpers/musicStyles/orders.js +1 -1
- package/helpers/{notifications/index.d.ts → notifications.d.ts} +4 -4
- package/helpers/{notifications/index.js → notifications.js} +3 -3
- package/helpers/slate.d.ts +0 -1
- package/helpers/slate.js +0 -18
- package/helpers/utils.d.ts +8 -4
- package/helpers/utils.js +94 -4
- package/lang/ca.json +35 -26
- package/lang/de.json +36 -27
- package/lang/en.json +35 -26
- package/lang/es.json +35 -26
- package/lang/eu.json +35 -26
- package/lang/gl.json +37 -28
- package/lang/pt.json +35 -26
- package/models/Communication/index.js +2 -2
- package/models/Group/index.d.ts +1 -0
- package/models/Group/index.js +3 -0
- package/models/Group/types.d.ts +6 -0
- package/models/Group/types.js +7 -1
- package/models/User/Notification/index.js +3 -3
- package/package.json +3 -3
- package/helpers/notifications/placeholders.d.ts +0 -4
- package/helpers/notifications/placeholders.js +0 -80
package/lang/pt.json
CHANGED
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
"communication.create.title": "Nova publicação",
|
|
20
20
|
"communication.newComment.text": "{string:user.0.displayName} comentou uma publicação",
|
|
21
21
|
"communication.newComment.title": "Novo comentário",
|
|
22
|
+
"emails.biweeklyEventReminder.attendance.confirm": "Confirm",
|
|
23
|
+
"emails.biweeklyEventReminder.attendance.confirmed": "Going 😎",
|
|
24
|
+
"emails.biweeklyEventReminder.attendance.decline": "Decline",
|
|
25
|
+
"emails.biweeklyEventReminder.attendance.declined": "Not going 🥲",
|
|
26
|
+
"emails.biweeklyEventReminder.intro": "Hi {name}, here is a summary of the events you can't miss!",
|
|
27
|
+
"emails.biweeklyEventReminder.subject": "Don't miss these events!",
|
|
28
|
+
"emails.biweeklyEventReminder.title": "Events Summary",
|
|
29
|
+
"emails.common.footer.contact": "If you have any doubts, please don't hesitate to contact us.\nOur email is hello@glissandoo.com.",
|
|
30
|
+
"emails.common.footer.rights": "© 2023 Glissandoo.com, All rights reserved.",
|
|
22
31
|
"event": "Evento",
|
|
23
32
|
"group.delete.text": "O grupo {string:group.0.displayName} foi excluído",
|
|
24
33
|
"group.delete.title": "Grupo excluído",
|
|
@@ -152,13 +161,13 @@
|
|
|
152
161
|
"performance.edit.stage.title": "Concerto - o plano de veiculação mudou",
|
|
153
162
|
"performance.edit.title.text": "O título de {string:event.0.displayName} foi atualizado",
|
|
154
163
|
"performance.edit.title.title": "Concerto - o título mudou",
|
|
155
|
-
"performance.eveningReminder.confirm.text": "{string:event.0.displayName} de {string:group.0.displayName} amanhã às {date:event.0.
|
|
164
|
+
"performance.eveningReminder.confirm.text": "{string:event.0.displayName} de {string:group.0.displayName} amanhã às {date:event.0.datetime:time}",
|
|
156
165
|
"performance.eveningReminder.confirm.title": "Lembrete de concerto",
|
|
157
|
-
"performance.eveningReminder.pending.text": "Confirme sua presença para {string:event.0.displayName} de {string:group.0.displayName} amanhã às {date:event.0.
|
|
166
|
+
"performance.eveningReminder.pending.text": "Confirme sua presença para {string:event.0.displayName} de {string:group.0.displayName} amanhã às {date:event.0.datetime:time}",
|
|
158
167
|
"performance.eveningReminder.pending.title": "Lembrete do concerto",
|
|
159
|
-
"performance.morningReminder.confirm.text": "{string:event.0.displayName} de {string:group.0.displayName} hoje em {date:event.0.
|
|
168
|
+
"performance.morningReminder.confirm.text": "{string:event.0.displayName} de {string:group.0.displayName} hoje em {date:event.0.datetime:time}",
|
|
160
169
|
"performance.morningReminder.confirm.title": "Lembrete do concerto",
|
|
161
|
-
"performance.morningReminder.pending.text": "Confirme sua presença para {string:event.0.displayName} de {string:group.0.displayName} hoje em {date:event.0.
|
|
170
|
+
"performance.morningReminder.pending.text": "Confirme sua presença para {string:event.0.displayName} de {string:group.0.displayName} hoje em {date:event.0.datetime:time}",
|
|
162
171
|
"performance.morningReminder.pending.title": "Lembrete do concerto",
|
|
163
172
|
"performance.players.add.text": "Você foi adicionado a {string:event.0.displayName}",
|
|
164
173
|
"performance.players.add.title": "Novo concerto",
|
|
@@ -169,47 +178,47 @@
|
|
|
169
178
|
"performance.rollCallReminder.text": "Agora é o melhor momento para fazer uma votação.",
|
|
170
179
|
"performance.rollCallReminder.title": "Você pode fazer uma votação para o ensaio",
|
|
171
180
|
"practice": "Ensaio",
|
|
172
|
-
"practice.assistance.confirm.text": "{string:user.0.displayName} confirmou a participação no ensaio em {date:event.0.
|
|
181
|
+
"practice.assistance.confirm.text": "{string:user.0.displayName} confirmou a participação no ensaio em {date:event.0.datetime:date}",
|
|
173
182
|
"practice.assistance.confirm.title": "Presença confirmada",
|
|
174
|
-
"practice.assistance.decline.text": "{string:user.0.displayName} recusou a participação no ensaio em {date:event.0.
|
|
183
|
+
"practice.assistance.decline.text": "{string:user.0.displayName} recusou a participação no ensaio em {date:event.0.datetime:date}",
|
|
175
184
|
"practice.assistance.decline.title": "Participação recusada",
|
|
176
|
-
"practice.cancel.text": "{date:event.0.
|
|
185
|
+
"practice.cancel.text": "{date:event.0.datetime:date} ensaio de {string:group.0.displayName} foi cancelado",
|
|
177
186
|
"practice.cancel.title": "Ensaio cancelado",
|
|
178
|
-
"practice.create.text": "Um novo ensaio de {string:group.0.displayName} em {date:event.0.
|
|
187
|
+
"practice.create.text": "Um novo ensaio de {string:group.0.displayName} em {date:event.0.datetime:datetime} foi adicionado",
|
|
179
188
|
"practice.create.title": "Novo ensaio",
|
|
180
|
-
"practice.edit.attendance.text": "O limite de presenças no ensaio para o {date:event.0.
|
|
189
|
+
"practice.edit.attendance.text": "O limite de presenças no ensaio para o {date:event.0.datetime:date} foi atualizado",
|
|
181
190
|
"practice.edit.attendance.title": "Ensaio - limite de presenças alterado",
|
|
182
|
-
"practice.edit.comments.text": "A descrição do ensaio {date:event.0.
|
|
191
|
+
"practice.edit.comments.text": "A descrição do ensaio {date:event.0.datetime:date} foi atualizada",
|
|
183
192
|
"practice.edit.comments.title": "Ensaio - a descrição mudou",
|
|
184
|
-
"practice.edit.datetime.text": "A programação para o ensaio {date:event.0.
|
|
193
|
+
"practice.edit.datetime.text": "A programação para o ensaio {date:event.0.datetime:date} foi modificada",
|
|
185
194
|
"practice.edit.datetime.title": "Ensaio - horário alterado",
|
|
186
|
-
"practice.edit.locality.text": "O endereço do ensaio de {date:event.0.
|
|
195
|
+
"practice.edit.locality.text": "O endereço do ensaio de {date:event.0.datetime:date} foi atualizado",
|
|
187
196
|
"practice.edit.locality.title": "Ensaio - endereço alterado",
|
|
188
|
-
"practice.edit.repertory.text": "O repertório para o ensaio {date:event.0.
|
|
197
|
+
"practice.edit.repertory.text": "O repertório para o ensaio {date:event.0.datetime:date} foi atualizado",
|
|
189
198
|
"practice.edit.repertory.title": "Ensaio - repertório alterado",
|
|
190
|
-
"practice.edit.stage.text": "O plano de veiculação para o ensaio {date:event.0.
|
|
199
|
+
"practice.edit.stage.text": "O plano de veiculação para o ensaio {date:event.0.datetime:date} foi atualizado",
|
|
191
200
|
"practice.edit.stage.title": "Ensaio - mudança de plano de veiculação",
|
|
192
|
-
"practice.edit.title.text": "O título do ensaio {date:event.0.
|
|
201
|
+
"practice.edit.title.text": "O título do ensaio {date:event.0.datetime:date} foi atualizado",
|
|
193
202
|
"practice.edit.title.title": "Ensaio - título alterado",
|
|
194
|
-
"practice.eveningReminder.confirm.text": "{string:group.0.displayName} ensaio amanhã às {date:event.0.
|
|
203
|
+
"practice.eveningReminder.confirm.text": "{string:group.0.displayName} ensaio amanhã às {date:event.0.datetime:time}",
|
|
195
204
|
"practice.eveningReminder.confirm.title": "Lembrete de ensaio",
|
|
196
|
-
"practice.eveningReminder.pending.text": "Confirme sua presença no ensaio de {string:group.0.displayName} amanhã às {date:event.0.
|
|
205
|
+
"practice.eveningReminder.pending.text": "Confirme sua presença no ensaio de {string:group.0.displayName} amanhã às {date:event.0.datetime:time}",
|
|
197
206
|
"practice.eveningReminder.pending.title": "Lembrete de ensaio",
|
|
198
|
-
"practice.morningReminder.confirm.text": "{string:group.0.displayName} ensaio hoje em {date:event.0.
|
|
207
|
+
"practice.morningReminder.confirm.text": "{string:group.0.displayName} ensaio hoje em {date:event.0.datetime:time}",
|
|
199
208
|
"practice.morningReminder.confirm.title": "Lembrete de ensaio",
|
|
200
|
-
"practice.morningReminder.pending.text": "Confirme sua participação no ensaio {string:group.0.displayName} hoje em {date:event.0.
|
|
209
|
+
"practice.morningReminder.pending.text": "Confirme sua participação no ensaio {string:group.0.displayName} hoje em {date:event.0.datetime:time}",
|
|
201
210
|
"practice.morningReminder.pending.title": "Lembrete de ensaio",
|
|
202
|
-
"practice.players.add.text": "Você foi adicionado a {string:group.0.displayName} em {date:event.0.
|
|
211
|
+
"practice.players.add.text": "Você foi adicionado a {string:group.0.displayName} em {date:event.0.datetime:datetime}",
|
|
203
212
|
"practice.players.add.title": "Novo ensaio",
|
|
204
|
-
"practice.players.remove.text": "Você foi removido de {string:group.0.displayName} em {date:event.0.
|
|
213
|
+
"practice.players.remove.text": "Você foi removido de {string:group.0.displayName} em {date:event.0.datetime:date}",
|
|
205
214
|
"practice.players.remove.title": "Ensaio removido",
|
|
206
|
-
"practice.reminder.text": "Você precisa de confirmar a presença no {date:event.0.
|
|
215
|
+
"practice.reminder.text": "Você precisa de confirmar a presença no {date:event.0.datetime:datetime} de {string:group.0.displayName, please}",
|
|
207
216
|
"practice.reminder.title": "Por favor, confirme sua presença",
|
|
208
217
|
"practice.rollCallReminder.text": "Agora é o melhor momento para fazer uma votação",
|
|
209
218
|
"practice.rollCallReminder.title": "Você pode fazer uma votação no seu último ensaio.",
|
|
210
|
-
"practices.cancel.text": "{string:extra.num} ensaios do {string:group.0.displayName} entre {date:event.0.
|
|
219
|
+
"practices.cancel.text": "{string:extra.num} ensaios do {string:group.0.displayName} entre {date:event.0.datetime:shortDate} e {date:event.1.datetime:shortDate} foram cancelados",
|
|
211
220
|
"practices.cancel.title": "Ensaios cancelados",
|
|
212
|
-
"practices.create.text": "{string:extra.num} novos ensaios de {string:group.0.displayName} entre {date:event.0.
|
|
221
|
+
"practices.create.text": "{string:extra.num} novos ensaios de {string:group.0.displayName} entre {date:event.0.datetime:shortDate} e {date:event.1.datetime:shortDate} foram adicionados",
|
|
213
222
|
"practices.create.title": "Novos ensaios",
|
|
214
223
|
"practices.edit.attendance.text": "O limite de presenças foi atualizado em vários ensaios",
|
|
215
224
|
"practices.edit.attendance.title": "Ensaios - limite de participação alterado",
|
|
@@ -225,9 +234,9 @@
|
|
|
225
234
|
"practices.edit.stage.title": "Ensaios - mudança de plano de veiculação",
|
|
226
235
|
"practices.edit.title.text": "O título foi atualizado em vários ensaios",
|
|
227
236
|
"practices.edit.title.title": "Ensaios - título alterado",
|
|
228
|
-
"practices.players.add.text": "Você foi adicionado a vários ensaios entre {date:event.0.
|
|
237
|
+
"practices.players.add.text": "Você foi adicionado a vários ensaios entre {date:event.0.datetime:shortDate} e {date:event.1.datetime:shortDate}",
|
|
229
238
|
"practices.players.add.title": "Novos ensaios",
|
|
230
|
-
"practices.players.remove.text": "Você foi removido de vários ensaios entre {date:event.0.
|
|
239
|
+
"practices.players.remove.text": "Você foi removido de vários ensaios entre {date:event.0.datetime:shortDate} e {date:event.1.datetime:shortDate}",
|
|
231
240
|
"practices.players.remove.title": "Ensaios removidos",
|
|
232
241
|
"repertoireTags.1": "1º",
|
|
233
242
|
"repertoireTags.2": "2º",
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
-
const
|
|
7
|
+
const utils_1 = require("../../helpers/utils");
|
|
8
8
|
const lang_1 = require("../../lang");
|
|
9
9
|
const lang_2 = __importDefault(require("../Model/lang"));
|
|
10
10
|
const types_1 = require("./types");
|
|
@@ -76,7 +76,7 @@ class Communication extends lang_2.default {
|
|
|
76
76
|
return !this.isDeleted;
|
|
77
77
|
}
|
|
78
78
|
get plainText() {
|
|
79
|
-
return (0,
|
|
79
|
+
return (0, utils_1.serializeSlateBlock)(this.message);
|
|
80
80
|
}
|
|
81
81
|
get createdAt() {
|
|
82
82
|
return this.data.createdAt;
|
package/models/Group/index.d.ts
CHANGED
package/models/Group/index.js
CHANGED
|
@@ -185,5 +185,8 @@ class Group extends basic_1.default {
|
|
|
185
185
|
get glissandooAdminUrl() {
|
|
186
186
|
return (0, glissandooAdmin_1.getGlissandooAdminEntityURL)(collections_1.CollectionNames.Group, this.id);
|
|
187
187
|
}
|
|
188
|
+
get createdOn() {
|
|
189
|
+
return this.data.createdOn;
|
|
190
|
+
}
|
|
188
191
|
}
|
|
189
192
|
exports.default = Group;
|
package/models/Group/types.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { StageTemplate } from '../../helpers/types';
|
|
|
4
4
|
import { DocumentReference, GeoPoint, Timestamp } from '../../types/firestore';
|
|
5
5
|
import { EventType } from '../Evento/types';
|
|
6
6
|
import { PlayerBasicData } from '../Player/types';
|
|
7
|
+
export declare enum GroupCreatedOn {
|
|
8
|
+
Web = "web",
|
|
9
|
+
App = "app",
|
|
10
|
+
Dashboard = "dashboard"
|
|
11
|
+
}
|
|
7
12
|
export declare enum GroupConfig {
|
|
8
13
|
IncludesMembersToEventsWhenJoined = "includesMembersToEventsWhenJoined"
|
|
9
14
|
}
|
|
@@ -111,6 +116,7 @@ export interface GroupData extends GroupBasicData {
|
|
|
111
116
|
firstAnswerAt: Timestamp | null;
|
|
112
117
|
repertoireTags: Record<string, GroupRepertoireTag>;
|
|
113
118
|
trialEndAt: Timestamp | null;
|
|
119
|
+
readonly createdOn: GroupCreatedOn;
|
|
114
120
|
readonly owner: DocumentReference;
|
|
115
121
|
readonly createdAt: Timestamp;
|
|
116
122
|
}
|
package/models/Group/types.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GroupRepertoireTagDefault = exports.GroupRepertoireTagReserved = exports.SocialNetwork = exports.GroupStatus = exports.GroupConfig = void 0;
|
|
3
|
+
exports.GroupRepertoireTagDefault = exports.GroupRepertoireTagReserved = exports.SocialNetwork = exports.GroupStatus = exports.GroupConfig = exports.GroupCreatedOn = void 0;
|
|
4
|
+
var GroupCreatedOn;
|
|
5
|
+
(function (GroupCreatedOn) {
|
|
6
|
+
GroupCreatedOn["Web"] = "web";
|
|
7
|
+
GroupCreatedOn["App"] = "app";
|
|
8
|
+
GroupCreatedOn["Dashboard"] = "dashboard";
|
|
9
|
+
})(GroupCreatedOn = exports.GroupCreatedOn || (exports.GroupCreatedOn = {}));
|
|
4
10
|
var GroupConfig;
|
|
5
11
|
(function (GroupConfig) {
|
|
6
12
|
GroupConfig["IncludesMembersToEventsWhenJoined"] = "includesMembersToEventsWhenJoined";
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
-
const
|
|
7
|
+
const utils_1 = require("../../../helpers/utils");
|
|
8
8
|
const lang_1 = require("../../../lang");
|
|
9
9
|
const Model_1 = __importDefault(require("../../Model"));
|
|
10
10
|
class Notification extends Model_1.default {
|
|
@@ -14,7 +14,7 @@ class Notification extends Model_1.default {
|
|
|
14
14
|
const translation = (0, lang_1.getTranslation)(`${this.action}.${key}`, this.lang);
|
|
15
15
|
return !translation
|
|
16
16
|
? this.action
|
|
17
|
-
: (0,
|
|
17
|
+
: (0, utils_1.replaceKeysNotification)(translation, this.meta, this.lang);
|
|
18
18
|
};
|
|
19
19
|
this.lang = lang;
|
|
20
20
|
}
|
|
@@ -32,7 +32,7 @@ class Notification extends Model_1.default {
|
|
|
32
32
|
return this.data.action;
|
|
33
33
|
}
|
|
34
34
|
get cleanPhotoURL() {
|
|
35
|
-
return this.isAvatar ? (0,
|
|
35
|
+
return this.isAvatar ? (0, utils_1.replaceVarsBrackets)(this.photoURL, this.meta) : this.photoURL;
|
|
36
36
|
}
|
|
37
37
|
get isAvatar() {
|
|
38
38
|
return this.photoURL.slice(0, 1) === '[' && this.photoURL.slice(-1) === ']';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissandoo/lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"description": "Glissandoo library js",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"date-fns": "^2.20.3",
|
|
29
29
|
"date-fns-tz": "^1.1.3",
|
|
30
|
-
"lodash": "^4.17.21"
|
|
30
|
+
"lodash": "^4.17.21",
|
|
31
|
+
"type-fest": "^3.5.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@localazy/cli": "^1.6.5",
|
|
@@ -40,7 +41,6 @@
|
|
|
40
41
|
"husky": "^8.0.1",
|
|
41
42
|
"lint-staged": "^12.4.1",
|
|
42
43
|
"prettier": "^2.2.1",
|
|
43
|
-
"type-fest": "^3.12.0",
|
|
44
44
|
"typescript": "^4.9.4"
|
|
45
45
|
},
|
|
46
46
|
"lint-staged": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LanguagesTypes } from '../../lang';
|
|
2
|
-
import { MetaNotificationData } from '../../models/User/Notification/types';
|
|
3
|
-
export declare const replaceVarsBrackets: (string: string, values: MetaNotificationData) => string;
|
|
4
|
-
export declare const replaceKeysNotification: (text: string, values: MetaNotificationData, lang: LanguagesTypes) => string;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.replaceKeysNotification = exports.replaceVarsBrackets = void 0;
|
|
7
|
-
const date_fns_1 = require("date-fns");
|
|
8
|
-
const date_fns_tz_1 = require("date-fns-tz");
|
|
9
|
-
const lodash_1 = require("lodash");
|
|
10
|
-
const lang_1 = require("../../lang");
|
|
11
|
-
const Instrument_1 = __importDefault(require("../../models/Instrument"));
|
|
12
|
-
var PlaceholderType;
|
|
13
|
-
(function (PlaceholderType) {
|
|
14
|
-
PlaceholderType["Instrument"] = "instrument";
|
|
15
|
-
PlaceholderType["Date"] = "date";
|
|
16
|
-
PlaceholderType["String"] = "string";
|
|
17
|
-
})(PlaceholderType || (PlaceholderType = {}));
|
|
18
|
-
const replaceVarsBrackets = (string, values) => {
|
|
19
|
-
const matches = string.match(/[^[\]]+(?=])/g);
|
|
20
|
-
let replaceString = string;
|
|
21
|
-
if (matches && matches.length > 0) {
|
|
22
|
-
matches.forEach((match) => {
|
|
23
|
-
replaceString = replaceString.replace(`[${match}]`, (0, lodash_1.get)(values, match));
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return replaceString;
|
|
27
|
-
};
|
|
28
|
-
exports.replaceVarsBrackets = replaceVarsBrackets;
|
|
29
|
-
const getTypeAndPathFromPlaceholder = (placeholder) => {
|
|
30
|
-
const placeholderWithoutBrackets = placeholder.slice(1, -1);
|
|
31
|
-
const [type, key, formatValue] = placeholderWithoutBrackets.split(':');
|
|
32
|
-
const path = key.split('.');
|
|
33
|
-
return {
|
|
34
|
-
type: type,
|
|
35
|
-
path,
|
|
36
|
-
formatValue: (formatValue || 'shortDate'),
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const replaceKeysNotification = (text, values, lang) => {
|
|
40
|
-
const placeholders = text.match(/(\{).+?(\})/g);
|
|
41
|
-
if (!placeholders || placeholders.length === 0) {
|
|
42
|
-
return text;
|
|
43
|
-
}
|
|
44
|
-
const { extra, ...other } = values;
|
|
45
|
-
const m = (0, lodash_1.mapValues)(other, (value) => value ? Object.values(value) : value);
|
|
46
|
-
const newValues = {
|
|
47
|
-
extra,
|
|
48
|
-
...m,
|
|
49
|
-
};
|
|
50
|
-
return placeholders.reduce((text, placeholder) => {
|
|
51
|
-
const { type, path, formatValue } = getTypeAndPathFromPlaceholder(placeholder);
|
|
52
|
-
switch (type) {
|
|
53
|
-
case PlaceholderType.Instrument: {
|
|
54
|
-
const instrumentId = (0, lodash_1.get)(newValues, path);
|
|
55
|
-
const instrument = new Instrument_1.default(instrumentId, lang);
|
|
56
|
-
if (!instrument)
|
|
57
|
-
return text;
|
|
58
|
-
return text.replace(placeholder, instrument.name.toLowerCase());
|
|
59
|
-
}
|
|
60
|
-
case PlaceholderType.Date: {
|
|
61
|
-
const [datetimeProp, timezoneProp] = path.pop()?.slice(1, -1).replace(' ', '').split(',') || [];
|
|
62
|
-
const datetime = (0, lodash_1.get)(newValues, [...path, datetimeProp]);
|
|
63
|
-
if (!datetime)
|
|
64
|
-
return text.replace(placeholder, '');
|
|
65
|
-
const timezone = (0, lodash_1.get)(newValues, [...path, timezoneProp]) || 'Europe/Madrid';
|
|
66
|
-
const zonedDatetime = (0, date_fns_tz_1.utcToZonedTime)(datetime.toDate(), timezone);
|
|
67
|
-
const dateLang = (0, lang_1.getDateLang)(lang);
|
|
68
|
-
const dateFormat = (0, date_fns_1.format)(zonedDatetime, (0, lodash_1.get)(dateLang.format, formatValue), {
|
|
69
|
-
locale: dateLang.locale,
|
|
70
|
-
});
|
|
71
|
-
return text.replace(placeholder, dateFormat);
|
|
72
|
-
}
|
|
73
|
-
case PlaceholderType.String:
|
|
74
|
-
return text.replace(placeholder, (0, lodash_1.get)(newValues, path));
|
|
75
|
-
default:
|
|
76
|
-
return text;
|
|
77
|
-
}
|
|
78
|
-
}, text);
|
|
79
|
-
};
|
|
80
|
-
exports.replaceKeysNotification = replaceKeysNotification;
|