migration to WSL

This commit is contained in:
canove
2020-06-24 09:40:51 -03:00
parent 0270ae09e6
commit c60c0f44fc
47 changed files with 17939 additions and 17696 deletions

View File

@@ -1,71 +1,93 @@
import React, { useContext } from "react";
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";
import { AuthContext, AuthProvider } from "./Context/Auth/AuthContext";
import Dashboard from "./pages/Home/Dashboard";
import Chat from "./pages/Chat/Chat";
import Profile from "./pages/Profile/Profile";
import Signup from "./pages/Signup/Signup";
import Login from "./pages/Login/Login";
import WhatsAuth from "./pages/WhatsAuth/WhatsAuth";
const PrivateRoute = ({ component: Component, ...rest }) => {
const { isAuth, loading } = useContext(AuthContext);
if (loading) return <h1>Loading...</h1>;
return (
<Route
{...rest}
render={props =>
isAuth ? (
<Component {...props} />
) : (
<Redirect
to={{ pathname: "/login", state: { from: props.location } }}
/>
)
}
/>
);
};
const PublicRoute = ({ component: Component, ...rest }) => {
const { isAuth, loading } = useContext(AuthContext);
if (loading) return <h1>Loading...</h1>;
return (
<Route
{...rest}
render={props =>
!isAuth ? (
<Component {...props} />
) : (
<Redirect to={{ pathname: "/", state: { from: props.location } }} />
)
}
/>
);
};
const Routes = () => {
return (
<BrowserRouter>
<AuthProvider>
<Switch>
<PrivateRoute exact path="/" component={Dashboard} />
<PrivateRoute exact path="/chat" component={Chat} />
<PrivateRoute exact path="/chat/:contactId" component={Chat} />
<PrivateRoute exact path="/profile" component={Profile} />
<PrivateRoute exact path="/whats-auth" component={WhatsAuth} />
<PublicRoute exact path="/login" component={Login} />
<PublicRoute exact path="/signup" component={Signup} />
</Switch>
</AuthProvider>
</BrowserRouter>
);
};
export default Routes;
import React, { useContext } from "react";
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";
import { AuthContext, AuthProvider } from "./Context/Auth/AuthContext";
import Dashboard from "./pages/Home/Dashboard";
import Chat from "./pages/Chat/Chat";
import Profile from "./pages/Profile/Profile";
import Signup from "./pages/Signup/Signup";
import Login from "./pages/Login/Login";
import WhatsAuth from "./pages/WhatsAuth/WhatsAuth";
import Backdrop from "@material-ui/core/Backdrop";
import CircularProgress from "@material-ui/core/CircularProgress";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles(theme => ({
backdrop: {
zIndex: theme.zIndex.drawer + 1,
color: "#fff",
},
}));
const PrivateRoute = ({ component: Component, ...rest }) => {
const classes = useStyles();
const { isAuth, loading } = useContext(AuthContext);
if (loading)
return (
<Backdrop className={classes.backdrop} open={loading}>
<CircularProgress color="inherit" />
</Backdrop>
);
return (
<Route
{...rest}
render={props =>
isAuth ? (
<Component {...props} />
) : (
<Redirect
to={{ pathname: "/login", state: { from: props.location } }}
/>
)
}
/>
);
};
const PublicRoute = ({ component: Component, ...rest }) => {
const classes = useStyles();
const { isAuth, loading } = useContext(AuthContext);
if (loading)
return (
<Backdrop className={classes.backdrop} open={loading}>
<CircularProgress color="inherit" />
</Backdrop>
);
return (
<Route
{...rest}
render={props =>
!isAuth ? (
<Component {...props} />
) : (
<Redirect to={{ pathname: "/", state: { from: props.location } }} />
)
}
/>
);
};
const Routes = () => {
return (
<BrowserRouter>
<AuthProvider>
<Switch>
<PrivateRoute exact path="/" component={Dashboard} />
<PrivateRoute exact path="/chat" component={Chat} />
<PrivateRoute exact path="/chat/:contactId" component={Chat} />
<PrivateRoute exact path="/profile" component={Profile} />
<PrivateRoute exact path="/whats-auth" component={WhatsAuth} />
<PublicRoute exact path="/login" component={Login} />
<PublicRoute exact path="/signup" component={Signup} />
</Switch>
</AuthProvider>
</BrowserRouter>
);
};
export default Routes;