@bjsdistribution/dms-client-return 0.0.43 → 0.0.45

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.
@@ -8930,7 +8930,7 @@ function SelectionFilter() {
8930
8930
  }
8931
8931
  }, [accountNumber, urlCustomerId]);
8932
8932
  useEffect(function () {
8933
- if (urlCustomerId && (clientOptions == null ? void 0 : clientOptions.length) > 0) {
8933
+ if (urlCustomerId) {
8934
8934
  var filteredClient = clientOptions == null ? void 0 : clientOptions.find(function (client) {
8935
8935
  return (client == null ? void 0 : client.value) == urlCustomerId;
8936
8936
  });
@@ -8985,8 +8985,8 @@ function SelectionFilter() {
8985
8985
  }) : []);
8986
8986
  setLocationOptions(Array.isArray(clientLocations) ? clientLocations == null ? void 0 : clientLocations.map(function (location) {
8987
8987
  return {
8988
- label: location,
8989
- value: location
8988
+ label: location == null ? void 0 : location.location_name,
8989
+ value: location == null ? void 0 : location.token
8990
8990
  };
8991
8991
  }) : []);
8992
8992
  //client value
@@ -9127,7 +9127,7 @@ function SelectionFilter() {
9127
9127
  placeholder: "Select Location",
9128
9128
  onChange: handleLocationChange,
9129
9129
  style: {
9130
- minWidth: '14vw'
9130
+ minWidth: '150px'
9131
9131
  },
9132
9132
  allowClear: true,
9133
9133
  mode: "multiple"
@@ -10378,6 +10378,46 @@ var OrderTable = function OrderTable(_ref) {
10378
10378
  setAssign = _useState[1];
10379
10379
  var _useCallApiAgain = useCallApiAgain(),
10380
10380
  setCallAPi = _useCallApiAgain[1];
10381
+ //sorting
10382
+ var _useState2 = useState(null),
10383
+ sortConfig = _useState2[0],
10384
+ setSortConfig = _useState2[1];
10385
+ var handleSort = function handleSort(key) {
10386
+ setSortConfig(function (prev) {
10387
+ if ((prev == null ? void 0 : prev.key) === key && prev.direction === 'asc') {
10388
+ return {
10389
+ key: key,
10390
+ direction: 'desc'
10391
+ };
10392
+ }
10393
+ return {
10394
+ key: key,
10395
+ direction: 'asc'
10396
+ };
10397
+ });
10398
+ };
10399
+ var sortedData = useMemo(function () {
10400
+ if (!returnAfterOrder || !sortConfig) return returnAfterOrder;
10401
+ var key = sortConfig.key,
10402
+ direction = sortConfig.direction;
10403
+ return [].concat(returnAfterOrder).sort(function (a, b) {
10404
+ var valueA = a[key];
10405
+ var valueB = b[key];
10406
+ if (typeof valueA === 'number' && typeof valueB === 'number') {
10407
+ return direction === 'asc' ? valueA - valueB : valueB - valueA;
10408
+ }
10409
+ if (typeof valueA === 'string' && typeof valueB === 'string') {
10410
+ return direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
10411
+ }
10412
+ return 0;
10413
+ });
10414
+ }, [returnAfterOrder, sortConfig]);
10415
+ var renderSortIcon = function renderSortIcon(columnKey) {
10416
+ if (!sortConfig || sortConfig.key !== columnKey) {
10417
+ return React.createElement(SortIcon, null);
10418
+ }
10419
+ return sortConfig.direction === 'asc' ? React.createElement(CaretDownFilledIcon, null) : React.createElement(CaretDownFilledIcon, null);
10420
+ };
10381
10421
  var OpenDropDown = function OpenDropDown(index) {
10382
10422
  setPrintToggle(function (prevIndex) {
10383
10423
  return prevIndex === index ? null : index;
@@ -10513,7 +10553,37 @@ var OrderTable = function OrderTable(_ref) {
10513
10553
  }, [actionResponse, apiError]);
10514
10554
  return React.createElement(React.Fragment, null, AssignLoading && React.createElement(Loader, null), React.createElement(StyledTableWrapper, {
10515
10555
  className: "fortables"
10516
- }, React.createElement(StyledTable$1, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", null, "Created"), React.createElement("th", null, "Return Location"), React.createElement("th", null, "Pick Up Location"), React.createElement("th", null, "Recipient"), React.createElement("th", null, " Client"), React.createElement("th", null, "Consignment"), React.createElement("th", null, "Return Order No"), React.createElement("th", null, " Total Parts"), React.createElement("th", null, "Total Weight"), React.createElement("th", null, "Total CBM"), React.createElement("th", null, "Assign"), React.createElement("th", null, "Status"), React.createElement("th", {
10556
+ }, React.createElement(StyledTable$1, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", {
10557
+ onClick: function onClick() {
10558
+ return handleSort('created_at');
10559
+ }
10560
+ }, React.createElement("div", {
10561
+ className: "sortIconClass"
10562
+ }, "Created ", renderSortIcon('created_at'))), React.createElement("th", {
10563
+ onClick: function onClick() {
10564
+ return handleSort('return_locations.location_name');
10565
+ }
10566
+ }, React.createElement("div", {
10567
+ className: "sortIconClass"
10568
+ }, "Return Location", ' ', renderSortIcon('return_locations.location_name'))), React.createElement("th", null, "Pick Up Location"), React.createElement("th", {
10569
+ onClick: function onClick() {
10570
+ return handleSort('order_recipient.recipient_name');
10571
+ }
10572
+ }, React.createElement("div", {
10573
+ className: "sortIconClass"
10574
+ }, "Recipient ", renderSortIcon('order_recipient.recipient_name'))), React.createElement("th", null, " Client"), React.createElement("th", null, "Consignment"), React.createElement("th", null, "Return Order No"), React.createElement("th", null, " Total Parts"), React.createElement("th", {
10575
+ onClick: function onClick() {
10576
+ return handleSort('weight');
10577
+ }
10578
+ }, React.createElement("div", {
10579
+ className: "sortIconClass"
10580
+ }, "Total Weight ", renderSortIcon('weight'))), React.createElement("th", {
10581
+ onClick: function onClick() {
10582
+ return handleSort('cube');
10583
+ }
10584
+ }, React.createElement("div", {
10585
+ className: "sortIconClass"
10586
+ }, "Total CBM ", renderSortIcon('cube'))), React.createElement("th", null, "Assign"), React.createElement("th", null, "Status"), React.createElement("th", {
10517
10587
  className: "emailInvoiceShare"
10518
10588
  }, "Labels"))), React.createElement("tbody", null, loadingskeleton ? React.createElement("tr", null, React.createElement("td", {
10519
10589
  colSpan: 16
@@ -10521,9 +10591,9 @@ var OrderTable = function OrderTable(_ref) {
10521
10591
  active: true
10522
10592
  })), React.createElement("td", {
10523
10593
  colSpan: 16
10524
- })) : (returnAfterOrder == null ? void 0 : returnAfterOrder.length) === 0 ? React.createElement("tr", null, React.createElement("td", {
10594
+ })) : (sortedData == null ? void 0 : sortedData.length) === 0 ? React.createElement("tr", null, React.createElement("td", {
10525
10595
  colSpan: 16
10526
- }, React.createElement(EmptyDataContainer$1, null, React.createElement(Empty, null)))) : returnAfterOrder == null ? void 0 : returnAfterOrder.map(function (item, index) {
10596
+ }, React.createElement(EmptyDataContainer$1, null, React.createElement(Empty, null)))) : sortedData == null ? void 0 : sortedData.map(function (item, index) {
10527
10597
  var _item$return_location, _item$order_recipient, _item$order_recipient2, _item$customer_data;
10528
10598
  var statusMapping = {
10529
10599
  cancelled: 'Cancelled',
@@ -11528,9 +11598,9 @@ var ReturnTable$1 = function ReturnTable() {
11528
11598
  fontWeight: (key == null ? void 0 : key.RTS) > 0 ? 600 : 'normal',
11529
11599
  cursor: (key == null ? void 0 : key.RTS) > 0 ? 'pointer' : 'default'
11530
11600
  },
11531
- onClick: function onClick() {
11601
+ onClick: (key == null ? void 0 : key.RTS) > 0 ? function () {
11532
11602
  return handleRedirectRTS(key == null ? void 0 : key.customer_id, 'RTS');
11533
- }
11603
+ } : undefined
11534
11604
  }, React.createElement(ColumStyle, null, React.createElement(GreyBox, {
11535
11605
  style: {
11536
11606
  backgroundColor: (key == null ? void 0 : key.RTS) > 0 ? 'rgba(99, 150, 229, 0.1)' : 'rgba(153, 153, 153, 0.1)'