diff --git a/sge-frontend/src/views/Communication.js b/sge-frontend/src/views/Communication.js index 1536861..fa8c9e2 100644 --- a/sge-frontend/src/views/Communication.js +++ b/sge-frontend/src/views/Communication.js @@ -1,218 +1,218 @@ -import React, { useEffect, useState } from "react"; -import { - Button, - Card, - CardHeader, - CardTitle, - Col, - Modal, - ModalBody, - ModalHeader, - Row, - UncontrolledTooltip, // Add UncontrolledTooltip import -} from "reactstrap"; -import { Edit, Mail, Phone, MapPin } from "react-feather"; // Import Mail, Phone, MapPin - -import { useSnackbar } from "notistack"; -import { useTranslation } from "react-i18next"; -import { useDispatch, useSelector } from "react-redux"; -import { permissionCheck } from "../components/permission-check"; -import { - getMailSettings, - clearMailSuccess, - clearMailError, -} from "../redux/actions/mailSettings"; -import MailSettings from "./MailSettings"; -import SpinnerComponent from "../@core/components/spinner/Fallback-spinner"; - -// Import custom styles for the communication page -import "../assets/scss/pages/communication.scss"; - -function Communication() { - const { t } = useTranslation(); - const dispatch = useDispatch(); - const { enqueueSnackbar } = useSnackbar(); - const { currentSettings, loading, success, error } = useSelector( - // Add loading to useSelector - (state) => state.mailSettings - ); - const [showMailModal, setShowMailModal] = useState(false); - - useEffect(() => { - // Load mail settings once when component mounts - dispatch(getMailSettings()); - }, [dispatch]); - - useEffect(() => { - if (success) { - enqueueSnackbar(t("Warnings.updatedSuccessfully"), { - variant: "success", - }); - dispatch(clearMailSuccess()); - } - }, [success, enqueueSnackbar, t, dispatch]); - - useEffect(() => { - if (error) { - const errorMessage = - error?.graphQLErrors?.[0]?.message || - error?.message || - t("Warnings.genericUpdateFailed"); - - enqueueSnackbar(errorMessage, { - variant: "error", - }); - dispatch(clearMailError()); - } - }, [error, enqueueSnackbar, t, dispatch]); - - // Get email address from settings or use default from environment variable - const defaultEmail = process.env.REACT_APP_DEFAULT_EMAIL || ""; - // Use default email if currentSettings is null or emailAddress is null - const emailAddress = currentSettings?.emailAddress || defaultEmail; - const handleEmailClick = () => { - if (emailAddress) { - window.location.href = `mailto:${emailAddress}`; - } - }; - - const handleCloseModal = () => { - setShowMailModal(false); - }; - - return ( -
- {loading && !currentSettings ? ( -
- -
- ) : ( - <> - {permissionCheck("settings_access") && ( - <> - - - {t("MailSettings.editMailInfo")} - - - - - - - )} - - - - {t("Contact.contactInfo")} - - - - - - -
-
-

- {" "} - {t("Contact.contactEmail")} -

{" "} - {/* Add Mail icon */} -

- {emailAddress || - defaultEmail || - t("MailSettings.notConfigured")} -

-
- {permissionCheck("settings_access") && ( - <> - {" "} - {/* Wrap button and tooltip in fragment */} - - - {t("MailSettings.editMailInfo")}{" "} - {/* Tooltip text */} - - - )} -
- - -
-

- {" "} - {t("Contact.contactPhoneNumber")} -

{" "} - {/* Add Phone icon */} -

+90 507 750 00 41

-
- -
- - -
-

- {" "} - {t("Contact.contactAddress")} -

{" "} - {/* Add MapPin icon */} -
- Central Office: 4995 sokak no:3, Alacaatlı Mahallesi, - Daire No: A2 06810 Çankaya/Ankara -
-
- -
- - - -
-
- -
-
-
- -
-
- - )} -
- ); -} - -export default Communication; +import React, { useEffect, useState } from "react"; +import { + Button, + Card, + CardHeader, + CardTitle, + Col, + Modal, + ModalBody, + ModalHeader, + Row, + UncontrolledTooltip, // Add UncontrolledTooltip import +} from "reactstrap"; +import { Edit, Mail, Phone, MapPin } from "react-feather"; // Import Mail, Phone, MapPin + +import { useSnackbar } from "notistack"; +import { useTranslation } from "react-i18next"; +import { useDispatch, useSelector } from "react-redux"; +import { permissionCheck } from "../components/permission-check"; +import { + getMailSettings, + clearMailSuccess, + clearMailError, +} from "../redux/actions/mailSettings"; +import MailSettings from "./MailSettings"; +import SpinnerComponent from "../@core/components/spinner/Fallback-spinner"; + +// Import custom styles for the communication page +import "../assets/scss/pages/communication.scss"; + +function Communication() { + const { t } = useTranslation(); + const dispatch = useDispatch(); + const { enqueueSnackbar } = useSnackbar(); + const { currentSettings, loading, success, error } = useSelector( + // Add loading to useSelector + (state) => state.mailSettings + ); + const [showMailModal, setShowMailModal] = useState(false); + + useEffect(() => { + // Load mail settings once when component mounts + dispatch(getMailSettings()); + }, [dispatch]); + + useEffect(() => { + if (success) { + enqueueSnackbar(t("Warnings.updatedSuccessfully"), { + variant: "success", + }); + dispatch(clearMailSuccess()); + } + }, [success, enqueueSnackbar, t, dispatch]); + + useEffect(() => { + if (error) { + const errorMessage = + error?.graphQLErrors?.[0]?.message || + error?.message || + t("Warnings.genericUpdateFailed"); + + enqueueSnackbar(errorMessage, { + variant: "error", + }); + dispatch(clearMailError()); + } + }, [error, enqueueSnackbar, t, dispatch]); + + // Get email address from settings or use default from environment variable + const defaultEmail = process.env.REACT_APP_DEFAULT_EMAIL || ""; + // Use default email if currentSettings is null or emailAddress is null + const emailAddress = currentSettings?.emailAddress || defaultEmail; + const handleEmailClick = () => { + if (emailAddress) { + window.location.href = `mailto:${emailAddress}`; + } + }; + + const handleCloseModal = () => { + setShowMailModal(false); + }; + + return ( +
+ {loading && !currentSettings ? ( +
+ +
+ ) : ( + <> + {permissionCheck("settings_access") && ( + <> + + + {t("MailSettings.editMailInfo")} + + + + + + + )} + + + + {t("Contact.contactInfo")} + + + + + + +
+
+

+ {" "} + {t("Contact.contactEmail")} +

{" "} + {/* Add Mail icon */} +

+ {emailAddress || + defaultEmail || + t("MailSettings.notConfigured")} +

+
+ {permissionCheck("settings_access") && ( + <> + {" "} + {/* Wrap button and tooltip in fragment */} + + + {t("MailSettings.editMailInfo")}{" "} + {/* Tooltip text */} + + + )} +
+ + +
+

+ {" "} + {t("Contact.contactPhoneNumber")} +

{" "} + {/* Add Phone icon */} +

+90 507 750 00 41

+
+ +
+ + +
+

+ {" "} + {t("Contact.contactAddress")} +

{" "} + {/* Add MapPin icon */} +
+ Central Office: 4995 sokak no:3, Alacaatlı Mahallesi, + Daire No: A2 06820 Çankaya/Ankara +
+
+ +
+ + + +
+
+ +
+
+
+ +
+
+ + )} +
+ ); +} + +export default Communication;