import React from 'react';
import { fromUnixTime, formatDistanceToNow } from "date-fns";
import { formatInTimeZone } from 'date-fns-tz';
import superagent from 'superagent';
import * as ApiUtils from '../CloudApi/ApiUtils.js';
import constants, { DEFAULT_TIMEZONE } from '../CloudApi/Constants.js';
import BigShipperWrapper from './BigShipperWrapper.jsx';
import { Card, Button, Table, Statistic, Label, Message, Icon, Image } from 'semantic-ui-react'
import InventoryItemPickingHint from './InventoryItemPickingHint.jsx';
export default class BigShipmentInventoryCards extends React.Component {
constructor(props) {
super(props);
}
async removeInventoryItem(e) {
}
async onAddToShipment(inventorySlot) {
if (this.props.onAddAccessoryInventoryItem) {
await this.props.onAddAccessoryInventoryItem(inventorySlot);
} else {
alert("Fucked");
}
}
renderInventorySlot(inventorySlot) {
let cardColor = "grey";
if (inventorySlot.status === "InventoryItemAdded") {
cardColor = "green";
} else if (inventorySlot.status === "NothingInStock") {
cardColor = "red";
}
// HACK HACK HACK
//
// Assume scannable items are
let isScannableItem = !(this.props.schemas.AccessoryBigProductTypes.includes(inventorySlot.productType) || inventorySlot.productType === "AudioStrapV1" || inventorySlot.productType === "Other");
let trackingType = "Unknown";
if (inventorySlot.item && inventorySlot.item.trackingType) {;
trackingType = inventorySlot.item.trackingType;
} else if (inventorySlot.pickingHint && inventorySlot.pickingHint.inventoryItem) {
trackingType = inventorySlot.pickingHint.inventoryItem.trackingType || "Unknown";
}
const title = inventorySlot.displayName || ApiUtils.splitUpperCamelCase(inventorySlot.productType) || "Unknown Product Type";
console.log(inventorySlot);
return (
{title}
{inventorySlot.status === "InventoryItemAdded" && (
Added to shipment
)}
{inventorySlot.status !== "NothingInStock" && (
)}
{inventorySlot.status === "NothingInStock" && (
Nothing in stock
)}
{(!isScannableItem && inventorySlot.status !== "InventoryItemAdded") &&
(
<>
{(trackingType === "Untracked") &&
Inventory not tracked
Stock availability unknown.
}
>
)
}
{isScannableItem && (
Serial Number
{inventorySlot.expectedSerialNumber || inventorySlot.expectedSerialNumberPattern}
Item Status
{inventorySlot.status === "NothingInStock" ? : }
)}
);
}
render() {
return (
{this.props.bigShipment.inventorySlots.map(inventorySlot => this.renderInventorySlot(inventorySlot))}
);
}
}