UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

53 lines (52 loc) 2.42 kB
import { jsxs, Fragment, jsx } from "react/jsx-runtime"; import { useState } from "react"; import { ButtonComponent } from "../button/Button.js"; import { CodeComponent } from "../code/Code.js"; import { DialogComponent } from "../dialog/Dialog.js"; import { HeadingComponent } from "../heading/Heading.js"; import { StackComponent } from "../stack/Stack.js"; import { getIsLocalDev } from "../../getIsLocalDev.js"; import { useToggleModal } from "../../message/useToggleModal.js"; import { ComponentErrorState } from "./ComponentErrorState.js"; import { useStyles } from "./ErrorModal.styles.js"; const ComponentAirplaneInternalErrorFallback = ({ errorMessage, componentName, errorID }) => { const isLocalDev = getIsLocalDev(); const [opened, setOpened] = useState(isLocalDev); useToggleModal(setOpened, errorID); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(AirplaneInternalErrorModal, { errorMessage, componentName, opened, setOpened }), /* @__PURE__ */ jsx(ComponentErrorState, { componentName, onClick: () => setOpened(true) }) ] }); }; const AirplaneInternalErrorModal = ({ errorMessage, componentName, opened, setOpened }) => { const { classes } = useStyles(); return /* @__PURE__ */ jsx(DialogComponent, { opened, onClose: () => setOpened(false), title: /* @__PURE__ */ jsxs(HeadingComponent, { level: 4, className: classes.title, children: [ "An internal error has occurred", " ", componentName ? ` in the ${componentName} component` : "" ] }), size: "100%", classNames: { modal: classes.modal }, children: /* @__PURE__ */ jsx(StackComponent, { children: /* @__PURE__ */ jsxs(StackComponent, { children: [ /* @__PURE__ */ jsx(CodeComponent, { language: "none", copyLabel: "Copy error", children: errorMessage }), /* @__PURE__ */ jsxs(StackComponent, { spacing: "sm", direction: "row", justify: "end", children: [ /* @__PURE__ */ jsx(ButtonComponent, { href: "https://www.airplane-status.com/", size: "xs", preset: "tertiary", disableFocusRing: true, children: "Check status page" }), /* @__PURE__ */ jsx(ButtonComponent, { href: "mailto:support@airplane.dev", size: "xs", disableFocusRing: true, children: "Contact support" }) ] }) ] }) }) }); }; export { AirplaneInternalErrorModal, ComponentAirplaneInternalErrorFallback }; //# sourceMappingURL=ComponentAirplaneInternalErrorFallback.js.map