UNPKG

@rnga/orders

Version:

## Get schema from @prisma-cms 1. yarn get-api-schema -e http://localhost:4000 2. yarn build-api-fragments

169 lines (102 loc) 2.29 kB
import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import URI from 'urijs'; import { Typography } from 'material-ui'; export default class PageLayout extends Component { static contextTypes = { user: PropTypes.object, client: PropTypes.object.isRequired, openLoginForm: PropTypes.func.isRequired, uri: PropTypes.object.isRequired, } static propTypes = { } static defaultProps = { }; state = {}; static childContextTypes = { setPageMeta: PropTypes.func, } getChildContext() { return { setPageMeta: this.setPageMeta, }; } setPageMeta = (meta) => { let { title, description, } = meta; if (title) { if (!global.document) { global.document = {} } let { document, } = global; const suffix = " | RNGA"; // Проверять надо именно так, потому что new RegExp не понимает экранирование | if (!/ \| RNGA$|^RNGA\:/.test(title)) { title += suffix; } if (document.title !== title) { document.title = title; } } } onChange(event) { const { name, value, } = event.target; this.setState({ [name]: value, }); } getPage() { const page = this.getUriParam("page"); return page ? parseInt(page) : 1; } getUriParam(param) { const uri = this.getUri(); const query = uri.query(true); return query ? query[param] : null; } getUri() { const { // history: { // }, location, } = this.props; const { pathname, search, } = location; let uri = new URI(pathname); uri.query(search); return uri; } render(content) { const { } = this.props; // const { // user: currentUser, // } = this.context; // const { // id: currentUserId, // sudo, // } = currentUser || {}; // if (!sudo) { // return <Typography // variant="display1" // color="error" // > // Доступ запрещен // </Typography>; // } if (!content) { return null; } return content; } }