Add component
This commit is contained in:
69
src/components/Global/ToastNotif.jsx
Normal file
69
src/components/Global/ToastNotif.jsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
const NotifAlert = ({ icon, title, message }) => {
|
||||
Swal.fire({
|
||||
icon: icon,
|
||||
title: title,
|
||||
text: message,
|
||||
showConfirmButton: false,
|
||||
position: 'center',
|
||||
timer: 2000,
|
||||
});
|
||||
};
|
||||
|
||||
const NotifOk = ({ icon, title, message }) => {
|
||||
Swal.fire({
|
||||
icon: icon,
|
||||
title: title,
|
||||
text: message,
|
||||
});
|
||||
};
|
||||
|
||||
const NotifConfirmDialog = ({
|
||||
icon,
|
||||
title,
|
||||
message,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
confirmButtonText = 'Hapus',
|
||||
}) => {
|
||||
Swal.fire({
|
||||
icon: icon,
|
||||
title: title,
|
||||
text: message,
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: '#23A55A',
|
||||
cancelButtonText: 'Batal',
|
||||
confirmButtonColor: '#d33000',
|
||||
confirmButtonText: confirmButtonText,
|
||||
reverseButtons: true,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
onConfirm();
|
||||
} else if (result.dismiss) {
|
||||
onCancel();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const QuestionConfirmSubmit = ({ icon, title, message, onConfirm, onCancel }) => {
|
||||
Swal.fire({
|
||||
icon: icon,
|
||||
title: title,
|
||||
text: message,
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: '#23A55A',
|
||||
cancelButtonText: 'Batal',
|
||||
confirmButtonColor: '#d33000',
|
||||
confirmButtonText: 'Proses',
|
||||
reverseButtons: true,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
onConfirm();
|
||||
} else if (result.dismiss) {
|
||||
onCancel();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export { NotifAlert, NotifOk, NotifConfirmDialog, QuestionConfirmSubmit };
|
||||
Reference in New Issue
Block a user