{"version":3,"file":"index.js","sources":["../../../../../../../../apps/acp/packages/error-boundary/styles/error-boundary.ccm.css.ts","../../../../../../../../apps/acp/packages/error-boundary/error-screens.tsx","../../../../../../../../apps/acp/packages/error-boundary/errors.ts","../../../../../../../../apps/acp/packages/error-boundary/error-boundary.tsx"],"sourcesContent":["\nimport { ComponentCreator, createComponentCreator, styleInject } from 'packages/css-component-modules';\n\nconst _css = `.ErrorBoundary_720cc61b73785dae{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.CenteredText_0280a4435e1552d4{text-align:center}`;\nstyleInject(_css)\n\n/** ErrorBoundary Props */\nexport type ErrorBoundaryCCM = {\n /** ErrorBoundary Component Custom Properties */\n // No custom properties found\n\n /** ErrorBoundary Modifier Flags */\n // No modifiers classes found\n};\n/** Base ErrorBoundary component */\nexport const ErrorBoundary: ComponentCreator = createComponentCreator({\n \"name\": \"ErrorBoundary\",\n \"base\": \"ErrorBoundary_720cc61b73785dae\",\n \"prop\": {},\n \"mod\": {}\n});\n\n\n/** CenteredText Props */\nexport type CenteredTextCCM = {\n /** CenteredText Component Custom Properties */\n // No custom properties found\n\n /** CenteredText Modifier Flags */\n // No modifiers classes found\n};\n/** Base CenteredText component */\nexport const CenteredText: ComponentCreator = createComponentCreator({\n \"name\": \"CenteredText\",\n \"base\": \"CenteredText_0280a4435e1552d4\",\n \"prop\": {},\n \"mod\": {}\n});\n\n","import { createElement, FC } from 'react';\nimport { Anchor, Link, useAnchor } from 'packages/react-nano-router';\nimport { Title, Body } from 'legos/typography';\nimport { Button } from 'legos/button-legacy';\nimport { ContentBlock } from 'legos/content-block';\n\nimport { Illustration } from 'legos/illustration';\nimport { SuspenseHandler } from 'apps/acp/packages/react-suspense-handler';\nimport {\n ErrorBoundary as RawErrorBoundary,\n CenteredText\n} from './styles/error-boundary.ccm.css';\nimport { ErrorObject } from './errors';\nimport { ButtonFlat } from 'legos/button/flat';\nimport { CenterChildren } from 'apps/acp/packages/center-children';\nimport { useHttpQuery } from 'packages/http-client/react';\nimport {\n ClientErrorLog,\n createClientErrorLogRequest\n} from 'apps/acp/packages/webapi';\n\ninterface ErrorScreenProps {\n error: ErrorObject;\n}\n\nexport const ErrorScreen: FC = ({ error, children }) => (\n \n \n \n \n \n \n {error.title}\n \n {error.body}\n \n {children}\n \n \n \n);\n\ninterface ErrorWithRetryProps extends ErrorScreenProps {\n retry: () => void;\n acpVersion: string;\n returnLink?: Anchor;\n webapiUrl?: string;\n type?: 'API' | 'JAVASCRIPT';\n statusCode?: string;\n}\n\nexport const ErrorLogger: FC<{ requestObj: ClientErrorLog }> = ({\n requestObj\n}) => {\n useHttpQuery(createClientErrorLogRequest(requestObj));\n return null;\n};\n\nexport const ErrorWithRetry: FC = ({\n error,\n retry,\n returnLink,\n acpVersion,\n webapiUrl,\n statusCode = 'UNKNOWN STATUS',\n type = 'API'\n}) => {\n const accessToken = sessionStorage.getItem('acp_access_token');\n const storedAuthBlocks = sessionStorage.getItem('acp_auth_blocks');\n const noAuthBlock =\n !storedAuthBlocks ||\n (storedAuthBlocks && JSON.parse(atob(storedAuthBlocks)).length === 0)\n ? true\n : false;\n\n const request: ClientErrorLog = {\n log_type: 'error',\n error_code: statusCode,\n payload: `client side error caused from ${type} on - ${location.href}, with error message ${error.title}: ${error.body}. UserAgent: ${navigator.userAgent}, webapiUrl: ${webapiUrl}`,\n acpVersion: acpVersion\n };\n\n return (\n \n \n \n {noAuthBlock && accessToken && error.returnLink && (\n \n {error.returnLink}\n \n )}\n \n );\n};\n\ninterface ErrorWithLinkProps extends ErrorScreenProps {\n returnLink: Link;\n}\n\nexport const ErrorWithLink: FC = ({\n error,\n returnLink\n}) => {\n const returnLinkAnchor = useAnchor(returnLink);\n return (\n \n \n \n );\n};\n","export interface ErrorObject {\n title: string;\n body: string;\n CTA: string;\n returnLink?: string;\n}\n\n// TODO use around these elements\n// https://bitbucket.hq.netspend.com/projects/APP/repos/account-center-platform/pull-requests/6679/overview?commentId=105861\nexport const Errors: { [key: string]: ErrorObject } = {\n UNKNOWN: {\n title: 'Something went wrong',\n body: 'We were unable to load this page at this time.',\n CTA: 'Try Again',\n returnLink: 'Return Home'\n },\n UNAVAILABLE: {\n title: 'Service unavailable',\n body: 'Try again soon, we’re working on it.',\n CTA: 'Try Again'\n },\n NETWORK_CONNECTION: {\n title: 'Can’t connect',\n body:\n 'We can’t find a network connection. Please check your connectivity and try again.',\n CTA: 'Try Again'\n },\n UNKNOWN_REJECTION: {\n title: 'Something went wrong',\n body: 'We were unable to load this page at this time.',\n CTA: 'Try Again',\n returnLink: 'Return Home'\n },\n AUTH_EXPIRED: {\n title: 'Your session has expired',\n body: 'For your security, we have logged you off.',\n CTA: 'Log Back In'\n }\n};\n\nexport type AuthErrorType = 'expired' | 'invalid';\n\nexport class AuthError extends Error {\n constructor(\n public readonly error: AuthErrorType,\n public response?: Response\n ) {\n super('AcpAuthError');\n }\n}\n","import { createElement, FC } from 'react';\nimport { Redirect, useAnchor } from 'packages/react-nano-router';\nimport { ErrorBoundary as ReactErrorBoundary } from 'packages/react-error-boundary';\nimport { HttpClientErrorBoundary } from 'packages/http-client/react';\n\nimport { ErrorWithRetry } from './error-screens';\nimport { Errors, AuthError } from './errors';\nimport { LogoutLinks } from 'apps/acp/micro-frontends/logout';\nimport { DashboardLinks } from 'apps/acp/micro-frontends/dashboard';\n\n/**\n * Blanket handler for any unknown rejection errors. This is where we'll\n * be handling any authentication related errors\n */\nconst handleUnknownRejectionError = (\n error: any,\n retry: () => void,\n logoutLink: LogoutLinks,\n acpVersion: string\n) => {\n if (error instanceof AuthError) {\n /* capturing path along with queryparams\n I can not use `useLocation()` as i am regular javascript function\n */\n const path = `${window.location.pathname}${window.location.search}`;\n\n const redirectToUrl =\n error.error === 'expired'\n ? `${logoutLink.logoutWithPostAuthPathWithReason.url({\n reason: 'session-timeout',\n path: encodeURIComponent(path)\n })}`\n : `${logoutLink.logoutWithPostAuthPath.url({\n path: encodeURIComponent(path)\n })}`;\n return logoutLink ? (\n \n ) : (\n \n );\n }\n return (\n \n );\n};\n\ninterface ErrorBoundaryProps {\n logoutLink: LogoutLinks;\n returnLink: DashboardLinks;\n acpVersion: string;\n}\n\n/**\n * The exported ErrorBoundary component, catches all network and application\n * errors thrown.\n */\nexport const ErrorBoundary: FC = ({\n logoutLink,\n returnLink,\n acpVersion,\n children\n}) => {\n const returnToHomeAnchor = useAnchor(returnLink.main);\n return (\n (\n \n )}\n >\n (\n \n )}\n renderNotOkFetchResponse={(_, retry, url, status) => (\n \n )}\n renderServiceUnavailable={(_, retry, url, status) => (\n \n )}\n renderUnknownRejectedFetchError={(error, retry) =>\n handleUnknownRejectionError(error, retry, logoutLink, acpVersion)\n }\n >\n {children}\n \n \n );\n};\n"],"names":["styleInject","ErrorBoundary","createComponentCreator","name","base","prop","mod","CenteredText","ErrorScreen","error","children","createElement","RawErrorBoundary","div","SuspenseHandler","ContentBlock","Illustration","type","label","Title","style","marginBottom","marginTop","title","Body","body","CenterChildren","ErrorLogger","requestObj","useHttpQuery","createClientErrorLogRequest","ErrorWithRetry","retry","returnLink","acpVersion","webapiUrl","statusCode","accessToken","sessionStorage","getItem","storedAuthBlocks","noAuthBlock","JSON","parse","atob","length","request","log_type","error_code","payload","location","href","navigator","userAgent","Button","variant","onClick","CTA","ButtonFlat","color","Errors","UNKNOWN","UNAVAILABLE","NETWORK_CONNECTION","UNKNOWN_REJECTION","AUTH_EXPIRED","AuthError","Error","[object Object]","response","super","this","logoutLink","returnToHomeAnchor","useAnchor","main","ReactErrorBoundary","renderError","_","HttpClientErrorBoundary","renderNetworkConnectivity","url","renderNotOkFetchResponse","status","toString","renderServiceUnavailable","renderUnknownRejectedFetchError","path","window","pathname","search","redirectToUrl","logoutWithPostAuthPathWithReason","reason","encodeURIComponent","logoutWithPostAuthPath","Redirect","to","handleUnknownRejectionError"],"mappings":"i6BAIAA,EADa,mKAYN,MAAMC,EAAoDC,EAAuB,CACtFC,KAAQ,gBACRC,KAAQ,iCACRC,KAAQ,GACRC,IAAO,KA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