-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.ts
139 lines (132 loc) · 4 KB
/
message.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
export enum Color {
success = "#7dd296",
warning = "#e6db64",
danger = "#F35A00",
}
const respondingActions = {
"type": "actions",
"elements": [
{
"type": "button",
"style": "primary",
"text": {
"type": "plain_text",
"text": "YES",
"emoji": true
},
"value": "YES",
"action_id": "responding"
},
{
"type": "button",
"style": "danger",
"text": {
"type": "plain_text",
"text": "NO",
"emoji": true
},
"value": "NO",
"action_id": "not_responding"
}
]
};
export const dutyCrewAttachment = [
{
"color": Color.success,
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Scheduled duty crew\n *No response is needed*"
}
}
]
}
]
export function generateDispatchMessage(formattedDateTime: string) {
return [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "RPI Ambulance dispatched on " + formattedDateTime + " \n\n *TONES RECIEVED*\n_Stand by for further information_"
}
},
{
"type": "divider"
}
]
}
export function generateLongtoneMessage(formattedDateTime: string) {
return [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Rensslaer County longtone on " + formattedDateTime + " \n\n *LONGTONE (GROUP ALERT) RECIEVED*\n_Stand by for further information_"
}
},
{
"type": "divider"
}
]
}
export function generateRespondingAttachment(message: string, color: Color, toneTest: boolean, responding: boolean) {
let textField = message;
if (toneTest) textField += "\nConfirm a possible call using other means.";
if (responding) textField += "\n*Are you responding?*"
let attachment = [
{
"color": color,
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": textField
}
}
]
}
];
if (responding) attachment[0].blocks.push(respondingActions);
return attachment;
}
export function generateLongtoneTestAttachment(message: string) {
return [
{
"color": "#e6db64",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": message + "\n*Confirm a possible message using other means.*"
}
}
]
}
]
}
export function generateResponderStatus(firstName: string, lastName: string, status: boolean) {
let attachment = [
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
}
}
]
}
]
if(status){
attachment[0].color = Color.success;
attachment[0].blocks[0].text.text = "*" + firstName.charAt(0) + ". " + lastName + "* is *RESPONDING*"
}
else
attachment[0].blocks[0].text.text = firstName.charAt(0) + ". " + lastName + " is NOT RESPONDING"
return attachment;
}