mirror of
https://github.com/wassname/talk.git
synced 2026-07-14 11:18:50 +08:00
[CORL-353] show error if network request fails (#2731)
* show error if network request fails * remove commented code * Update src/core/client/admin/routes/AuthCheck/NetworkError.tsx Co-Authored-By: Wyatt Johnson <wyattjoh@gmail.com> * spell occurred correctly
This commit is contained in:
committed by
Wyatt Johnson
parent
9bc41ad020
commit
0e15bc46d2
@@ -10,6 +10,7 @@ import { GQLUSER_ROLE } from "coral-framework/schema";
|
||||
|
||||
import { AuthCheckRouteQueryResponse } from "coral-admin/__generated__/AuthCheckRouteQuery.graphql";
|
||||
|
||||
import NetworkError from "./NetworkError";
|
||||
import RestrictedContainer from "./RestrictedContainer";
|
||||
|
||||
interface Props {
|
||||
@@ -17,6 +18,7 @@ interface Props {
|
||||
router: Router;
|
||||
setRedirectPath: MutationProp<typeof SetRedirectPathMutation>;
|
||||
data: AuthCheckRouteQueryResponse;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
type CheckParams =
|
||||
@@ -86,6 +88,9 @@ function createAuthCheckRoute(check: CheckParams) {
|
||||
}
|
||||
|
||||
public render() {
|
||||
if (this.props.error) {
|
||||
return <NetworkError />;
|
||||
}
|
||||
if (!this.props.data || this.shouldRedirectTo()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
padding: 20px;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Localized } from "fluent-react/compat";
|
||||
import React, { FunctionComponent } from "react";
|
||||
|
||||
import { Message } from "coral-ui/components";
|
||||
|
||||
import styles from "./NetworkError.css";
|
||||
|
||||
const NetworkError: FunctionComponent<{}> = () => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<Message color="error">
|
||||
<Localized id="authcheck-network-error">
|
||||
<span>A network error occurred. Please refresh the page</span>
|
||||
</Localized>
|
||||
</Message>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NetworkError;
|
||||
Reference in New Issue
Block a user