Skip to content

Commit

Permalink
auth: clicking on login navigates to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanth1109 committed Jan 9, 2021
1 parent 31156ba commit 1b7a0e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions auth/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ const CardTitle = styled.h1`
margin: 24px 0;
`;

const App = () => {
interface AppProps {
login: VoidFunction;
}

const App = ({ login }: AppProps) => {
return (
<CardContainer>
<Card variant="outlined">
<CardTitle>Auth microfrontend (2 routes)</CardTitle>
<Switch>
<Route path="/auth/login">
<Login />
<Login login={login} />
</Route>
<Route path="/auth/register">
<Register />
Expand Down
4 changes: 2 additions & 2 deletions auth/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { createBrowserHistory } from "history";

import App from "./App";

const mount = (el: Element, { history }: AuthMountOptions) => {
const mount = (el: Element, { history, login }: AuthMountOptions) => {
ReactDOM.render(
<Router history={history}>
<App />
<App login={login} />
</Router>,
el
);
Expand Down
5 changes: 3 additions & 2 deletions auth/src/components/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { Link } from "react-router-dom";
import Input from "./Input";
import { CardFooter, TabTitle } from "./styled";

const Login = () => {
const Login = ({ login }: { login: VoidFunction }) => {
const onLogin = useCallback(() => {
console.log("login");
// verify details are correct (not implemented) and login
login();
}, []);

return (
Expand Down

0 comments on commit 1b7a0e7

Please sign in to comment.