diff --git a/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx b/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx
index 126e5df..7df4ac9 100644
--- a/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx
+++ b/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx
@@ -12,7 +12,8 @@ import {
deleteEstablishment,
uploadCompanyProfileCSV,
uploadCompanyProfileCSVAlternative,
- downloadSampleFile
+ downloadSampleFile,
+ sendWelcomeEmail
} from '@/services/establishments/establishmentService';
import { fetchProducts } from '@/services/masters/masterService';
@@ -30,6 +31,7 @@ const deleteIconSrc = '/assets/images/delete.svg';
const activeToggleSrc = '/assets/images/Toggle.svg';
const inactiveToggleSrc = '/assets/images/Toggle-inactive.svg';
const uploadImportIconSrc = '/assets/images/UploadSimple.svg';
+const mailIconSrc = '/assets/images/material-symbols_mail-outline.svg';
// Custom Toast Component
const CustomToast = ({ message, type, onClose }) => {
@@ -463,6 +465,7 @@ const validateCSVFile = (file, existingEstablishments = []) => {
};
const CompanyProfile = () => {
+ const [isSendingEmail, setIsSendingEmail] = React.useState(false);
const navigate = useNavigate();
const [profiles, setProfiles] = React.useState([]);
const [isLoading, setIsLoading] = React.useState(false);
@@ -1581,6 +1584,25 @@ const CompanyProfile = () => {
setActiveStep((prev) => Math.min(prev + 1, formSteps.length - 1));
}, [activeStep, form.userProfilePassword, form.userProfileConfirmPassword, formSteps.length, validateStepFields, selectedProducts, showToast]);
+ const handleSendWelcomeEmail = async (establishmentId) => {
+ if (!establishmentId) {
+ showToast('error', 'Invalid establishment ID');
+ return;
+ }
+
+ try {
+ setIsSendingEmail(true);
+ const response = await sendWelcomeEmail(establishmentId);
+ showToast('success', response.message || 'Welcome email sent successfully');
+ } catch (error) {
+ console.error('Error sending welcome email:', error);
+ const errorMessage = error.response?.data?.message || 'Failed to send welcome email';
+ showToast('error', errorMessage);
+ } finally {
+ setIsSendingEmail(false);
+ }
+ };
+
const handleToggleStatus = async (establishmentId, currentStatus) => {
try {
const newStatus = !currentStatus;
@@ -1696,7 +1718,7 @@ const displayedRows = sortedProfiles.map((item) => {
@@ -1714,14 +1736,14 @@ const displayedRows = sortedProfiles.map((item) => {
{/* Toggle Status */}
+
+ {/* Mail */}
+
@@ -1746,6 +1787,7 @@ const displayedRows = sortedProfiles.map((item) => {
];
});
+// ... (rest of the code remains the same)
React.useEffect(() => {
const handle = setTimeout(() => {
diff --git a/ipi-survey-platform/src/services/establishments/establishmentService.js b/ipi-survey-platform/src/services/establishments/establishmentService.js
index efc0669..16259b7 100644
--- a/ipi-survey-platform/src/services/establishments/establishmentService.js
+++ b/ipi-survey-platform/src/services/establishments/establishmentService.js
@@ -164,6 +164,13 @@ export const downloadSampleFile = async (config = {}) => {
return response.data;
};
+export const sendWelcomeEmail = async (establishmentId, config = {}) => {
+ const response = await postRequest('/trigger-establishment-users-welcome-email', {
+ establishment_id: establishmentId
+ }, config);
+ return response.data;
+};
+
export default {
fetchEstablishments,
fetchEstablishmentDashboard,
@@ -176,4 +183,5 @@ export default {
bulkUpdateEstablishments,
bulkDeleteEstablishments,
downloadSampleFile,
+ sendWelcomeEmail,
};
\ No newline at end of file