Explorar el Código

customAlerts formatter

feature/axios_provider
cyril.tsui hace 5 meses
padre
commit
2c164b9a75
Se han modificado 2 ficheros con 37 adiciones y 29 borrados
  1. +32
    -24
      src/components/Swal/CustomAlerts.js
  2. +5
    -5
      src/components/Swal/sweetalert2.css

+ 32
- 24
src/components/Swal/CustomAlerts.js Ver fichero

@@ -1,5 +1,5 @@
import Swal from "sweetalert2";
import "./sweetalert2.css"
import "./sweetalert2.css";

export const msg = (text) => {
Swal.mixin({
@@ -28,8 +28,8 @@ export const successDialog = (text, t) => {
title: text,
confirmButtonText: t("Confirm"),
showConfirmButton: true,
})
}
});
};

export const successDialogWithContent = (title, text, t) => {
return Swal.fire({
@@ -38,8 +38,8 @@ export const successDialogWithContent = (title, text, t) => {
html: text,
confirmButtonText: t("Confirm"),
showConfirmButton: true,
})
}
});
};

export const errorDialog = (text, t) => {
return Swal.fire({
@@ -47,18 +47,18 @@ export const errorDialog = (text, t) => {
title: text,
confirmButtonText: t("Confirm"),
showConfirmButton: true,
})
}
});
};

export const errorDialogWithContent = (title, text, t) => {
export const errorDialogWithContent = (title, text, t) => {
return Swal.fire({
icon: "error",
title: title,
html: text,
confirmButtonText: t("Confirm"),
showConfirmButton: true,
})
}
});
};

export const warningDialog = (text, t) => {
return Swal.fire({
@@ -66,13 +66,17 @@ export const warningDialog = (text, t) => {
title: text,
confirmButtonText: t("Confirm"),
showConfirmButton: true,
})
}
});
};

export const submitDialog = async (confirmAction, t, {...props} = {
title: t("Do you want to submit?"),
confirmButtonText: t("Submit"),
}) => {
export const submitDialog = async (
confirmAction,
t,
{ ...props } = {
title: t("Do you want to submit?"),
confirmButtonText: t("Submit"),
}
) => {
// console.log(props)
// const { t } = useTranslation("common")
const result = await Swal.fire({
@@ -90,13 +94,17 @@ export const submitDialog = async (confirmAction, t, {...props} = {
if (result.isConfirmed) {
confirmAction();
}
}
};

export const submitDialogWithWarning = async (confirmAction, t, {...props} = {
title: t("Do you want to submit?"),
text: t("Warning!"),
confirmButtonText: t("Submit"),
}) => {
export const submitDialogWithWarning = async (
confirmAction,
t,
{ ...props } = {
title: t("Do you want to submit?"),
text: t("Warning!"),
confirmButtonText: t("Submit"),
}
) => {
// console.log(props)
// const { t } = useTranslation("common")
const result = await Swal.fire({
@@ -115,7 +123,7 @@ export const submitDialogWithWarning = async (confirmAction, t, {...props} = {
if (result.isConfirmed) {
confirmAction();
}
}
};

export const deleteDialog = async (confirmAction, t) => {
// const { t } = useTranslation("common")
@@ -134,4 +142,4 @@ export const deleteDialog = async (confirmAction, t) => {
if (result.isConfirmed) {
confirmAction();
}
}
};

+ 5
- 5
src/components/Swal/sweetalert2.css Ver fichero

@@ -1,7 +1,7 @@
.swal-container-class {
z-index: 9999; /* Adjust the z-index value as needed */
}
z-index: 9999; /* Adjust the z-index value as needed */
}
.swal-popup-class {
z-index: 10000; /* Adjust the z-index value as needed */
}
z-index: 10000; /* Adjust the z-index value as needed */
}

Cargando…
Cancelar
Guardar