-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathalerts.js
More file actions
45 lines (39 loc) · 1.35 KB
/
alerts.js
File metadata and controls
45 lines (39 loc) · 1.35 KB
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
import Swal from "sweetalert2";
import { doLogin } from 'openstack-uicore-foundation/lib/methods'
import URI from "urijs"
import { savePendingAction } from "./schedule";
export const alertPopup = (title, html, confirmLabel, confirmAction, cancelLabel = 'Dismiss') => {
Swal.fire({
title,
html,
icon: 'question',
iconHtml: '!',
showCancelButton: true,
cancelButtonText: cancelLabel,
width: '400px',
reverseButtons: true,
customClass: {
container: 'swal-wrapper',
title: 'swal-title',
icon: 'swal-icon',
content: 'swal-body',
confirmButton: 'swal-confirm',
cancelButton: 'swal-cancel',
}
}
).then((result) => {
if (result.value) {
confirmAction();
}
})
};
export const needsLogin = (action, msg = null) => {
const defaultMessage = "Please login in order to build your schedule and add activities during the event";
const login = () => {
let backUrl = window?.location?.href ?? '/a/profile';
let encodedBackUrl = URI.encode(backUrl);
if (action) savePendingAction(action);
return doLogin(encodedBackUrl);
}
alertPopup('Login', msg || defaultMessage, 'Login', login);
};