UNPKG

@rnga/orders

Version:

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

113 lines (78 loc) 1.84 kB
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import ImportIcon from "material-ui-icons/CloudDownload"; import { IconButton } from 'material-ui'; import SingleUploader from "FileUploader/SingleUploader"; import { graphql } from 'react-apollo'; import gql from 'graphql-tag'; import Context from "@prisma-cms/context"; class ImportOrders extends Component { static propTypes = { }; static contextType = Context; state = { opened: false, } import(event){ const { name, value, } = event.target; } render() { const { opened, uploading, } = this.state; const { mutate, } = this.props; let content; if (opened) { content = <SingleUploader // type="file" // name="file" // onChange={event => { // event.preventDefault(); // this.import(event); // }} mutate={mutate} label={uploading ? "Выполняется импорт..." : "Загрузите excel-файл"} // mutate={func => { // }} onStartUpload={func => { this.setState({ uploading: true, }); }} onUpload={result => { const { client, } = this.context; this.setState({ opened: false, uploading: false, }); return client.reFetchObservableQueries(); }} /> } else { content = <IconButton onClick={event => { this.setState({ opened: true, }); }} > <ImportIcon /> </IconButton> } return content; } } export default graphql(gql` mutation($file: Upload!) { importOrders(file: $file) } `)(ImportOrders);