mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
feat: add UI support for ABM error message
This commit is contained in:
parent
dc7639c07b
commit
3dc65d7432
1 changed files with 12 additions and 1 deletions
|
|
@ -1,6 +1,14 @@
|
|||
import React, { FormEvent, useCallback, useMemo, useState } from "react";
|
||||
import React, {
|
||||
FormEvent,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useState,
|
||||
useContext,
|
||||
} from "react";
|
||||
|
||||
import mdmAppleBusinessManagerApi from "services/entities/mdm_apple_bm";
|
||||
import { NotificationContext } from "context/notification";
|
||||
import { getErrorReason } from "interfaces/errors";
|
||||
|
||||
import Icon from "components/Icon";
|
||||
import Button from "components/buttons/Button";
|
||||
|
|
@ -23,6 +31,7 @@ const useDownloadABMKey = ({
|
|||
onError,
|
||||
}: Omit<IDownloadABMKeyProps, "baseClass">) => {
|
||||
const [downloadState, setDownloadState] = useState<RequestState>(undefined);
|
||||
const { renderFlash } = useContext(NotificationContext);
|
||||
|
||||
const handleDownload = useCallback(
|
||||
async (evt: FormEvent) => {
|
||||
|
|
@ -34,6 +43,8 @@ const useDownloadABMKey = ({
|
|||
setDownloadState("success");
|
||||
onSuccess && onSuccess();
|
||||
} catch (e) {
|
||||
const msg = getErrorReason(e);
|
||||
renderFlash("error", msg);
|
||||
setDownloadState("error");
|
||||
onError && onError(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue