{"version":3,"file":"ErrorScreen.mjs","sources":["../../../../../../../../../web/src/ui/components/molecules/ErrorScreen.tsx"],"sourcesContent":["import { useLingui } from '@lingui/react/macro';\nimport React, { useMemo } from 'react';\n\nimport { useGlobalReducer } from '../../b2b/GlobalContextProvider';\nimport { AppScreens } from '../../b2b/types/AppScreens';\nimport { ErrorType } from '../../b2b/types/ErrorType';\nimport Button from '../atoms/Button';\nimport Column from '../atoms/Column';\nimport TextColumn from './TextColumn';\n\nexport const ErrorDisplay = ({ text, onGoBack }: { text: string; onGoBack?: () => void }) => {\n  const { t } = useLingui();\n\n  return (\n    <Column gap={6}>\n      <TextColumn header={t({ id: 'error.title', message: 'Looks like there was an error!' })} body={text} />\n\n      {onGoBack && (\n        <Button variant=\"outline\" onClick={onGoBack}>\n          {t({ id: 'button.goBack', message: 'Go back' })}\n        </Button>\n      )}\n    </Column>\n  );\n};\n\nexport const ErrorScreen = () => {\n  const [state, dispatch] = useGlobalReducer();\n  const { t } = useLingui();\n\n  const { type: currentErrorType, canGoBack } = state.error;\n  const organizationName = state.flowState.organization?.organization_name;\n\n  const ErrorTypeMap: Record<ErrorType, string> = {\n    [ErrorType.Default]: t({\n      id: 'error.default',\n      message: 'Something went wrong. Try again later or contact your admin for help.',\n    }),\n    [ErrorType.EmailMagicLink]: t({\n      id: 'error.eml',\n      message:\n        'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.',\n    }),\n    [ErrorType.Organization]: t({\n      id: 'error.organization',\n      message:\n        'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.',\n    }),\n    [ErrorType.CannotJoinOrgDueToAuthPolicy]: organizationName\n      ? t({\n          id: 'error.authPolicyWithOrg',\n          message: `Unable to join due to ${organizationName}'s authentication policy. Please contact your admin for more information.`,\n        })\n      : t({\n          id: 'error.authPolicyNoOrg',\n          message:\n            \"Unable to join due to the organization's authentication policy. Please contact your admin for more information.\",\n        }),\n    [ErrorType.AdBlockerDetected]: t({\n      id: 'error.adBlockerDetected',\n      message:\n        'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.',\n    }),\n    [ErrorType.OrganizationDiscoveryClaimedDomain]: t({\n      id: 'error.claimedDomain',\n      message:\n        'Your email domain is associated with a particular organization, so you are unable to join or create other organizations. Please contact your admin for more information.',\n    }),\n  };\n\n  const handleGoBack = useMemo(() => {\n    if (canGoBack) {\n      return () => dispatch({ type: 'transition', screen: AppScreens.Main });\n    }\n    return undefined;\n  }, [canGoBack, dispatch]);\n\n  return <ErrorDisplay text={ErrorTypeMap[currentErrorType]} onGoBack={handleGoBack} />;\n};\n"],"names":["ErrorDisplay","text","onGoBack","useLingui","React","Column","gap","TextColumn","header","body","Button","variant","onClick","ErrorScreen","state","dispatch","useGlobalReducer","type","currentErrorType","canGoBack","error","organizationName","flowState","organization","organization_name","ErrorTypeMap","ErrorType","Default","EmailMagicLink","Organization","CannotJoinOrgDueToAuthPolicy","AdBlockerDetected","OrganizationDiscoveryClaimedDomain","handleGoBack","useMemo","screen","AppScreens","Main","undefined"],"mappings":";;;;;;;;;;MAUaA,YAAAA,GAAe,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAA2C,GAAA;AACtF,IAAA,MAAM,EAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,GAAA,EAAA,GAAQC,SAAAA,EAAAA;AAEd,IAAA,qBACEC,EAAA,CAAA,aAAA,CAACC,MAAAA,EAAAA;QAAOC,GAAAA,EAAK;qBACXF,EAAA,CAAA,aAAA,CAACG,UAAAA,EAAAA;QAAWC,MAAM,EAAA,OAAA,CAAA,CAAA,CAAA;;;;QAAuEC,IAAAA,EAAMR;AAE9FC,KAAAA,CAAAA,EAAAA,QAAAA,kBACCE,EAAA,CAAA,aAAA,CAACM,MAAAA,EAAAA;QAAOC,OAAAA,EAAQ,SAAA;QAAUC,OAAAA,EAASV;;;;;AAM3C;MAEaW,WAAAA,GAAc,IAAA;IACzB,MAAM,CAACC,KAAAA,EAAOC,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