-
Notifications
You must be signed in to change notification settings - Fork 3
/
user-got-fined.ts
87 lines (76 loc) · 3.82 KB
/
user-got-fined.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* SudoSOS back-end API service.
* Copyright (C) 2024 Study association GEWIS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license
*/
/**
* This is the module page of the user-got-fined.
*
* @module internal/mailer
*/
import { Dinero } from 'dinero.js';
import MailContentBuilder from './mail-content-builder';
import MailMessage, { Language, MailLanguageMap } from '../mail-message';
interface UserGotFinedOptions {
referenceDate: Date;
fine: Dinero;
totalFine: Dinero;
balance: Dinero;
}
const userGotFinedDutch = new MailContentBuilder<UserGotFinedOptions>({
getHTML: (context) => `
<p>Op ${context.referenceDate.toLocaleString('nl-NL')} had je een saldo van <span style="color: red; font-weight: bold;">${context.balance.toFormat()}</span>.<br>
Hiervoor heb je zojuist een boete gekregen van ${context.fine.toFormat()}.<br>
Dit brengt je totale boete op:<br>
<span style="color: red; font-weight: bold; font-size: 20px;">${context.totalFine.toFormat()}</span>.</p>
<p>Ga snel naar de SudoSOS website om je saldo op te hogen en je boete te betalen. Zo voorkom je dat de boete meer wordt of je account geblokkeerd wordt.</p>`,
getSubject: (context) => `Je hebt ${context.fine.toFormat()} SudoSOS boete gekregen!`,
getTitle: 'Schuldnotificatie',
getText: (context) => `
Op ${context.referenceDate.toLocaleString('nl-NL')} had je een saldo van ${context.balance.toFormat()}.
Hiervoor heb je zojuist een boete gekregen van ${context.fine.toFormat()}.
Dit brengt je totale boete op:
${context.totalFine.toFormat()}.
Ga snel naar de SudoSOS website om je saldo op te hogen en je boete te betalen.
Zo voorkom je dat de boete meer wordt of je account geblokkeerd wordt.`,
});
const userGotFinedEnglish = new MailContentBuilder<UserGotFinedOptions>({
getHTML: (context) => `
<p>On ${context.referenceDate.toLocaleString('en-US')} you had a balance of <span style="color: red; font-weight: bold;">${context.balance.toFormat()}</span>.<br>
For your debt, you have been fined for an amount of ${context.fine.toFormat()}.<br>
This brings your total fine to:<br>
<span style="color: red; font-weight: bold; font-size: 20px;">${context.totalFine.toFormat()}</span>.</p>
<p>Go to the SudoSOS website to deposit money into your account and pay your fines. With this you prevent getting more fines and getting your account blocked.</p>`,
getSubject: (context) => `You have been fined ${context.fine.toFormat()} for your negative SudoSOS balance!`,
getTitle: 'Debt notification',
getText: (context) => `
On ${context.referenceDate.toLocaleString('nl-NL')} you had a balance of ${context.balance.toFormat()}.
For your debt, you have been fined for an amount of ${context.fine.toFormat()}.
This brings your total fine to:
${context.totalFine.toFormat()}.
Go to the SudoSOS website to deposit money into your account and pay your fines.
With this you prevent getting more fines and getting your account blocked.`,
});
const mailContents: MailLanguageMap<UserGotFinedOptions> = {
[Language.DUTCH]: userGotFinedDutch,
[Language.ENGLISH]: userGotFinedEnglish,
};
export default class UserGotFined extends MailMessage<UserGotFinedOptions> {
public constructor(options: UserGotFinedOptions) {
super(options, mailContents);
}
}