bug fixed
This commit is contained in:
parent
d14fb99d13
commit
cdc14fe7e2
@ -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) => {
|
||||
<img
|
||||
src={pencilActiveSrc}
|
||||
alt="Edit"
|
||||
className="h-[24px] w-[24px]"
|
||||
className="h-[25px] w-[25px]"
|
||||
/>
|
||||
</button>
|
||||
|
||||
@ -1714,14 +1736,14 @@ const displayedRows = sortedProfiles.map((item) => {
|
||||
<img
|
||||
src={viewIconSrc}
|
||||
alt="View"
|
||||
className="h-[24px] w-[24px]"
|
||||
className="h-[25px] w-[25px]"
|
||||
/>
|
||||
</button>
|
||||
|
||||
{/* Toggle Status */}
|
||||
<button
|
||||
type="button"
|
||||
className="h-[20px] w-[40px] grid place-items-center rounded hover:bg-gray-50 cursor-pointer"
|
||||
className="h-[24px] w-[24px] grid place-items-center rounded hover:bg-gray-50 cursor-pointer ml-1"
|
||||
title={item.status === "Active" ? "Deactivate" : "Activate"}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
@ -1738,7 +1760,26 @@ const displayedRows = sortedProfiles.map((item) => {
|
||||
: inactiveToggleSrc
|
||||
}
|
||||
alt={item.status === "Active" ? "Active" : "Inactive"}
|
||||
className="h-[20px] w-[40px] object-contain"
|
||||
className="h-[25px] w-[25px] object-contain"
|
||||
/>
|
||||
</button>
|
||||
|
||||
{/* Mail */}
|
||||
<button
|
||||
type="button"
|
||||
className="h-[24px] w-[24px] grid place-items-center rounded hover:bg-gray-50 cursor-pointer ml-1"
|
||||
title="Resend Email"
|
||||
aria-label="Resend Email"
|
||||
disabled={isSendingEmail}
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
await handleSendWelcomeEmail(item.apiId || item.establishmentId);
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={mailIconSrc}
|
||||
alt="Resend Email"
|
||||
className={`h-[25px] w-[25px] ${isSendingEmail ? 'opacity-50' : ''}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
@ -1746,6 +1787,7 @@ const displayedRows = sortedProfiles.map((item) => {
|
||||
];
|
||||
});
|
||||
|
||||
// ... (rest of the code remains the same)
|
||||
|
||||
React.useEffect(() => {
|
||||
const handle = setTimeout(() => {
|
||||
|
||||
@ -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,
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user