(CANCEL_APP, {
context: { clientName: "backend" },
@@ -47,14 +56,17 @@ const CancelApplicationButton = ({ application, onCancel, disabled, ...rest }: P
const textValues = useMemo(
() => ({
- // TODO: Icon from the design
- icon: isRestoreAction ? : ,
+ icon: isRestoreAction ? (
+
+ ) : (
+
+ ),
dialogTitle: `${isRestoreAction ? "Restore" : "Cancel"} Submission Request`,
dialogDescription: isRestoreAction
? `Are you sure you want to restore the previously canceled submission request for the study listed below?`
: `Are you sure you want to cancel the submission request for the study listed below?`,
}),
- [status, isRestoreAction]
+ [isRestoreAction]
);
const onClickIcon = async () => {
@@ -66,20 +78,21 @@ const CancelApplicationButton = ({ application, onCancel, disabled, ...rest }: P
};
const onConfirmDialog = async () => {
+ setLoading(true);
try {
const { data: d, errors } = await cancelApp({
variables: { _id },
});
if (errors || !d?.cancelApplication?._id) {
- Logger.error("Failed to cancel the application", errors);
- throw new Error("Oops! Unable to cancel that Submission Request.");
+ throw new Error(errors?.[0]?.message || "Unknown API error");
}
setConfirmOpen(false);
onCancel();
} catch (err) {
- enqueueSnackbar(err, { variant: "error" });
+ Logger.error("Failed to cancel the application", err);
+ enqueueSnackbar("Oops! Unable to cancel that Submission Request", { variant: "error" });
} finally {
setLoading(false);
}
@@ -96,6 +109,8 @@ const CancelApplicationButton = ({ application, onCancel, disabled, ...rest }: P
disabled={loading || disabled}
aria-label="Cancel/Restore icon"
data-testid="cancel-restore-application-button"
+ restore={isRestoreAction}
+ disableRipple
{...rest}
>
{textValues.icon}
@@ -104,13 +119,12 @@ const CancelApplicationButton = ({ application, onCancel, disabled, ...rest }: P
open={confirmOpen}
header={textValues.dialogTitle}
description={
-
+
{textValues.dialogDescription}
- {/* TODO: technically this needs to be study name */}
- Study: {application.studyAbbreviation || "N/A"}
-
+ Study: {application.studyAbbreviation || "NA"}
+
}
confirmText="Confirm"
closeText="Cancel"