PromucFlow_constructor/app/client/src/pages/UserAuth/index.tsx

53 lines
1.9 KiB
TypeScript
Raw Normal View History

2019-12-16 08:49:10 +00:00
import React from "react";
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";
import PageNotFound from "pages/common/PageNotFound";
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}>
<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}
/>
<SentryRoute
2020-01-28 11:46:04 +00:00
exact
path={`${path}/forgotPassword`}
component={ForgotPassword}
/>
<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;