oa-componentbook 1.0.1-stage.5 → 1.0.1-stage.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -485,6 +485,12 @@ Object.defineProperty(exports, "TrackShipmentWidget", {
485
485
  return _TrackShipmentWidget.default;
486
486
  }
487
487
  });
488
+ Object.defineProperty(exports, "TrackShipmentWidgetList", {
489
+ enumerable: true,
490
+ get: function get() {
491
+ return _TrackShipmentWidgetList.default;
492
+ }
493
+ });
488
494
  Object.defineProperty(exports, "Typographies", {
489
495
  enumerable: true,
490
496
  get: function get() {
@@ -603,6 +609,7 @@ var _SparePartsWidget = _interopRequireDefault(require("./widgets/oa-widget-spar
603
609
  var _SparePartsCollapseWidget = _interopRequireDefault(require("./widgets/oa-widget-spare-part/SparePartsCollapseWidget"));
604
610
  var _StageTimelineWidget = _interopRequireWildcard(require("./widgets/oa-widget-stage-timeline/StageTimelineWidget"));
605
611
  var _TrackShipmentWidget = _interopRequireDefault(require("./widgets/oa-widget-track-shipment/TrackShipmentWidget"));
612
+ var _TrackShipmentWidgetList = _interopRequireDefault(require("./widgets/oa-widget-track-shipment-list/TrackShipmentWidgetList"));
606
613
  var _UploadDownloadWidget = _interopRequireDefault(require("./widgets/oa-widget-upload-download/UploadDownloadWidget"));
607
614
  var _ViewHistoryWidget = _interopRequireDefault(require("./widgets/oa-widget-view-history/ViewHistoryWidget"));
608
615
  var _ViewPreviousDescriptionWidget = _interopRequireDefault(require("./widgets/oa-widget-view-previous-description/ViewPreviousDescriptionWidget"));
@@ -8,10 +8,10 @@ exports.default = void 0;
8
8
  require("core-js/modules/web.dom-collections.iterator.js");
9
9
  require("core-js/modules/es.promise.js");
10
10
  var _react = _interopRequireWildcard(require("react"));
11
- var _antd = require("antd");
12
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
12
  var _fn = require("./fn");
14
13
  var _TrackShipmentWidget = _interopRequireDefault(require("../oa-widget-track-shipment/TrackShipmentWidget"));
14
+ var _Accordion = _interopRequireDefault(require("../../components/oa-component-accordion/Accordion"));
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -23,65 +23,24 @@ function TrackShipmentWidgetList(_ref) {
23
23
  const [historyData, setHistoryData] = (0, _react.useState)({});
24
24
  const [loading, setLoading] = (0, _react.useState)({});
25
25
  const fetchStatusXData = async reassignmentId => {};
26
- const getSingleShipmentHistory = item => {
27
- var _item$stages;
28
- return {
29
- awbNumber: item === null || item === void 0 ? void 0 : item.awb,
30
- partnerName: item === null || item === void 0 ? void 0 : item.partnerName,
31
- fromAddress: {
32
- heading: 'From Address:',
33
- addressLine1: item === null || item === void 0 ? void 0 : item.origAddressFullName,
34
- addressLine2: item === null || item === void 0 ? void 0 : item.originAddressLine1,
35
- pincode: item === null || item === void 0 ? void 0 : item.originPincode,
36
- city: item === null || item === void 0 ? void 0 : item.originDistrict
37
- },
38
- toAddress: {
39
- heading: 'To Address:',
40
- addressLine1: item === null || item === void 0 ? void 0 : item.destAddressFullName,
41
- addressLine2: item === null || item === void 0 ? void 0 : item.destAddressLine1,
42
- pincode: item === null || item === void 0 ? void 0 : item.destPincode,
43
- city: item === null || item === void 0 ? void 0 : item.destDistrict
44
- },
45
- tableData: (_item$stages = item === null || item === void 0 ? void 0 : item.stages) !== null && _item$stages !== void 0 ? _item$stages : []
46
- };
47
- };
48
26
  if (!shipmentData || shipmentData.length === 0) {
49
27
  return /*#__PURE__*/_react.default.createElement("p", null, "No shipment data available.");
50
28
  }
51
29
  if (shipmentData.length === 1) {
52
- return /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, getSingleShipmentHistory(shipmentData[0]));
30
+ return /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, (0, _fn.getSingleShipmentHistory)(shipmentData[0]));
53
31
  }
54
32
  return shipmentData === null || shipmentData === void 0 || (_shipmentData$map = shipmentData.map) === null || _shipmentData$map === void 0 ? void 0 : _shipmentData$map.call(shipmentData, (item, index) => {
55
- if ((item === null || item === void 0 ? void 0 : item.status) === 'X') {
56
- var _historyData$reassign;
57
- const reassignmentId = item === null || item === void 0 ? void 0 : item.reassignmentId;
58
- return /*#__PURE__*/_react.default.createElement(_antd.Collapse, {
59
- key: reassignmentId,
60
- onChange: keys => {
61
- console.log('keys:', keys);
62
- if (keys.length > 0) {
63
- fetchStatusXData(reassignmentId);
64
- }
65
- },
66
- items: [{
67
- key: reassignmentId,
68
- label: "".concat((0, _fn.getCurrentShipmentLabel)(index + 1), " | ").concat((0, _fn.getDateString)(item === null || item === void 0 ? void 0 : item.reassignmentTime, item === null || item === void 0 ? void 0 : item.modifiedTime)),
69
- children: loading[reassignmentId] ? /*#__PURE__*/_react.default.createElement(_antd.Spin, null) : /*#__PURE__*/_react.default.createElement("p", null, ((_historyData$reassign = historyData[reassignmentId]) === null || _historyData$reassign === void 0 ? void 0 : _historyData$reassign.details) || 'No details available')
70
- }]
71
- });
72
- }
73
- if ((item === null || item === void 0 ? void 0 : item.status) === 'A') {
74
- console.log('item:', item);
75
- return /*#__PURE__*/_react.default.createElement(_antd.Collapse, {
76
- key: item === null || item === void 0 ? void 0 : item.reassignmentId,
77
- items: [{
78
- key: item === null || item === void 0 ? void 0 : item.reassignmentId,
79
- label: "".concat((0, _fn.getCurrentShipmentLabel)(index + 1), " | ").concat((0, _fn.getDateString)(item === null || item === void 0 ? void 0 : item.reassignmentTime, item === null || item === void 0 ? void 0 : item.modifiedTime), "-Present"),
80
- children: /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, getSingleShipmentHistory(item))
81
- }]
82
- });
83
- }
84
- return null;
33
+ const {
34
+ reassignmentId,
35
+ reassignmentTime,
36
+ modifiedTime,
37
+ status
38
+ } = item !== null && item !== void 0 ? item : {};
39
+ return /*#__PURE__*/_react.default.createElement(_Accordion.default, {
40
+ key: reassignmentId,
41
+ body: /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, (0, _fn.getSingleShipmentHistory)(item)),
42
+ headerText: (0, _fn.headerText)(index, reassignmentTime, modifiedTime, status)
43
+ });
85
44
  });
86
45
  }
87
46
  TrackShipmentWidgetList.propTypes = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getDateString = exports.getCurrentShipmentLabel = void 0;
6
+ exports.isActive = exports.headerText = exports.getSingleShipmentHistory = exports.getDateString = exports.getCurrentShipmentLabel = void 0;
7
7
  function numberToOrdinal(number) {
8
8
  const suffixes = ['th', 'st', 'nd', 'rd'];
9
9
  const value = number % 100;
@@ -36,6 +36,34 @@ const getDateString = (startTime, endTime) => {
36
36
  exports.getDateString = getDateString;
37
37
  const getCurrentShipmentLabel = number => {
38
38
  const ordinalNumber = numberToOrdinal(number);
39
- return "Shipment ".concat(ordinalNumber);
39
+ return "".concat(ordinalNumber, " Shipment");
40
40
  };
41
- exports.getCurrentShipmentLabel = getCurrentShipmentLabel;
41
+ exports.getCurrentShipmentLabel = getCurrentShipmentLabel;
42
+ const isActive = status => status === 'A';
43
+ exports.isActive = isActive;
44
+ const headerText = (index, reassignmentTime, modifiedTime, status) => "".concat(getCurrentShipmentLabel(index + 1), " | ").concat(getDateString(reassignmentTime, modifiedTime)).concat(isActive(status) ? ' - Present' : '');
45
+ exports.headerText = headerText;
46
+ const getSingleShipmentHistory = item => {
47
+ var _item$stages;
48
+ return {
49
+ partnerName: item === null || item === void 0 ? void 0 : item.partnerName,
50
+ errorReason: item === null || item === void 0 ? void 0 : item.errorReason,
51
+ awbNumber: item === null || item === void 0 ? void 0 : item.awb,
52
+ fromAddress: {
53
+ heading: 'From Address:',
54
+ addressLine1: item === null || item === void 0 ? void 0 : item.origAddressFullName,
55
+ addressLine2: item === null || item === void 0 ? void 0 : item.originAddressLine1,
56
+ pincode: item === null || item === void 0 ? void 0 : item.originPincode,
57
+ city: item === null || item === void 0 ? void 0 : item.originDistrict
58
+ },
59
+ toAddress: {
60
+ heading: 'To Address:',
61
+ addressLine1: item === null || item === void 0 ? void 0 : item.destAddressFullName,
62
+ addressLine2: item === null || item === void 0 ? void 0 : item.destAddressLine1,
63
+ pincode: item === null || item === void 0 ? void 0 : item.destPincode,
64
+ city: item === null || item === void 0 ? void 0 : item.destDistrict
65
+ },
66
+ tableData: (_item$stages = item === null || item === void 0 ? void 0 : item.stages) !== null && _item$stages !== void 0 ? _item$stages : []
67
+ };
68
+ };
69
+ exports.getSingleShipmentHistory = getSingleShipmentHistory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-componentbook",
3
- "version": "1.0.1-stage.5",
3
+ "version": "1.0.1-stage.7",
4
4
  "private": false,
5
5
  "description": "Reusable components",
6
6
  "main": "build/index.js",