Backup before moving to local state instead of hooks.
This commit is contained in:
@@ -76,16 +76,6 @@ export default function Auth() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const signOut = async () => {
|
||||
try {
|
||||
setAuthState({ status: "loading" });
|
||||
await firebase.auth().signOut();
|
||||
setAuthState({ status: "out" });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
let content;
|
||||
if (authState.status === "loading") {
|
||||
content = <Spin />;
|
||||
|
||||
@@ -16,6 +16,7 @@ import Manage from "../pages/manage/manage.page";
|
||||
|
||||
import PrivateRoute from "../utils/private-route";
|
||||
import SignInContainer from "../pages/sign-in/sign-in.container";
|
||||
import Unauthorized from "../pages/unauthorized/unauthorized.component";
|
||||
|
||||
const graphqlEndpoint = process.env.REACT_APP_GRAPHQL_ENDPOINT;
|
||||
|
||||
@@ -47,15 +48,22 @@ export default function App({ authState }) {
|
||||
|
||||
return (
|
||||
<ApolloProvider client={client}>
|
||||
<div>{authState.status}</div>
|
||||
<Switch>
|
||||
<Route exact path="/" component={LandingPage} />
|
||||
<Route exact path="/unauthorized" component={Unauthorized} />
|
||||
<Route
|
||||
exact
|
||||
path="/signin"
|
||||
render={() =>
|
||||
authState ? <Redirect to="/manage" /> : <SignInContainer />
|
||||
authState.status == "in" ? (
|
||||
<Redirect to="/manage" />
|
||||
) : (
|
||||
<SignInContainer />
|
||||
)
|
||||
}
|
||||
/>
|
||||
{/* <Route path="/signin" component={SignInContainer} /> */}
|
||||
<PrivateRoute isAuthorized={isIn} path="/manage" component={Manage} />
|
||||
</Switch>
|
||||
</ApolloProvider>
|
||||
|
||||
Reference in New Issue
Block a user