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 { Table, Statistic, Label } from 'semantic-ui-react'
export default class BigShipmentsTable extends React.Component {
render() {
return (
ID
Big Order
Item Status
Tracking Number
Created at
Courier
{this.props.shipments.map((shipment, index) => {
let createdAtDateTime = fromUnixTime(shipment.createdAt / 1000);
const createdAt = formatInTimeZone(createdAtDateTime, DEFAULT_TIMEZONE, 'PPPp z');
const fromNow = formatDistanceToNow(createdAtDateTime, { addSuffix: true });
const courier = shipment.currentShippingLabel?.rate?.provider ? shipment.currentShippingLabel.rate.provider : "N/A";
const trackingNumber = shipment.currentShippingLabel?.tracking_number || shipment.currentShippingLabel?.trackingNumber;
const trackingUrlProvider = shipment.currentShippingLabel?.tracking_url_provider || shipment.currentShippingLabel?.trackingUrlProvider;
const uploadLabelUrl = shipment.currentShippingLabel?.upload_label_url || shipment.currentShippingLabel?.uploadLabelUrl;
return
{shipment.id}
{shipment.bigOrderId}
{shipment.currentShippingLabel && {trackingNumber}}
{createdAt} ({fromNow})
{courier}
})}
);
}
}