misc: updated toast

This commit is contained in:
Sheen Capadngan
2024-07-09 23:32:26 +08:00
parent 079e005f49
commit 28723e9a4e
@@ -1,4 +1,5 @@
import { useState } from "react"; import { useState } from "react";
import { TypeOptions } from "react-toastify";
import { subject } from "@casl/ability"; import { subject } from "@casl/ability";
import { import {
faAngleDown, faAngleDown,
@@ -259,30 +260,30 @@ export const ActionBar = ({
secretIds: secretsToMove.map((sec) => sec.id) secretIds: secretsToMove.map((sec) => sec.id)
}); });
let successMessage = ""; let notificationMessage = "";
let notificationType: TypeOptions = "info";
if (isDestinationUpdated && isSourceUpdated) { if (isDestinationUpdated && isSourceUpdated) {
successMessage = "Successfully moved selected secrets"; notificationMessage = "Successfully moved selected secrets";
notificationType = "success";
} else if (isDestinationUpdated) { } else if (isDestinationUpdated) {
successMessage = notificationMessage =
"Successfully created secrets in destination. A secret approval request has been generated for the source."; "Successfully created secrets in destination. A secret approval request has been generated for the source.";
} else if (isSourceUpdated) { } else if (isSourceUpdated) {
successMessage = "A secret approval request has been generated in the destination"; notificationMessage = "A secret approval request has been generated in the destination";
} else { } else {
successMessage = notificationMessage =
"A secret approval request has been generated in both the source and the destination."; "A secret approval request has been generated in both the source and the destination.";
} }
createNotification({ createNotification({
type: "success", type: notificationType,
text: successMessage text: notificationMessage
}); });
resetSelectedSecret(); resetSelectedSecret();
} catch (error) { } catch (error) {
createNotification({ console.error(error);
type: "error",
text: "Error moving selected secrets"
});
} }
}; };