Remove individual toast notifications
- During SSL certificate refresh and display a single summary notification after the "Refresh All" action.
This commit is contained in:
@@ -30,12 +30,12 @@ export const SSLDomainContent = () => {
|
|||||||
queryKey: ['ssl-certificates'],
|
queryKey: ['ssl-certificates'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
try {
|
try {
|
||||||
// console.log("Fetching SSL certificates from SSLDomainContent...");
|
console.log("Fetching SSL certificates from SSLDomainContent...");
|
||||||
const result = await fetchSSLCertificates();
|
const result = await fetchSSLCertificates();
|
||||||
// console.log("Received SSL certificates:", result);
|
console.log("Received SSL certificates:", result);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.error("Error fetching certificates:", error);
|
console.error("Error fetching certificates:", error);
|
||||||
toast.error(t('failedToLoadCertificates'));
|
toast.error(t('failedToLoadCertificates'));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ export const SSLDomainContent = () => {
|
|||||||
toast.success(t('sslCertificateAdded'));
|
toast.success(t('sslCertificateAdded'));
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
// console.error("Error adding SSL certificate:", error);
|
console.error("Error adding SSL certificate:", error);
|
||||||
toast.error(error instanceof Error ? error.message : t('failedToAddCertificate'));
|
toast.error(error instanceof Error ? error.message : t('failedToAddCertificate'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -61,7 +61,7 @@ export const SSLDomainContent = () => {
|
|||||||
// Edit certificate mutation - Updated to ensure thresholds are properly updated
|
// Edit certificate mutation - Updated to ensure thresholds are properly updated
|
||||||
const editMutation = useMutation({
|
const editMutation = useMutation({
|
||||||
mutationFn: async (certificate: SSLCertificate) => {
|
mutationFn: async (certificate: SSLCertificate) => {
|
||||||
// console.log("Updating certificate with data:", certificate);
|
console.log("Updating certificate with data:", certificate);
|
||||||
|
|
||||||
// Create the update data object
|
// Create the update data object
|
||||||
const updateData = {
|
const updateData = {
|
||||||
@@ -70,12 +70,12 @@ export const SSLDomainContent = () => {
|
|||||||
notification_channel: certificate.notification_channel,
|
notification_channel: certificate.notification_channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log("Update data to be sent:", updateData);
|
console.log("Update data to be sent:", updateData);
|
||||||
|
|
||||||
// Update certificate in the database using PocketBase directly
|
// Update certificate in the database using PocketBase directly
|
||||||
const updated = await pb.collection('ssl_certificates').update(certificate.id, updateData);
|
const updated = await pb.collection('ssl_certificates').update(certificate.id, updateData);
|
||||||
|
|
||||||
// console.log("PocketBase update response:", updated);
|
console.log("PocketBase update response:", updated);
|
||||||
|
|
||||||
// After updating the settings, refresh the certificate to ensure it's up to date
|
// After updating the settings, refresh the certificate to ensure it's up to date
|
||||||
// This will also check if notification needs to be sent based on updated thresholds
|
// This will also check if notification needs to be sent based on updated thresholds
|
||||||
@@ -90,7 +90,7 @@ export const SSLDomainContent = () => {
|
|||||||
toast.success(t('sslCertificateUpdated'));
|
toast.success(t('sslCertificateUpdated'));
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
// console.error("Error updating SSL certificate:", error);
|
console.error("Error updating SSL certificate:", error);
|
||||||
toast.error(error instanceof Error ? error.message : t('failedToUpdateCertificate'));
|
toast.error(error instanceof Error ? error.message : t('failedToUpdateCertificate'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,33 +103,26 @@ export const SSLDomainContent = () => {
|
|||||||
toast.success(t('sslCertificateDeleted'));
|
toast.success(t('sslCertificateDeleted'));
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
// console.error("Error deleting SSL certificate:", error);
|
console.error("Error deleting SSL certificate:", error);
|
||||||
toast.error(error instanceof Error ? error.message : t('failedToDeleteCertificate'));
|
toast.error(error instanceof Error ? error.message : t('failedToDeleteCertificate'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh certificate mutation - Updated to ensure notifications are sent
|
// Refresh certificate mutation - Updated to remove individual toast notifications
|
||||||
const refreshMutation = useMutation({
|
const refreshMutation = useMutation({
|
||||||
mutationFn: checkAndUpdateCertificate,
|
mutationFn: checkAndUpdateCertificate,
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['ssl-certificates'] });
|
queryClient.invalidateQueries({ queryKey: ['ssl-certificates'] });
|
||||||
setRefreshingId(null);
|
setRefreshingId(null);
|
||||||
toast.success(t('sslCertificateRefreshed').replace('{domain}', data.domain));
|
// Removed individual success toast notification
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
// console.error("Error refreshing SSL certificate:", error);
|
console.error("Error refreshing SSL certificate:", error);
|
||||||
|
|
||||||
let errorMessage = t('failedToCheckCertificate');
|
|
||||||
|
|
||||||
if (error instanceof Error) {
|
|
||||||
errorMessage = error.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.error(errorMessage);
|
|
||||||
setRefreshingId(null);
|
setRefreshingId(null);
|
||||||
|
|
||||||
// Still refresh the data to show any partial information that was saved
|
// Still refresh the data to show any partial information that was saved
|
||||||
queryClient.invalidateQueries({ queryKey: ['ssl-certificates'] });
|
queryClient.invalidateQueries({ queryKey: ['ssl-certificates'] });
|
||||||
|
// Removed individual error toast notification
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -149,7 +142,7 @@ export const SSLDomainContent = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
// console.error("Error refreshing all certificates:", error);
|
console.error("Error refreshing all certificates:", error);
|
||||||
toast.error(t('failedToCheckCertificate'));
|
toast.error(t('failedToCheckCertificate'));
|
||||||
setIsRefreshingAll(false);
|
setIsRefreshingAll(false);
|
||||||
|
|
||||||
@@ -174,7 +167,7 @@ export const SSLDomainContent = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateCertificate = (certificate: SSLCertificate) => {
|
const handleUpdateCertificate = (certificate: SSLCertificate) => {
|
||||||
// console.log("Handling certificate update with data:", certificate);
|
console.log("Handling certificate update with data:", certificate);
|
||||||
editMutation.mutate(certificate);
|
editMutation.mutate(certificate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user