/* * Copyright 2018 Transposit Corporation. All Rights Reserved. */ import * as React from "react"; import "./App.css"; import { Transposit } from "transposit"; import { Login } from "./Login"; import { Button, Card } from "antd"; import { MainContent } from "./MainContent"; import { Route, Redirect, Switch, withRouter, RouteComponentProps } from "react-router-dom"; import { NoMatch } from "./NoMatch"; import { HandleLogin } from "./HandleLogin"; const logo = require("./logo.svg"); const serviceMaintainer = "${SERVICE_MAINTAINER}"; const serviceName = "${SERVICE_NAME}"; const transpositUrl = "${TRANSPOSIT_URL}"; // Export the instance of the Transposit SDK. This can be imported and used in other files export const transposit = new Transposit( serviceMaintainer, serviceName, transpositUrl ); /* * Contains top-level application logic, including routing and the sidebar. * * Routes: * * /login - has a button to start the login flow. Logged out users are redirected here. * * /handle-login - completes the login process and then redirects to the * main content. Use this as the redirect url in your deploy configuration. * * / - the logged in content for the application * * If none of these match, a 404 page is displayed (NoMatch.tsx) */ class AppContent extends React.Component, {}> { constructor(props: RouteComponentProps<{}>) { super(props); } logOut = async () => { if (!transposit) { throw new Error("logOut called but the Transposit SDK is not available"); } await transposit.logOut(); location.reload(); } renderRoutes() { const loggedInUser = transposit && transposit.getUserInfo(); if (!loggedInUser) { return ( ( )} /> } /> ); } else { return ( } /> ); } } render() { const loggedInUser = transposit && transposit.getUserInfo(); return (
logo

Welcome to Transposit

{
Service: {serviceMaintainer}/{serviceName}
Transposit url: {transpositUrl}
} {loggedInUser && (
Logged in as: {loggedInUser}
)}
{this.renderRoutes()}
); } } // Wrap with withRouter to make sure we re-render when the route changes export default withRouter(AppContent);