Web: Files: Added ThirdPartyResponse page error container, fixed router

This commit is contained in:
Ilya Oleshko 2021-01-15 16:28:08 +03:00
parent 0f96dcfeb4
commit 8f3b4a60dd
2 changed files with 37 additions and 12 deletions

View File

@ -32,6 +32,12 @@ const {
} = CommonStore.auth.actions;
class App extends React.Component {
constructor(props) {
super(props);
const pathname = window.location.pathname.toLowerCase();
this.isThirdPartyResponse = pathname.indexOf("thirdparty") !== -1;
}
componentDidMount() {
const {
getPortalSettings,
@ -41,6 +47,11 @@ class App extends React.Component {
getIsAuthenticated,
} = this.props;
if (this.isThirdPartyResponse) {
setIsLoaded();
return;
}
getIsAuthenticated()
.then((isAuthenticated) => {
if (isAuthenticated) utils.updateTempContent(isAuthenticated);
@ -70,7 +81,7 @@ class App extends React.Component {
render() {
return navigator.onLine ? (
<Router history={history}>
<NavMenu />
{!this.isThirdPartyResponse && <NavMenu />}
<Main>
<Suspense fallback={null}>
<Switch>
@ -85,6 +96,10 @@ class App extends React.Component {
component={Login}
/>
<Route path="/confirm" component={Confirm} />
<Route
path={`/thirdparty/:provider`}
component={ThirdPartyResponse}
/>
<PrivateRoute
exact
path={["/", "/error=:error"]}
@ -98,10 +113,6 @@ class App extends React.Component {
component={ComingSoon}
/>
<PrivateRoute path="/payments" component={Payments} />
<PrivateRoute
path={`/thirdparty/:provider`}
component={ThirdPartyResponse}
/>
<PrivateRoute component={Error404} />
</Switch>
</Suspense>

View File

@ -1,9 +1,9 @@
import React from "react";
import { withRouter } from "react-router";
import { Box } from "asc-web-components";
import { utils } from "asc-web-common";
import { utils, Loaders, ErrorContainer } from "asc-web-common";
const { getObjectByLocation } = utils;
const { getObjectByLocation, showLoader, hideLoader } = utils;
class ThirdPartyResponse extends React.Component {
constructor(props) {
@ -12,18 +12,32 @@ class ThirdPartyResponse extends React.Component {
const urlParams = getObjectByLocation(window.location);
this.code = urlParams ? urlParams.code || null : null;
this.error = urlParams ? urlParams.error || null : null;
this.provider = provider;
}
async componentDidMount() {
localStorage.setItem("provider", this.provider);
localStorage.setItem("code", this.code);
componentDidMount() {
showLoader();
setTimeout(window.close(), 1000);
if (this.code) {
localStorage.setItem("code", this.code);
hideLoader();
window.close();
} else {
hideLoader();
}
}
render() {
return <Box>OK</Box>;
return (
<Box>
{!this.error ? (
<Loaders.Rectangle height="100vh" width="100vw" />
) : (
<ErrorContainer bodyText={this.error} />
)}
</Box>
);
}
}