import React from 'react'; import { fromUnixTime, formatDistanceToNow } from "date-fns"; import { formatInTimeZone } from 'date-fns-tz'; import superagent from 'superagent'; import { Message, Segment, Modal, Header, Icon, Button, Table, Form, Divider, Label } from 'semantic-ui-react' import BigShipperWrapper from './BigShipperWrapper.jsx'; import * as ApiUtils from '../CloudApi/ApiUtils.js'; import BigOrderComponent from '../BigOrders/BigOrderComponent.jsx'; import HandScannerInput from '../Util/HandScannerInput.jsx'; import BigOrdersQuery from '../BigOrders/BigOrdersQuery.jsx'; export default class BigShipperNextOrder extends React.Component { constructor(props) { super(props); this.state = { loading: false, nextInventoryItems: [], currentShipment: null, productDatabaseOptions: [] }; } async componentDidMount() { //this.setState({ loading: true }); let schemas = await ApiUtils.getFabricatorSchemas(); this.setState({ schemas }); } async onScannedSerialNumberFinished(scannedSerialNumber) { if (scannedSerialNumber.startsWith("bs")) { scannedSerialNumber = scannedSerialNumber.toUpperCase(); } this.setState({ loading: true, scannedSerialNumber: "" }); const res = await superagent.get(`/api/admin/inventory/items?serialNumber=${scannedSerialNumber}`); console.log(res.body); this.setState({ items: res.body.items, binNumber: res.body.binNumber, menuLoading: false }); const res2 = await superagent.get(`/api/admin/inventory/hint?serialNumber=${scannedSerialNumber}`); console.log(res2.body); this.setState({ hint: res2.body.hint, newItemSerialNumber: scannedSerialNumber, loading: false }); } async onCreateShipment(bigOrderId, shipmentGroupId) { this.setState({ loading: true }); try { const res = await superagent.post(`/api/admin/shipper/shipment`).send({ bigOrderId, shipmentGroupId }); window.location.href = `/shipper/shipment/${res.body.id}`; } catch (e) { console.log(e); this.setState({ loading: false }); } } async onUpdateQuery(params) { this.setState({ loading: true, inventoryItems: [], bigOrder: null }); let shipperResults = []; try { const result = await superagent.get(`/api/admin/shipper/next3?${params.toString()}`); shipperResults = result.body; } catch (e) { console.log(e); } this.setState({ shipperResults, loading: false }); } render() { let bigShipperResults = null; if (this.state.shipperResults && this.state.shipperResults.length > 0) { bigShipperResults = this.state.shipperResults.map((result) => ( <>