import React, { useRef } from 'react';
import superagent from 'superagent';
import { Message, Segment, Grid, Header, Icon, Button, Table, Form, Divider, Label, Transition } from 'semantic-ui-react'
import * as ApiUtils from '../CloudApi/ApiUtils.js';
import BigApiErrorMessage from '../CloudApi/BigApiErrorMessage.jsx';
import HandScannerInput from '../Util/HandScannerInput.jsx';
import InventoryWrapper from './InventoryWrapper.jsx';
import InventoryItemComponent from './InventoryItemComponent.jsx';
export default class InventoryAdd extends React.Component {
constructor(props) {
super(props);
this.state = {
savedQueries: [],
newItemSerialNumber: "",
error: null
};
}
async componentDidMount() {
this.setState({ menuLoading: true });
let schemas = await ApiUtils.getFabricatorSchemas();
this.setState({ schemas });
}
async onCreateBigInventoryItem() {
try {
const res = await superagent.post(`/api/admin/inventory/item`).send({
serialNumber: this.state.serialNumber,
trackingType: "QuantityTracked",
productType: this.state.productType,
quantity: this.state.quantity || 0
});
window.location.href = `/inventory/item/${res.body.id}`;
} catch (e) {
console.log(e);
this.setState({ error: ex.response });
}
}
onChange(e, { name, value }) {
this.setState({ [name]: value })
}
onDismissMessage(e) {
this.setState({ message: null });
}
render() {
if (!this.state.schemas) {
return