import * as React from "react"; import CatalogLink from "opds-web-client/lib/components/CatalogLink"; import { HeaderProps } from "opds-web-client/lib/components/Root"; import { Navbar, Nav, NavItem } from "react-bootstrap"; import { NavigateContext } from "opds-web-client/lib/interfaces"; import { LibraryData } from "../interfaces"; import * as PropTypes from "prop-types"; export interface HeaderContext extends NavigateContext { library: LibraryData; } export default class Header extends React.Component { context: HeaderContext; static contextTypes = { library: PropTypes.object.isRequired, router: PropTypes.object.isRequired, pathFor: PropTypes.func.isRequired, }; constructor(props) { super(props); this.signIn = this.signIn.bind(this); this.signOut = this.signOut.bind(this); } render(): JSX.Element { return ( {this.context.library.catalogName} ); } signIn() { if (this.props.fetchLoans && this.props.loansUrl) { this.props.fetchLoans(this.props.loansUrl); } } signOut() { this.props.clearAuthCredentials(); this.context.router.push(this.context.pathFor(this.context.library.catalogUrl, null)); } }