modify notification email subject
This commit is contained in:
@@ -7,7 +7,7 @@ const generateEmailFooter = searchRequestId => {
|
||||
return `<div>Ako želite prestati dobijati obavještenja za ovu pretragu, <a href="${APP_URL}/odjava/${searchRequestId}">odjavite ovdje</a></div>
|
||||
<div>Ako želite pogledati ili promijeniti uslove za ovu pretragu, <a href="${APP_URL}/pregled/${searchRequestId}">pogledajte ovdje</a></div>
|
||||
<br/>
|
||||
<strong>Vaš,<br/>Javimi tim</strong>`;
|
||||
<strong>Vaš,<br/>Kivi tim</strong>`;
|
||||
};
|
||||
|
||||
const generateRealEstateLinks = realEstates => {
|
||||
@@ -82,7 +82,32 @@ const generateNewSearchRequestEmail = (searchRequest, matchingRealEstates) => {
|
||||
${emailFooter}`;
|
||||
};
|
||||
|
||||
const generateEmailSubject = (numberOfRealEstates, singleRealEstateTitle) => {
|
||||
if (numberOfRealEstates === 1) {
|
||||
return `Kivi: ${singleRealEstateTitle}`;
|
||||
}
|
||||
|
||||
const leastSignificantDigit = numberOfRealEstates % 10;
|
||||
const numberWithoutLastDigit = Math.floor(numberOfRealEstates / 10);
|
||||
const secondLeastSignificantDigit = numberWithoutLastDigit % 10;
|
||||
|
||||
if (leastSignificantDigit === 1 && secondLeastSignificantDigit !== 1) {
|
||||
return `Kivi : ${numberOfRealEstates} nova nekretnina`;
|
||||
}
|
||||
|
||||
if (
|
||||
leastSignificantDigit >= 2 &&
|
||||
leastSignificantDigit <= 4 &&
|
||||
secondLeastSignificantDigit !== 1
|
||||
) {
|
||||
return `Kivi: ${numberOfRealEstates} nove nekretnine`;
|
||||
}
|
||||
|
||||
return `Kivi: ${numberOfRealEstates} novih nekretnina`;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
generateNotificationEmail,
|
||||
generateNewSearchRequestEmail
|
||||
generateNewSearchRequestEmail,
|
||||
generateEmailSubject
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user