address PR feedback
This commit is contained in:
3 files changed
+12
-21
No files matched your search
@@ -65,14 +65,16 @@ const useDeleteNotification = () => {
|
|||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const deleteNotification = async (id, triggerUpdate) => {
|
const deleteNotification = async (id, callback) => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await networkService.deleteNotificationById({ id });
|
await networkService.deleteNotificationById({ id });
|
||||||
createToast({
|
createToast({
|
||||||
body: t("notifications.delete.success"),
|
body: t("notifications.delete.success"),
|
||||||
});
|
});
|
||||||
triggerUpdate();
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
setError(error);
|
||||||
createToast({
|
createToast({
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ const ActionMenu = ({ notification, onDelete }) => {
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<MenuItem onClick={handleConfigure}>{t("configure", "Configure")}</MenuItem>
|
<MenuItem onClick={handleConfigure}>{t("configure")}</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={handleRemove}
|
onClick={handleRemove}
|
||||||
sx={{ "&.MuiButtonBase-root": { color: theme.palette.error.main } }}
|
sx={{ "&.MuiButtonBase-root": { color: theme.palette.error.main } }}
|
||||||
>
|
>
|
||||||
{t("delete", "Delete")}
|
{t("delete")}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ const CreateNotifications = () => {
|
|||||||
const { notificationId } = useParams();
|
const { notificationId } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [createNotification, isCreating, createNotificationError] =
|
const [createNotification, isCreating] = useCreateNotification();
|
||||||
useCreateNotification();
|
const [editNotification, isEditing] = useEditNotification();
|
||||||
const [editNotification, isEditing, editNotificationError] = useEditNotification();
|
const [testNotification, isTesting] = useTestNotification();
|
||||||
const [testNotification, isTesting, testNotificationError] = useTestNotification();
|
const [deleteNotification, isDeleting] = useDeleteNotification();
|
||||||
const [deleteNotification, isDeleting, deleteError] = useDeleteNotification();
|
|
||||||
|
|
||||||
const BREADCRUMBS = [
|
const BREADCRUMBS = [
|
||||||
{ name: "notifications", path: "/notifications" },
|
{ name: "notifications", path: "/notifications" },
|
||||||
@@ -61,7 +60,7 @@ const CreateNotifications = () => {
|
|||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [notificationIsLoading, getNotificationError] = useGetNotificationById(
|
const [notificationIsLoading] = useGetNotificationById(
|
||||||
notificationId,
|
notificationId,
|
||||||
setNotification
|
setNotification
|
||||||
);
|
);
|
||||||
@@ -136,17 +135,7 @@ const CreateNotifications = () => {
|
|||||||
|
|
||||||
const onDelete = () => {
|
const onDelete = () => {
|
||||||
if (notificationId) {
|
if (notificationId) {
|
||||||
deleteNotification(
|
deleteNotification(notificationId, () => navigate("/notifications"));
|
||||||
notificationId,
|
|
||||||
() => navigate("/notifications"), // Success callback
|
|
||||||
(error) => {
|
|
||||||
// Error handling
|
|
||||||
createToast({
|
|
||||||
body: `Delete failed: ${error.message}`,
|
|
||||||
type: "error",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user