UNPKG

@atlaskit/profilecard

Version:

A React component to display a card with user information.

47 lines 1.89 kB
import React, { useEffect } from 'react'; import ButtonLegacy from '@atlaskit/button'; import Button from '@atlaskit/button/new'; import CrossCircleIcon from '@atlaskit/icon/core/cross-circle'; import IconError from '@atlaskit/icon/glyph/cross-circle'; import { fg } from '@atlaskit/platform-feature-flags'; import { Text } from '@atlaskit/primitives'; import { ErrorTitle, ErrorWrapper } from '../../styled/Error'; import { profileCardRendered } from '../../util/analytics'; const ErrorMessage = props => { const errorType = props.errorType || { reason: 'default' }; const errorReason = errorType.reason; const { fireAnalytics, reload } = props; const hasRetry = !!reload; useEffect(() => { fireAnalytics(profileCardRendered('user', 'error', { hasRetry, errorType: errorReason })); }, [errorReason, fireAnalytics, hasRetry]); const errorContent = () => { if (errorReason === 'NotFound') { return /*#__PURE__*/React.createElement(ErrorTitle, null, "The user is no longer available for the site"); } return /*#__PURE__*/React.createElement(ErrorTitle, null, "Oops, looks like we\u2019re having issues", /*#__PURE__*/React.createElement("br", null), reload && /*#__PURE__*/React.createElement(Text, { color: "color.text.subtlest" }, "Try again and we\u2019ll give it another shot")); }; return /*#__PURE__*/React.createElement(ErrorWrapper, { testId: "profilecard-error" }, /*#__PURE__*/React.createElement(CrossCircleIcon, { label: "icon error", LEGACY_fallbackIcon: IconError, LEGACY_size: "xlarge" }), errorContent(), reload && (fg('ptc_migrate_buttons') ? /*#__PURE__*/React.createElement(Button, { onClick: reload }, "Try again") : /*#__PURE__*/React.createElement(ButtonLegacy, { appearance: "link", onClick: reload }, "Try again"))); }; export default ErrorMessage;