2019-12-16 08:49:10 +00:00
|
|
|
import React from "react";
|
2020-09-24 16:05:18 +00:00
|
|
|
import { Switch, useRouteMatch, useLocation, Route } from "react-router-dom";
|
2019-12-16 08:49:10 +00:00
|
|
|
import Login from "./Login";
|
|
|
|
|
import Centered from "components/designSystems/appsmith/CenteredWrapper";
|
2020-01-28 11:46:04 +00:00
|
|
|
import { animated, useTransition } from "react-spring";
|
2019-12-16 08:49:10 +00:00
|
|
|
import { AuthContainer, AuthCard } from "./StyledComponents";
|
|
|
|
|
import SignUp from "./SignUp";
|
|
|
|
|
import ForgotPassword from "./ForgotPassword";
|
|
|
|
|
import ResetPassword from "./ResetPassword";
|
2020-08-14 06:01:50 +00:00
|
|
|
import PageNotFound from "pages/common/PageNotFound";
|
2020-09-24 16:05:18 +00:00
|
|
|
import * as Sentry from "@sentry/react";
|
|
|
|
|
const SentryRoute = Sentry.withSentryRouting(Route);
|
|
|
|
|
|
2020-01-28 11:46:04 +00:00
|
|
|
const AnimatedAuthCard = animated(AuthContainer);
|
2019-12-16 08:49:10 +00:00
|
|
|
export const UserAuth = () => {
|
|
|
|
|
const { path } = useRouteMatch();
|
|
|
|
|
const location = useLocation();
|
2020-01-28 11:46:04 +00:00
|
|
|
const transitions = useTransition(location, location => location.pathname, {
|
|
|
|
|
from: { opacity: 0, transform: "translate3d(50%,0,0)" },
|
|
|
|
|
enter: { opacity: 1, transform: "translate3d(0%,0,0)" },
|
|
|
|
|
leave: { opacity: 0, transform: "translate3d(-50%,0,0)" },
|
|
|
|
|
reset: true,
|
|
|
|
|
});
|
|
|
|
|
const renderTransitions = transitions.map(
|
|
|
|
|
({ item: location, props, key }) => (
|
|
|
|
|
<AnimatedAuthCard key={key} style={props}>
|
|
|
|
|
<Centered>
|
|
|
|
|
<AuthCard>
|
|
|
|
|
<Switch location={location}>
|
2020-09-24 16:05:18 +00:00
|
|
|
<SentryRoute exact path={`${path}/login`} component={Login} />
|
|
|
|
|
<SentryRoute exact path={`${path}/signup`} component={SignUp} />
|
|
|
|
|
<SentryRoute
|
2020-01-28 11:46:04 +00:00
|
|
|
exact
|
|
|
|
|
path={`${path}/resetPassword`}
|
|
|
|
|
component={ResetPassword}
|
|
|
|
|
/>
|
2020-09-24 16:05:18 +00:00
|
|
|
<SentryRoute
|
2020-01-28 11:46:04 +00:00
|
|
|
exact
|
|
|
|
|
path={`${path}/forgotPassword`}
|
|
|
|
|
component={ForgotPassword}
|
|
|
|
|
/>
|
2020-09-24 16:05:18 +00:00
|
|
|
<SentryRoute component={PageNotFound} />
|
2020-01-28 11:46:04 +00:00
|
|
|
</Switch>
|
|
|
|
|
</AuthCard>
|
|
|
|
|
</Centered>
|
|
|
|
|
</AnimatedAuthCard>
|
|
|
|
|
),
|
2019-12-16 08:49:10 +00:00
|
|
|
);
|
2020-01-28 11:46:04 +00:00
|
|
|
return <React.Fragment>{renderTransitions}</React.Fragment>;
|
2019-12-16 08:49:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default UserAuth;
|