Projekt

Obecné

Profil

Stáhnout (1.11 KB) Statistiky
| Větev: | Tag: | Revize:
1
import Swal, { SweetAlertIcon, SweetAlertPosition } from 'sweetalert2';
2
import withReactContent from 'sweetalert2-react-content';
3
import { AxiosResponse } from 'axios';
4

    
5
const MySwal = withReactContent(Swal);
6

    
7
export function ShowToast(
8
    text: string,
9
    icon: SweetAlertIcon = 'success',
10
    timer = 3000,
11
    position: SweetAlertPosition = 'top-right'
12
) {
13
    const Toast = Swal.mixin({
14
        toast: true,
15
        position: position,
16
        showConfirmButton: false,
17
        timer: timer,
18
        timerProgressBar: true,
19
        didOpen: (toast) => {
20
            toast.addEventListener('mouseenter', Swal.stopTimer);
21
            toast.addEventListener('mouseleave', Swal.resumeTimer);
22
        },
23
    });
24

    
25
    Toast.fire({
26
        icon: icon,
27
        title: text,
28
    });
29
}
30

    
31
export function ShowConfirmDelete(deleteAction: () => void, deleteSubjectLabel: string) {
32
    Swal.fire({
33
        title: 'Opravdu si přejete smazat ' + deleteSubjectLabel + '?',
34
        showCancelButton: true,
35
        confirmButtonText: 'Smazat',
36
    }).then((result) => {
37
        if (result.isConfirmed) {
38
            deleteAction();
39
        }
40
    });
41
}
(1-1/4)