Merge pull request #2295 from bluewave-labs/test-email-implementation-in-details-page

Email test button added in details page.
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-05-19 10:57:40 -07:00
commit 27e02c53b8
3 files changed
+26 -3

No files matched your search

@@ -5,12 +5,15 @@ import Button from "@mui/material/Button";
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined"; import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
import PauseOutlinedIcon from "@mui/icons-material/PauseOutlined"; import PauseOutlinedIcon from "@mui/icons-material/PauseOutlined";
import PlayArrowOutlinedIcon from "@mui/icons-material/PlayArrowOutlined"; import PlayArrowOutlinedIcon from "@mui/icons-material/PlayArrowOutlined";
import EmailIcon from '@mui/icons-material/Email';
// Utils // Utils
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import { usePauseMonitor } from "../../Hooks/useMonitorControls"; import { usePauseMonitor } from "../../Hooks/useMonitorControls";
import { useSendTestEmail } from "../../Hooks/useSendTestEmail";
import { useTranslation } from "react-i18next";
/** /**
* MonitorDetailsControlHeader component displays the control header for monitor details. * MonitorDetailsControlHeader component displays the control header for monitor details.
@@ -34,11 +37,14 @@ const MonitorDetailsControlHeader = ({
}) => { }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation();
const [pauseMonitor, isPausing, error] = usePauseMonitor({ const [pauseMonitor, isPausing, error] = usePauseMonitor({
monitorId: monitor?._id, monitorId: monitor?._id,
triggerUpdate, triggerUpdate,
}); });
const [isSending, emailError, sendTestEmail] = useSendTestEmail();
if (isLoading) { if (isLoading) {
return <Skeleton />; return <Skeleton />;
} }
@@ -54,6 +60,15 @@ const MonitorDetailsControlHeader = ({
direction="row" direction="row"
gap={theme.spacing(2)} gap={theme.spacing(2)}
> >
<Button
variant="contained"
color="secondary"
loading={isSending}
startIcon={<EmailIcon />}
onClick={sendTestEmail}
>
{t("sendTestEmail")}
</Button>
<Button <Button
variant="contained" variant="contained"
color="secondary" color="secondary"
+7 -2
View File
@@ -2,11 +2,13 @@ import { useState } from "react";
import { networkService } from "../main"; import { networkService } from "../main";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { createToast } from "../Utils/toastUtils"; import { createToast } from "../Utils/toastUtils";
import { useTranslation } from "react-i18next";
const useSendTestEmail = () => { const useSendTestEmail = () => {
const [isSending, setIsSending] = useState(false); const [isSending, setIsSending] = useState(false);
const [error, setError] = useState(null); const [error, setError] = useState(null);
const user = useSelector((state) => state.auth.user); const user = useSelector((state) => state.auth.user);
const { t } = useTranslation();
const sendTestEmail = async () => { const sendTestEmail = async () => {
try { try {
@@ -16,12 +18,15 @@ const useSendTestEmail = () => {
const response = await networkService.sendTestEmail({ to: user.email }); const response = await networkService.sendTestEmail({ to: user.email });
if (typeof response?.data?.data?.messageId !== "undefined") { if (typeof response?.data?.data?.messageId !== "undefined") {
createToast({ createToast({
body: "Test email sent successfully", body: t("emailSent"),
}); });
} else { } else {
throw new Error("Failed to send test email"); throw new Error(t("failedToSendEmail"));
} }
} catch (error) { } catch (error) {
createToast({
body: t("failedToSendEmail"),
});
setError(error); setError(error);
} finally { } finally {
setIsSending(false); setIsSending(false);
+4 -1
View File
@@ -536,5 +536,8 @@
"passwordRequirements": "New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character.", "passwordRequirements": "New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character.",
"saving": "Saving..." "saving": "Saving..."
}, },
"uptimeCreateSelectURL": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard." "uptimeCreateSelectURL": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard.",
"sendTestEmail": "Send test email",
"emailSent": "Email sent successfully",
"failedToSendEmail": "Failed to send email"
} }