Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit cd5cbfb

Browse files
committed
fix for plural notification text
1 parent 5ad49e9 commit cd5cbfb

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/constants/notifications.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,14 @@ export const NOTIFICATIONS = [
12911291
type: NOTIFICATION_TYPE.TAAS,
12921292
rules: [
12931293
{
1294-
text: "{{numOfExpiringResourceBookings}} resource booking{{s}} {{be}} expiring in the team <strong>{{teamName}}</strong>",
1294+
textIsPlural: true,
1295+
text: "{{numOfExpiringResourceBookings}} resource bookings are expiring in the team <strong>{{teamName}}</strong>",
1296+
shouldBundle: false,
1297+
goTo: GOTO.TAAS_PROJECT,
1298+
},
1299+
{
1300+
textIsPlural: false,
1301+
text: "{{numOfExpiringResourceBookings}} resource booking is expiring in the team <strong>{{teamName}}</strong>",
12951302
shouldBundle: false,
12961303
goTo: GOTO.TAAS_PROJECT,
12971304
},

src/utils/notifications.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ const getNotificationRule = (notification) => {
319319
);
320320
}
321321

322+
if (notification.contents.textIsPlural != null) {
323+
match =
324+
match &&
325+
notification.contents.textIsPlural === _notificationRule.textIsPlural;
326+
}
327+
322328
return match;
323329
});
324330

@@ -572,6 +578,17 @@ export const preRenderNotifications = (notifications) => {
572578

573579
// --- TaaS --- //
574580

581+
const prepareTaaSNotificationContents = (eventType, contents) => {
582+
if (eventType === EVENT_TYPE.TAAS.RESOURCE_BOOKING_EXPIRATION) {
583+
return {
584+
...contents,
585+
textIsPlural: contents.numOfExpiringResourceBookings > 1,
586+
};
587+
}
588+
589+
return contents;
590+
};
591+
575592
export const prepareTaaSNotifications = (rawNotifications) => {
576593
const notifications = rawNotifications.map((rawNotification) => ({
577594
id: `${rawNotification.id}`,
@@ -585,7 +602,10 @@ export const prepareTaaSNotifications = (rawNotifications) => {
585602
date: rawNotification.createdAt,
586603
isRead: rawNotification.read,
587604
seen: rawNotification.seen,
588-
contents: rawNotification.contents,
605+
contents: prepareTaaSNotificationContents(
606+
rawNotification.type,
607+
rawNotification.contents
608+
),
589609
version: rawNotification.version,
590610
}));
591611

0 commit comments

Comments
 (0)