@bjsdistribution/dms-client-return 0.0.33 → 0.0.35

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.
Files changed (34) hide show
  1. package/dist/components/order-daily-overview/store/store.d.ts +3 -0
  2. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  3. package/dist/components/store.d.ts +12 -2
  4. package/dist/components/types.d.ts +4 -0
  5. package/dist/dms-client-return.cjs.development.js +594 -337
  6. package/dist/dms-client-return.cjs.development.js.map +1 -1
  7. package/dist/dms-client-return.cjs.production.min.js +1 -1
  8. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  9. package/dist/dms-client-return.esm.js +598 -341
  10. package/dist/dms-client-return.esm.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +119 -140
  13. package/src/components/order-daily-overview/header-filters/filterStore.ts +4 -4
  14. package/src/components/order-daily-overview/index.tsx +18 -14
  15. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +14 -10
  16. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +88 -32
  17. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +18 -2
  18. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +18 -7
  19. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +2 -3
  20. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +6 -4
  21. package/src/components/order-daily-overview/store/store.ts +15 -0
  22. package/src/components/order-daily-overview/table/ReturnTable.tsx +16 -11
  23. package/src/components/order-daily-overview/table/table-data/styles.ts +1 -1
  24. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +3 -3
  25. package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn.tsx +1 -1
  26. package/src/components/order-view/general-information/dropdowns/Print.tsx +1 -1
  27. package/src/components/order-view/modalsPopup/ModalManager.tsx +3 -9
  28. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +88 -13
  29. package/src/components/order-view/products-info/expanded-content/index.tsx +91 -16
  30. package/src/components/order-view/products-info/index.tsx +1 -1
  31. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +47 -42
  32. package/src/components/store.ts +51 -1
  33. package/src/components/types.ts +5 -0
  34. package/src/index.tsx +25 -16
@@ -1,10 +1,10 @@
1
- import React, { useEffect, useState, useMemo, useCallback, useRef, Suspense } from 'react';
2
- import { useLocation, useParams, useNavigate, NavLink, Routes, Route } from 'react-router-dom';
1
+ import React, { useEffect, useState, useMemo, useRef, Suspense } from 'react';
2
+ import { useLocation, useNavigate, NavLink, Routes, Route } from 'react-router-dom';
3
3
  import styled, { keyframes, css } from 'styled-components';
4
- import { Label as Label$h, Input as Input$1, TextArea, FormSection, displayValueOrNA as displayValueOrNA$1, SelectDropdown, dropdownStyles, RadioButtonGroup as RadioButtonGroup$1, Switch, getBaseEndpoint, Button, useApiHook, formatDateTime, Checkbox as Checkbox$1, AntSelect, SectionHeader, CrossIcon, Alert, CustomRating, AntTable, CancelationModal, CancelAndCompleteAction, filterDropdownStyles, BackgroundModal as BackgroundModal$1, AntModal } from '@bjsdistribution/dms-component-library';
4
+ import { Label as Label$h, Input as Input$1, TextArea, FormSection, displayValueOrNA as displayValueOrNA$1, SelectDropdown, dropdownStyles, RadioButtonGroup as RadioButtonGroup$1, Switch, getBaseEndpoint, Button, useApiHook, formatDateTime, Checkbox as Checkbox$1, SectionHeader, CrossIcon, AntSelect, Alert, CustomRating, AntTable, CancelationModal, CancelAndCompleteAction, filterDropdownStyles, BackgroundModal as BackgroundModal$1, AntModal } from '@bjsdistribution/dms-component-library';
5
5
  import { useAtom, atom } from 'jotai';
6
6
  import { atomWithReducer } from 'jotai/utils';
7
- import { DatePicker, notification, Skeleton, Upload, message, Empty, Input as Input$2, Select } from 'antd';
7
+ import { DatePicker, notification, Skeleton, Select, Upload, message, Empty, Input as Input$2 } from 'antd';
8
8
  import dayjs from 'dayjs';
9
9
  import { useReactTable, getCoreRowModel, getSortedRowModel, flexRender } from '@tanstack/react-table';
10
10
  import Scrollbars from 'react-custom-scrollbars-2';
@@ -679,10 +679,6 @@ var deleteProdId = /*#__PURE__*/atom([]);
679
679
  function useDeleteProdsID() {
680
680
  return useAtom(deleteProdId);
681
681
  }
682
- var createOrderProduct = /*#__PURE__*/atom([]);
683
- function useCreateOrderProducts() {
684
- return useAtom(createOrderProduct);
685
- }
686
682
  var errorAtom = /*#__PURE__*/atom({
687
683
  homeContactError: '',
688
684
  workCOntanctError: '',
@@ -3473,6 +3469,21 @@ var ActionIcon = function ActionIcon() {
3473
3469
  }));
3474
3470
  };
3475
3471
 
3472
+ var _templateObject$U, _templateObject2$G, _templateObject3$m, _templateObject4$a, _templateObject5$5, _templateObject6$3, _templateObject7$3;
3473
+ function Loader(props) {
3474
+ return React.createElement(MainContainer$6, {
3475
+ id: "loder"
3476
+ }, React.createElement(Container$B, null, React.createElement(Spinner, null), React.createElement(Wrapper$b, null, React.createElement(Title, null, props.title || 'Loading...'), React.createElement(Subtitle, null, props.subtitle || "Sit tight - won't be long!"))));
3477
+ }
3478
+ var rotate = /*#__PURE__*/keyframes(_templateObject$U || (_templateObject$U = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"])));
3479
+ // Styled components for the loading spinner
3480
+ var Spinner = /*#__PURE__*/styled.div(_templateObject2$G || (_templateObject2$G = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 4px solid rgb(0 0 0 / 50%);\n border-left-color: #feba30;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: ", " 1s linear infinite;\n"])), rotate);
3481
+ var Container$B = /*#__PURE__*/styled.div(_templateObject3$m || (_templateObject3$m = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n gap: 25px;\n align-items: center;\n flex-direction: column;\n text-align: center;\n"])));
3482
+ var Subtitle = /*#__PURE__*/styled.span(_templateObject4$a || (_templateObject4$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: white;\n font-size: 25px;\n text-transform: capitalize;\n font-weight: bold;\n"])));
3483
+ var Title = /*#__PURE__*/styled.span(_templateObject5$5 || (_templateObject5$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: white;\n font-size: 25px;\n text-transform: capitalize;\n font-weight: bold;\n"])));
3484
+ var Wrapper$b = /*#__PURE__*/styled.div(_templateObject6$3 || (_templateObject6$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 20px;\n"])));
3485
+ var MainContainer$6 = /*#__PURE__*/styled.div(_templateObject7$3 || (_templateObject7$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n background-color: rgba(0, 0, 0, 0.3);\n backdrop-filter: blur(5px);\n display: flex;\n justify-content: center;\n align-items: center;\n"])));
3486
+
3476
3487
  var CreateReturnInitial = {
3477
3488
  customer_id: 0,
3478
3489
  account_number: '',
@@ -3480,6 +3491,10 @@ var CreateReturnInitial = {
3480
3491
  products: [],
3481
3492
  return_action: []
3482
3493
  };
3494
+ var AssignUpdateInitial = {
3495
+ return_order_id: 0,
3496
+ bjs_delivery: false
3497
+ };
3483
3498
  var customerData = /*#__PURE__*/atom([]);
3484
3499
  var actionTypeData = /*#__PURE__*/atom([]);
3485
3500
  var locationData = /*#__PURE__*/atom([]);
@@ -3492,6 +3507,11 @@ var selectAll = /*#__PURE__*/atom(false);
3492
3507
  var postLoading = /*#__PURE__*/atom(false);
3493
3508
  var _final = /*#__PURE__*/atom([]);
3494
3509
  var clearState = /*#__PURE__*/atom(false);
3510
+ var assignData = /*#__PURE__*/atom([]);
3511
+ var assignPayload = /*#__PURE__*/atom(AssignUpdateInitial);
3512
+ var callAPIAgain = /*#__PURE__*/atom(true);
3513
+ var actionTypeOptions = /*#__PURE__*/atom([]);
3514
+ var selectedProductsMove = /*#__PURE__*/atom([]);
3495
3515
  var selectedOrderlList = /*#__PURE__*/atom([]);
3496
3516
  function useSelectedOrders() {
3497
3517
  return useAtom(selectedOrderlList);
@@ -3537,26 +3557,27 @@ function useFinalPayload() {
3537
3557
  function useClearState() {
3538
3558
  return useAtom(clearState);
3539
3559
  }
3540
-
3541
- var _templateObject$U, _templateObject2$G, _templateObject3$m, _templateObject4$a, _templateObject5$5, _templateObject6$3, _templateObject7$3;
3542
- function Loader(props) {
3543
- return React.createElement(MainContainer$6, {
3544
- id: "loder"
3545
- }, React.createElement(Container$B, null, React.createElement(Spinner, null), React.createElement(Wrapper$b, null, React.createElement(Title, null, props.title || 'Loading...'), React.createElement(Subtitle, null, props.subtitle || "Sit tight - won't be long!"))));
3560
+ function useAssignData() {
3561
+ return useAtom(assignData);
3562
+ }
3563
+ function useAssignPayload() {
3564
+ return useAtom(assignPayload);
3565
+ }
3566
+ function useCallApiAgain() {
3567
+ return useAtom(callAPIAgain);
3568
+ }
3569
+ function useActionTypeOptions() {
3570
+ return useAtom(actionTypeOptions);
3571
+ }
3572
+ function useSelectedProducts() {
3573
+ return useAtom(selectedProductsMove);
3546
3574
  }
3547
- var rotate = /*#__PURE__*/keyframes(_templateObject$U || (_templateObject$U = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"])));
3548
- // Styled components for the loading spinner
3549
- var Spinner = /*#__PURE__*/styled.div(_templateObject2$G || (_templateObject2$G = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 4px solid rgb(0 0 0 / 50%);\n border-left-color: #feba30;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: ", " 1s linear infinite;\n"])), rotate);
3550
- var Container$B = /*#__PURE__*/styled.div(_templateObject3$m || (_templateObject3$m = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n gap: 25px;\n align-items: center;\n flex-direction: column;\n text-align: center;\n"])));
3551
- var Subtitle = /*#__PURE__*/styled.span(_templateObject4$a || (_templateObject4$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: white;\n font-size: 25px;\n text-transform: capitalize;\n font-weight: bold;\n"])));
3552
- var Title = /*#__PURE__*/styled.span(_templateObject5$5 || (_templateObject5$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: white;\n font-size: 25px;\n text-transform: capitalize;\n font-weight: bold;\n"])));
3553
- var Wrapper$b = /*#__PURE__*/styled.div(_templateObject6$3 || (_templateObject6$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 20px;\n"])));
3554
- var MainContainer$6 = /*#__PURE__*/styled.div(_templateObject7$3 || (_templateObject7$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n background-color: rgba(0, 0, 0, 0.3);\n backdrop-filter: blur(5px);\n display: flex;\n justify-content: center;\n align-items: center;\n"])));
3555
3575
 
3556
3576
  var ReturnProductTable = function ReturnProductTable() {
3557
3577
  var _orderStaticData$retu;
3558
- var _useSelectedOrders = useSelectedOrders(),
3559
- selectedInvoices = _useSelectedOrders[0];
3578
+ var _useSelectedProducts = useSelectedProducts(),
3579
+ selectedProducts = _useSelectedProducts[0],
3580
+ setSelectedProducts = _useSelectedProducts[1];
3560
3581
  var _useState = useState(false),
3561
3582
  selectAll = _useState[0],
3562
3583
  setSelectAll = _useState[1];
@@ -3568,9 +3589,9 @@ var ReturnProductTable = function ReturnProductTable() {
3568
3589
  setSelectedRowId = _useState2[1];
3569
3590
  var _useOrderId = useOrderId(),
3570
3591
  orderId = _useOrderId[0];
3571
- var handleActionClick = useCallback(function (id) {
3592
+ var handleActionClick = function handleActionClick(id) {
3572
3593
  setSelectedRowId(id);
3573
- }, []);
3594
+ };
3574
3595
  var _useApiHook = useApiHook({
3575
3596
  endpoint: "order/order_products/delete/",
3576
3597
  method: 'DELETE',
@@ -3581,21 +3602,19 @@ var ReturnProductTable = function ReturnProductTable() {
3581
3602
  performAction: false
3582
3603
  }),
3583
3604
  isresponse = _useApiHook.data,
3584
- setaction = _useApiHook.setShouldPerformAction,
3605
+ setAction = _useApiHook.setShouldPerformAction,
3585
3606
  loading = _useApiHook.loading;
3586
3607
  useEffect(function () {
3587
3608
  if (isresponse && isresponse.data) {
3588
3609
  notification.success({
3589
3610
  message: 'Success',
3590
- description:
3591
- //@ts-ignore
3592
- (isresponse == null ? void 0 : isresponse.message) || 'An error has occurred. Please try again later.'
3611
+ description: 'An error has occurred. Please try again later.'
3593
3612
  });
3594
3613
  handleRemoveRow();
3595
3614
  setSelectedRowId(null);
3596
3615
  }
3597
3616
  }, [isresponse]);
3598
- var handleRemoveRow = useCallback(function () {
3617
+ var handleRemoveRow = function handleRemoveRow() {
3599
3618
  if (selectedRowId !== null) {
3600
3619
  setProductData(function (prevData) {
3601
3620
  return prevData.filter(function (item) {
@@ -3603,16 +3622,28 @@ var ReturnProductTable = function ReturnProductTable() {
3603
3622
  });
3604
3623
  });
3605
3624
  }
3606
- }, [selectedRowId, setProductData]);
3607
- var onDeleteProducts = useCallback(function () {
3608
- setaction(true);
3609
- }, [setaction, selectedRowId]);
3610
- var handleSelectAll = useCallback(function () {
3611
- setSelectAll(function (prevSelectAll) {
3612
- return !prevSelectAll;
3625
+ };
3626
+ var onDeleteProducts = function onDeleteProducts() {
3627
+ setAction(true);
3628
+ };
3629
+ var handleSelectAll = function handleSelectAll() {
3630
+ if (selectAll) {
3631
+ setSelectedProducts([]);
3632
+ } else {
3633
+ var allProductIds = productData.map(function (product) {
3634
+ return product.id;
3635
+ });
3636
+ setSelectedProducts(allProductIds);
3637
+ }
3638
+ setSelectAll(!selectAll);
3639
+ };
3640
+ var handleSelectProduct = function handleSelectProduct(id) {
3641
+ setSelectedProducts(function (prevSelected) {
3642
+ return prevSelected.includes(id) ? prevSelected.filter(function (selectedId) {
3643
+ return selectedId !== id;
3644
+ }) : [].concat(prevSelected, [id]);
3613
3645
  });
3614
- }, []);
3615
- // const returnreason =
3646
+ };
3616
3647
  var _useOrderStaticData = useOrderStaticData(),
3617
3648
  orderStaticData = _useOrderStaticData[0];
3618
3649
  var returnReasonsOptions = orderStaticData == null || (_orderStaticData$retu = orderStaticData.return_reasons) == null ? void 0 : _orderStaticData$retu.map(function (option) {
@@ -3625,34 +3656,30 @@ var ReturnProductTable = function ReturnProductTable() {
3625
3656
  var matchedReason = returnReasonsOptions == null ? void 0 : returnReasonsOptions.find(function (option) {
3626
3657
  return option.value === returnReasonId;
3627
3658
  });
3628
- return matchedReason ? matchedReason.label : 'N/A'; // Return label or 'N/A' if no match found
3659
+ return matchedReason ? matchedReason.label : 'N/A';
3629
3660
  };
3630
3661
  return React.createElement("div", null, loading && React.createElement(Loader, {
3631
3662
  title: "Deleting"
3632
3663
  }), React.createElement(StyledTableWrapper, {
3633
- id: "tableScrolling"
3664
+ id: "tableScrolling",
3665
+ className: "orderProductTable"
3634
3666
  }, React.createElement(StyledTable$1, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", {
3635
- className: "emailInvoiceCheckbox"
3667
+ className: "emailproductsCheckbox"
3636
3668
  }, React.createElement(Checkbox$1, {
3637
3669
  checked: selectAll,
3638
- onChange: handleSelectAll,
3639
- disabled: true,
3640
- style: {
3641
- cursor: 'not-allowed'
3642
- }
3643
- })), React.createElement("th", null, "Location"), React.createElement("th", null, "Sender"), React.createElement("th", null, "Code"), React.createElement("th", null, "Description"), React.createElement("th", null, "Return Reason"), React.createElement("th", null, "Part"), React.createElement("th", null, "Action"))), React.createElement("tbody", null, productData && productData.length > 0 ? productData.map(function (invoice) {
3670
+ onChange: handleSelectAll
3671
+ })), React.createElement("th", null, "Location"), React.createElement("th", null, "Sender"), React.createElement("th", null, "Code"), React.createElement("th", null, "Description"), React.createElement("th", null, "Return Reason"), React.createElement("th", null, "Part"), React.createElement("th", null, "Action"))), React.createElement("tbody", null, productData && (productData == null ? void 0 : productData.length) > 0 ? productData == null ? void 0 : productData.map(function (product) {
3672
+ var _product$orders_produ, _product$order_data, _product$order_data2;
3644
3673
  return React.createElement("tr", {
3645
- key: invoice.id
3674
+ key: product.id
3646
3675
  }, React.createElement("td", null, React.createElement(Checkbox$1, {
3647
- checked: selectedInvoices.some(function (selectedInvoice) {
3648
- return selectedInvoice.id === invoice.id;
3649
- }),
3650
- style: {
3651
- cursor: 'not-allowed'
3676
+ checked: selectedProducts == null ? void 0 : selectedProducts.includes(product == null ? void 0 : product.id),
3677
+ onChange: function onChange() {
3678
+ return handleSelectProduct(product == null ? void 0 : product.id);
3652
3679
  }
3653
- })), React.createElement("td", null, 'N/A'), React.createElement("td", null, 'N/A'), React.createElement("td", null, invoice.code), React.createElement("td", null, invoice.description), React.createElement("td", null, getReturnReasonLabel(invoice == null ? void 0 : invoice.return_reason_id)), ' ', React.createElement("td", null, "1 of 1"), React.createElement("td", null, React.createElement("div", {
3680
+ })), React.createElement("td", null, (product == null || (_product$orders_produ = product.orders_products_stock) == null ? void 0 : _product$orders_produ.location) || 'N/A'), React.createElement("td", null, product == null || (_product$order_data = product.order_data) == null || (_product$order_data = _product$order_data.order_recipient) == null ? void 0 : _product$order_data.recipient_name, ' ', product == null || (_product$order_data2 = product.order_data) == null || (_product$order_data2 = _product$order_data2.order_recipient) == null ? void 0 : _product$order_data2.postcode), React.createElement("td", null, product == null ? void 0 : product.code), React.createElement("td", null, product == null ? void 0 : product.description), React.createElement("td", null, getReturnReasonLabel(product == null ? void 0 : product.return_reason_id)), React.createElement("td", null, "1 of 1"), React.createElement("td", null, React.createElement("div", {
3654
3681
  onClick: function onClick() {
3655
- handleActionClick(invoice.id);
3682
+ handleActionClick(product == null ? void 0 : product.id);
3656
3683
  onDeleteProducts();
3657
3684
  },
3658
3685
  style: {
@@ -3674,47 +3701,189 @@ var ProductTable = function ProductTable() {
3674
3701
  var Container$C = /*#__PURE__*/styled.div(_templateObject$V || (_templateObject$V = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n /* height: 230px; */\n overflow: auto; /* Enable scrolling */\n scrollbar-width: thin;\n"])));
3675
3702
 
3676
3703
  var _templateObject$W, _templateObject2$H;
3704
+ var payloadAtom = /*#__PURE__*/atom(null);
3677
3705
  var NewReturnDropdown = function NewReturnDropdown() {
3678
3706
  var defaultSelectStyle = {
3679
3707
  width: '100%'
3680
3708
  };
3681
3709
  var defaultPopupClassName = 'dropDownStyle';
3682
- var defaultSelectWrapperClass = 'rounded';
3683
- return React.createElement(Container$D, null, React.createElement(Text$3, null, "New Return Order:"), React.createElement(AntSelect, {
3684
- options: [],
3710
+ var _useState = useState([]),
3711
+ returnOrderData = _useState[0],
3712
+ setReturnOrderData = _useState[1];
3713
+ var _useState2 = useState(null),
3714
+ selectedOrderId = _useState2[0],
3715
+ setSelectedOrderId = _useState2[1];
3716
+ var _useSelectedProducts = useSelectedProducts(),
3717
+ selectedProducts = _useSelectedProducts[0];
3718
+ var _useOrderDetails = useOrderDetails(),
3719
+ orderData = _useOrderDetails[0];
3720
+ var _useAtom = useAtom(payloadAtom),
3721
+ setPayload = _useAtom[1];
3722
+ var _useProductDetails = useProductDetails(),
3723
+ productData = _useProductDetails[0];
3724
+ var _useState3 = useState(),
3725
+ idProduct = _useState3[0],
3726
+ setId = _useState3[1];
3727
+ var id = orderData == null ? void 0 : orderData.customer_id;
3728
+ useEffect(function () {
3729
+ var allProductIds = (productData == null ? void 0 : productData.map(function (product) {
3730
+ return product.return_location;
3731
+ })) || [];
3732
+ setId(allProductIds);
3733
+ }, [productData]);
3734
+ var filters = [{
3735
+ field: 'customer_id',
3736
+ op: '=',
3737
+ value: id
3738
+ }, {
3739
+ field: 'is_deleted',
3740
+ op: '=',
3741
+ value: 0
3742
+ }, {
3743
+ field: 'status',
3744
+ op: '!=',
3745
+ value: 'SD'
3746
+ }];
3747
+ if ((idProduct == null ? void 0 : idProduct.length) > 0 && idProduct[0]) {
3748
+ filters.push({
3749
+ field: 'return_order_products.return_location',
3750
+ op: '=',
3751
+ value: idProduct[0]
3752
+ });
3753
+ }
3754
+ var _useApiHook = useApiHook({
3755
+ endpoint: '/return_orders/?skip_filters=0',
3756
+ method: 'GET',
3757
+ filters: filters,
3758
+ //@ts-ignore
3759
+ pagination: {
3760
+ is_pagination: false
3761
+ },
3762
+ performAction: false
3763
+ }),
3764
+ fetchedReturnOrderData = _useApiHook.data,
3765
+ setShouldPerformAction = _useApiHook.setShouldPerformAction;
3766
+ useEffect(function () {
3767
+ if (id && (idProduct == null ? void 0 : idProduct.length) > 0 && idProduct[0]) {
3768
+ setShouldPerformAction(true);
3769
+ }
3770
+ }, [id, idProduct, setShouldPerformAction]);
3771
+ useEffect(function () {
3772
+ if (fetchedReturnOrderData && fetchedReturnOrderData != null && fetchedReturnOrderData.data && id !== null) {
3773
+ setReturnOrderData(fetchedReturnOrderData == null ? void 0 : fetchedReturnOrderData.data);
3774
+ }
3775
+ }, [fetchedReturnOrderData, id]);
3776
+ useEffect(function () {
3777
+ if (selectedOrderId && (selectedProducts == null ? void 0 : selectedProducts.length) > 0) {
3778
+ var newPayload = {
3779
+ new_return_order: selectedOrderId,
3780
+ products: selectedProducts
3781
+ };
3782
+ setPayload(newPayload);
3783
+ }
3784
+ }, [selectedOrderId, selectedProducts, setPayload]);
3785
+ var handleDropdownChange = function handleDropdownChange(value) {
3786
+ setSelectedOrderId(value);
3787
+ };
3788
+ var dropdownOptions = returnOrderData == null ? void 0 : returnOrderData.map(function (order) {
3789
+ return {
3790
+ label: order.order_recipient.recipient_name + " - " + order.order_recipient.postcode,
3791
+ value: order.id
3792
+ };
3793
+ });
3794
+ return React.createElement(Container$D, null, React.createElement(Text$3, null, "New Return Order:"), React.createElement(Select, {
3795
+ options: dropdownOptions,
3685
3796
  placeholder: "Select",
3686
- onChange: function onChange() {},
3687
- defaultValue: 'Current Return Order' ,
3797
+ onChange: handleDropdownChange,
3688
3798
  style: defaultSelectStyle,
3689
3799
  disabled: false,
3690
- // onSearch={handleSearch}
3691
3800
  showSearch: true,
3692
- popupClassName: defaultPopupClassName,
3693
- selectWrapperClass: defaultSelectWrapperClass
3801
+ dropdownStyle: {
3802
+ width: 'max-content'
3803
+ },
3804
+ popupClassName: defaultPopupClassName
3694
3805
  }));
3695
3806
  };
3696
- var Container$D = /*#__PURE__*/styled.div(_templateObject$W || (_templateObject$W = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 10px;\n align-self: stretch;\n"])));
3697
- var Text$3 = /*#__PURE__*/styled.div(_templateObject2$H || (_templateObject2$H = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: #000;\n\n /* body/captions */\n font-family: 'Lato';\n font-size: 13px;\n font-style: normal;\n font-weight: 400;\n line-height: 16px; /* 123.077% */\n"])));
3807
+ var Container$D = /*#__PURE__*/styled.div(_templateObject$W || (_templateObject$W = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 10px;\n align-self: stretch;\n white-space: nowrap;\n"])));
3808
+ var Text$3 = /*#__PURE__*/styled.div(_templateObject2$H || (_templateObject2$H = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: #000;\n font-family: 'Lato';\n font-size: 13px;\n font-weight: 400;\n line-height: 16px;\n"])));
3698
3809
 
3699
3810
  var _templateObject$X, _templateObject2$I, _templateObject3$n;
3700
- // import { notification } from 'antd';
3701
3811
  function ExpandedContent$2() {
3702
- // const SaveNote = () => {
3703
- // // alert('saved');
3704
- // notification.success({
3705
- // message: 'Success',
3706
- // description: ' Saved successfully.',
3707
- // });
3708
- // };
3709
- return React.createElement(Container$E, null, React.createElement(ProductTable, null), React.createElement(MidConatiner, null, React.createElement(SaveNoteContainer$1, null, React.createElement(Button, {
3812
+ var _response$data, _response$data2;
3813
+ var _useAtom = useAtom(payloadAtom),
3814
+ payload = _useAtom[0];
3815
+ var _usePostLoading = usePostLoading(),
3816
+ setPostLoading = _usePostLoading[1];
3817
+ var _useOrderId = useOrderId(),
3818
+ orderId = _useOrderId[0];
3819
+ var _useState = useState(true),
3820
+ isButtonDisabled = _useState[0],
3821
+ setIsButtonDisabled = _useState[1];
3822
+ var navigate = useNavigate();
3823
+ var _useSelectedProducts = useSelectedProducts(),
3824
+ setSelectedProducts = _useSelectedProducts[1];
3825
+ var _useApiHook = useApiHook({
3826
+ endpoint: "return_order_products/move/" + orderId,
3827
+ method: 'POST',
3828
+ body: payload,
3829
+ performAction: false
3830
+ }),
3831
+ response = _useApiHook.data,
3832
+ setShouldPerformAction = _useApiHook.setShouldPerformAction,
3833
+ confirmLoading = _useApiHook.loading;
3834
+ useEffect(function () {
3835
+ setPostLoading(confirmLoading);
3836
+ }, [confirmLoading, setPostLoading]);
3837
+ useEffect(function () {
3838
+ var _payload$products;
3839
+ if (payload != null && payload.new_return_order && (payload == null || (_payload$products = payload.products) == null ? void 0 : _payload$products.length) > 0) {
3840
+ setIsButtonDisabled(false);
3841
+ } else {
3842
+ setIsButtonDisabled(true);
3843
+ }
3844
+ }, [payload]);
3845
+ var handleConfirmReturn = function handleConfirmReturn() {
3846
+ if (!isButtonDisabled) {
3847
+ setShouldPerformAction(true);
3848
+ setPostLoading(confirmLoading);
3849
+ } else {
3850
+ console.error('Payload is incomplete:', payload);
3851
+ }
3852
+ };
3853
+ var newId = Array.isArray(response == null ? void 0 : response.data) ? //@ts-ignore
3854
+ response == null || (_response$data = response.data) == null || (_response$data = _response$data[0]) == null ? void 0 : _response$data.id : //@ts-ignore
3855
+ response == null || (_response$data2 = response.data) == null ? void 0 : _response$data2.id;
3856
+ useEffect(function () {
3857
+ //@ts-ignore
3858
+ if ((response == null ? void 0 : response.code) === 200) {
3859
+ notification.success({
3860
+ message: 'Success',
3861
+ //@ts-ignore
3862
+ description: (response == null ? void 0 : response.message) || 'Products moved successfully'
3863
+ });
3864
+ setSelectedProducts([]);
3865
+ } else if (response) {
3866
+ notification.error({
3867
+ message: 'Error',
3868
+ //@ts-ignore
3869
+ description: (response == null ? void 0 : response.message) || 'Error while moving products'
3870
+ });
3871
+ }
3872
+ //@ts-ignore
3873
+ if ((response == null ? void 0 : response.code) === 200 && newId) {
3874
+ navigate("details/" + newId);
3875
+ setSelectedProducts([]);
3876
+ }
3877
+ }, [response, newId, navigate, setSelectedProducts]);
3878
+ return React.createElement(Container$E, null, React.createElement(ProductTable, null), React.createElement(MidContainer, null, React.createElement(SaveNoteContainer$1, null, React.createElement(Button, {
3710
3879
  style: {
3711
3880
  borderRadius: '20px'
3712
3881
  },
3713
- onClick: function onClick() {},
3714
- disabled: true
3882
+ onClick: handleConfirmReturn,
3883
+ disabled: isButtonDisabled
3715
3884
  }, "Move Products"), React.createElement(NewReturnDropdown, null))));
3716
3885
  }
3717
- var MidConatiner = /*#__PURE__*/styled.div(_templateObject$X || (_templateObject$X = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n padding: 10px 15px;\n align-items: flex-start;\n border-top: 1px solid #edebe8;\n background: #f8fafc;\n margin: 0px -15px -15px -15px;\n border-radius: 0px 0px 8px 8px;\n margin-bottom: 22px;\n"])));
3886
+ var MidContainer = /*#__PURE__*/styled.div(_templateObject$X || (_templateObject$X = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n padding: 10px 15px;\n align-items: flex-start;\n border-top: 1px solid #edebe8;\n background: #f8fafc;\n margin: 0px -15px -15px -15px;\n border-radius: 0px 0px 8px 8px;\n margin-bottom: 22px;\n"])));
3718
3887
  var SaveNoteContainer$1 = /*#__PURE__*/styled.div(_templateObject2$I || (_templateObject2$I = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n gap: 10px;\n"])));
3719
3888
  var Container$E = /*#__PURE__*/styled.div(_templateObject3$n || (_templateObject3$n = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
3720
3889
 
@@ -3753,6 +3922,10 @@ var selectedClient = /*#__PURE__*/atom(null);
3753
3922
  function useSelectedClient() {
3754
3923
  return useAtom(selectedClient);
3755
3924
  }
3925
+ var clientTableId = /*#__PURE__*/atom(null);
3926
+ function useIdForTableName() {
3927
+ return useAtom(clientTableId);
3928
+ }
3756
3929
  var clientTableName = /*#__PURE__*/atom(null);
3757
3930
  function useTableName() {
3758
3931
  return useAtom(clientTableName);
@@ -3808,7 +3981,7 @@ function ProductsInfo() {
3808
3981
  var _useLoading = useLoading(),
3809
3982
  setLoading = _useLoading[1];
3810
3983
  var _useApiHook = useApiHook({
3811
- endpoint: "/order/order_products/" + customerData.id,
3984
+ endpoint: "return_order_products/" + customerData.id,
3812
3985
  method: 'GET',
3813
3986
  performAction: false
3814
3987
  }),
@@ -8069,11 +8242,10 @@ var OptionsDropDown = function OptionsDropDown() {
8069
8242
  setIsOpen = _useState[1];
8070
8243
  var dropdownRef = useRef(null);
8071
8244
  var _useCurrentAction = useCurrentAction(),
8072
- action = _useCurrentAction[0],
8073
8245
  setCurrentAction = _useCurrentAction[1];
8074
8246
  var _useIsOnHoldOrder = useIsOnHoldOrder(),
8075
8247
  hold = _useIsOnHoldOrder[0];
8076
- console.log(action, 'action');
8248
+ // console.log(action, 'action');
8077
8249
  var handleClick = function handleClick() {
8078
8250
  setIsOpen(function (prev) {
8079
8251
  return !prev;
@@ -8087,7 +8259,6 @@ var OptionsDropDown = function OptionsDropDown() {
8087
8259
  }
8088
8260
  });
8089
8261
  var handleSelect = function handleSelect(selectedOption) {
8090
- console.log(selectedOption);
8091
8262
  setCurrentAction(selectedOption);
8092
8263
  setIsOpen(false);
8093
8264
  };
@@ -8164,7 +8335,7 @@ function Print() {
8164
8335
  orderDetails = _useOrderDetails[0];
8165
8336
  var gsitId = orderDetails == null ? void 0 : orderDetails.gsit_order_id;
8166
8337
  var dropdownRef = useRef(null);
8167
- console.log(gsitId, 'gsitId');
8338
+ // console.log(gsitId, 'gsitId');
8168
8339
  var _useState = useState(false),
8169
8340
  isOpen = _useState[0],
8170
8341
  setIsOpen = _useState[1];
@@ -8552,7 +8723,11 @@ var ApplyButton = /*#__PURE__*/styled.button(_templateObject14$2 || (_templateOb
8552
8723
 
8553
8724
  // let todayDate = new Date();
8554
8725
  var initialState$1 = {
8555
- 'x-filters': [],
8726
+ 'x-filters': [{
8727
+ field: 'isdeleted',
8728
+ op: '=',
8729
+ value: 0
8730
+ }],
8556
8731
  'x-pagination': {
8557
8732
  page: 1,
8558
8733
  per_page: 50
@@ -8591,9 +8766,9 @@ var filterReducer = function filterReducer(state, action) {
8591
8766
  case 'SET_ACTIONS_FILTER':
8592
8767
  return _extends({}, state, {
8593
8768
  'x-filters': [].concat(state['x-filters'].filter(function (f) {
8594
- return f.field !== 'product_return_action_id';
8769
+ return f.field !== 'order_product_return_action.type';
8595
8770
  }), [{
8596
- field: 'product_return_action_id',
8771
+ field: 'order_product_return_action.type',
8597
8772
  op: '=',
8598
8773
  value: action.payload
8599
8774
  }])
@@ -8617,7 +8792,7 @@ var filterReducer = function filterReducer(state, action) {
8617
8792
  case 'CLEAR_ACTION':
8618
8793
  return _extends({}, state, {
8619
8794
  'x-filters': state['x-filters'].filter(function (f) {
8620
- return f.field !== 'product_return_action_id';
8795
+ return f.field !== 'order_product_return_action.type';
8621
8796
  })
8622
8797
  });
8623
8798
  case 'CLEAR_LOC':
@@ -8657,15 +8832,6 @@ var _templateObject$1R;
8657
8832
  function SelectionFilter() {
8658
8833
  var _useCustomerData = useCustomerData(),
8659
8834
  customers = _useCustomerData[0];
8660
- var _useActionType = useActionType(),
8661
- actionType = _useActionType[0];
8662
- var _useLocationData = useLocationData(),
8663
- locationData = _useLocationData[0];
8664
- var _useState = useState([]),
8665
- filteredLocationOptions = _useState[0],
8666
- setFilteredLocationOptions = _useState[1];
8667
- var _useState2 = useState(),
8668
- setUuid = _useState2[1];
8669
8835
  var _useSelectedAction = useSelectedAction(),
8670
8836
  selectedFilterValue = _useSelectedAction[0],
8671
8837
  setSelectedFilterValue = _useSelectedAction[1];
@@ -8675,138 +8841,98 @@ function SelectionFilter() {
8675
8841
  selectedLocationValue = _useSelectedLocation[0],
8676
8842
  setSelectedLocationValue = _useSelectedLocation[1];
8677
8843
  var _useSelectedClient = useSelectedClient(),
8844
+ selectedClient = _useSelectedClient[0],
8678
8845
  setSelectedClient = _useSelectedClient[1];
8679
- var _useTableName = useTableName(),
8680
- setClientLabel = _useTableName[1];
8681
- var _useState3 = useState(),
8682
- setName = _useState3[1];
8683
- var _useState4 = useState(false),
8684
- isButtonEnabled = _useState4[0],
8685
- setIsButtonEnabled = _useState4[1];
8846
+ var _useIdForTableName = useIdForTableName(),
8847
+ setClientIdForTable = _useIdForTableName[1];
8848
+ var _useState = useState(false),
8849
+ isButtonEnabled = _useState[0],
8850
+ setIsButtonEnabled = _useState[1];
8686
8851
  var _useReturnPayload = useReturnPayload(),
8687
8852
  setReturnPayload = _useReturnPayload[1];
8688
- var _useState5 = useState(),
8689
- storedAccNumber = _useState5[0],
8690
- setStoredAccNumber = _useState5[1];
8691
- var _useState6 = useState(),
8692
- storedCustomerId = _useState6[0],
8693
- setStoredCustomerId = _useState6[1];
8694
- var _useNewReturnPayload = useNewReturnPayload(),
8695
- setNewPayload = _useNewReturnPayload[1];
8696
- var _useGroupedPayload = useGroupedPayload(),
8697
- setGrouped = _useGroupedPayload[1];
8698
- var _useSelectedOrders = useSelectedOrders(),
8699
- setSelectedReturnOrder = _useSelectedOrders[1];
8700
- var _useSelectAll = useSelectAll(),
8701
- setSelectAll = _useSelectAll[1];
8702
- var _useSelectedConfirmLo = useSelectedConfirmLoc(),
8703
- setCheck = _useSelectedConfirmLo[1];
8853
+ var _useLoading = useLoading(),
8854
+ load = _useLoading[0];
8855
+ var _useTableName = useTableName(),
8856
+ setTableName = _useTableName[1];
8704
8857
  var _useClearState = useClearState(),
8705
8858
  clearState = _useClearState[0],
8706
8859
  setClear = _useClearState[1];
8707
- //client options
8860
+ var _useActionTypeOptions = useActionTypeOptions(),
8861
+ actionTypeOptions = _useActionTypeOptions[0],
8862
+ setActionTypeOptions = _useActionTypeOptions[1];
8863
+ var _useLocationOptions = useLocationOptions(),
8864
+ locationOptions = _useLocationOptions[0],
8865
+ setLocationOptions = _useLocationOptions[1];
8708
8866
  var clientOptions = customers == null ? void 0 : customers.map(function (option) {
8709
8867
  var _option$customer_name, _option$customer_name2;
8710
8868
  return {
8711
8869
  label: (option == null || (_option$customer_name = option.customer_name) == null || (_option$customer_name = _option$customer_name.charAt(0)) == null ? void 0 : _option$customer_name.toUpperCase()) + (option == null || (_option$customer_name2 = option.customer_name) == null ? void 0 : _option$customer_name2.slice(1)),
8712
- value: (option == null ? void 0 : option.id) + "_" + (option == null ? void 0 : option.uuid),
8713
- id: option == null ? void 0 : option.id,
8714
- uuid: option == null ? void 0 : option.uuid,
8715
- account_number: option == null ? void 0 : option.account_number,
8716
- gsit_customer_id: option == null ? void 0 : option.gsit_customer_id
8717
- };
8718
- });
8719
- var actionTypeOptions = actionType == null ? void 0 : actionType.map(function (option) {
8720
- var _option$type, _option$type2;
8721
- return {
8722
- label: (option == null || (_option$type = option.type) == null || (_option$type = _option$type.charAt(0)) == null ? void 0 : _option$type.toUpperCase()) + (option == null || (_option$type2 = option.type) == null ? void 0 : _option$type2.slice(1)),
8723
- value: option == null ? void 0 : option.id
8724
- };
8725
- });
8726
- var LocationOptions = locationData == null ? void 0 : locationData.map(function (option) {
8727
- return {
8728
- label: option == null ? void 0 : option.location_name,
8729
- value: option == null ? void 0 : option.token
8870
+ value: option == null ? void 0 : option.customer_id,
8871
+ actions: option == null ? void 0 : option.actions,
8872
+ return_locations: option == null ? void 0 : option.return_locations,
8873
+ account_number: option == null ? void 0 : option.account_number
8730
8874
  };
8731
8875
  });
8732
8876
  //client change
8733
- var handleSelectChange = function handleSelectChange(_value, option) {
8734
- setNewPayload([]);
8735
- var selectedLabel = option == null ? void 0 : option.label;
8736
- var selectedValue = option == null ? void 0 : option.id;
8737
- var selectedUuids = option == null ? void 0 : option.uuid;
8738
- var selectAccountNumber = option == null ? void 0 : option.account_number;
8739
- var selectedCustomerId = option == null ? void 0 : option.gsit_customer_id;
8740
- setSelectedClient(selectedValue);
8741
- setName(selectedLabel);
8742
- // storedName(selectedLabel);
8743
- //set items in local storage
8744
- localStorage.setItem('clientName', selectedLabel);
8745
- localStorage.setItem('clientId', selectedValue == null ? void 0 : selectedValue.toString());
8746
- localStorage.setItem('account_number', selectAccountNumber);
8747
- localStorage.setItem('uuid', selectedUuids);
8748
- localStorage.setItem('customer_id', selectedCustomerId == null ? void 0 : selectedCustomerId.toString());
8749
- var storedAccNo = localStorage.getItem('account_number');
8750
- var storedCustomerId = localStorage.getItem('customer_id');
8751
- var storedUuid = localStorage.getItem('uuid');
8752
- setUuid(storedUuid);
8877
+ var handleClientChange = function handleClientChange(value, option) {
8878
+ // console.log(value, 'value');
8879
+ setSelectedClient(value);
8880
+ localStorage.setItem('clientName', option == null ? void 0 : option.label);
8881
+ localStorage.setItem('clientId', value == null ? void 0 : value.toString());
8882
+ localStorage.setItem('account_number', option == null ? void 0 : option.account_number);
8753
8883
  //set payload
8754
8884
  setReturnPayload(function (prevState) {
8755
8885
  return _extends({}, prevState, {
8756
- account_number: storedAccNo,
8757
- customer_id: storedCustomerId
8886
+ account_number: option == null ? void 0 : option.account_number,
8887
+ customer_id: value
8758
8888
  });
8759
8889
  });
8760
- //filtering locations
8761
- var filteredSubLocations = locationData == null ? void 0 : locationData.filter(function (subCat) {
8762
- return (subCat == null ? void 0 : subCat.customer_id) === storedUuid;
8763
- }).map(function (subCat) {
8764
- return {
8765
- label: subCat == null ? void 0 : subCat.location_name,
8766
- value: subCat == null ? void 0 : subCat.token
8767
- };
8768
- });
8769
- setFilteredLocationOptions(filteredSubLocations);
8770
- //clearing states
8771
- setUuid('');
8772
- setSelectedReturnOrder([]);
8773
- setNewPayload([]);
8774
- setGrouped([]);
8775
- setSelectAll(false);
8776
- setCheck([]);
8777
8890
  };
8891
+ var storedName = localStorage.getItem('clientName');
8892
+ var storedClientId = localStorage.getItem('clientId');
8893
+ var storedAccountNumber = localStorage.getItem('account_number');
8778
8894
  useEffect(function () {
8779
- var accountNumberFromStorage = localStorage.getItem('account_number');
8780
- var customerIdFromStorage = localStorage.getItem('customer_id');
8781
- if (accountNumberFromStorage) {
8782
- setStoredAccNumber(accountNumberFromStorage);
8783
- }
8784
- if (customerIdFromStorage) {
8785
- setStoredCustomerId(customerIdFromStorage);
8895
+ if (storedClientId !== selectedClient) {
8896
+ localStorage.removeItem('clientDetails');
8897
+ localStorage.removeItem('clientActions');
8898
+ localStorage.removeItem('clientLocations');
8786
8899
  }
8787
- if (storedAccNumber && storedCustomerId) {
8900
+ }, [storedClientId]);
8901
+ useEffect(function () {
8902
+ if (storedClientId && storedAccountNumber) {
8788
8903
  setReturnPayload(function (prevState) {
8789
8904
  return _extends({}, prevState, {
8790
- account_number: storedAccNumber,
8791
- customer_id: storedCustomerId
8905
+ account_number: storedAccountNumber,
8906
+ customer_id: storedClientId
8792
8907
  });
8793
8908
  });
8794
8909
  }
8795
- }, [storedAccNumber, storedCustomerId]);
8796
- var storedUuid = localStorage.getItem('uuid');
8910
+ }, [storedClientId, storedAccountNumber]);
8797
8911
  useEffect(function () {
8798
- if (storedUuid && locationData) {
8799
- var filteredSubLocations = locationData.filter(function (subCat) {
8800
- return (subCat == null ? void 0 : subCat.customer_id) === storedUuid;
8801
- }).map(function (subCat) {
8802
- return {
8803
- label: subCat == null ? void 0 : subCat.location_name,
8804
- value: subCat == null ? void 0 : subCat.token
8805
- };
8912
+ var storedClientId = localStorage.getItem('clientId');
8913
+ if (storedClientId && (clientOptions == null ? void 0 : clientOptions.length) > 0) {
8914
+ var filteredClient = clientOptions == null ? void 0 : clientOptions.find(function (client) {
8915
+ return (client == null ? void 0 : client.value) == storedClientId;
8806
8916
  });
8807
- setFilteredLocationOptions(filteredSubLocations);
8917
+ if (filteredClient) {
8918
+ var _filteredClient$actio, _filteredClient$retur;
8919
+ var mappedActions = filteredClient == null || (_filteredClient$actio = filteredClient.actions) == null ? void 0 : _filteredClient$actio.map(function (action) {
8920
+ return {
8921
+ label: action,
8922
+ value: action
8923
+ };
8924
+ });
8925
+ setActionTypeOptions(mappedActions);
8926
+ var mappedLocations = filteredClient == null || (_filteredClient$retur = filteredClient.return_locations) == null ? void 0 : _filteredClient$retur.map(function (location) {
8927
+ return {
8928
+ label: location,
8929
+ value: location
8930
+ };
8931
+ });
8932
+ setLocationOptions(mappedLocations);
8933
+ }
8808
8934
  }
8809
- }, [storedUuid, locationData]);
8935
+ }, [load]);
8810
8936
  //location change
8811
8937
  var handleLocationChange = function handleLocationChange(value) {
8812
8938
  setSelectedLocationValue(value);
@@ -8817,9 +8943,29 @@ function SelectionFilter() {
8817
8943
  };
8818
8944
  //Apply filters
8819
8945
  var applyFilters = function applyFilters() {
8946
+ if (selectedClient) {
8947
+ setClientIdForTable(selectedClient);
8948
+ }
8820
8949
  if (storedName) {
8821
- setClientLabel(storedName);
8950
+ setTableName(storedName);
8822
8951
  }
8952
+ var selectedClientValue = clientOptions == null ? void 0 : clientOptions.find(function (client) {
8953
+ return (client == null ? void 0 : client.value) === selectedClient;
8954
+ });
8955
+ var clientActions = (selectedClientValue == null ? void 0 : selectedClientValue.actions) || [];
8956
+ var clientLocations = (selectedClientValue == null ? void 0 : selectedClientValue.return_locations) || [];
8957
+ setActionTypeOptions(clientActions == null ? void 0 : clientActions.map(function (action) {
8958
+ return {
8959
+ label: action,
8960
+ value: action
8961
+ };
8962
+ }));
8963
+ setLocationOptions(clientLocations == null ? void 0 : clientLocations.map(function (action) {
8964
+ return {
8965
+ label: action,
8966
+ value: action
8967
+ };
8968
+ }));
8823
8969
  //client value
8824
8970
  if (storedClientId) {
8825
8971
  dispatch({
@@ -8859,8 +9005,7 @@ function SelectionFilter() {
8859
9005
  });
8860
9006
  }
8861
9007
  };
8862
- var storedName = localStorage.getItem('clientName');
8863
- var storedClientId = localStorage.getItem('clientId');
9008
+ // const storedName = localStorage.getItem('clientName');
8864
9009
  useEffect(function () {
8865
9010
  if (storedClientId) {
8866
9011
  dispatch({
@@ -8870,12 +9015,12 @@ function SelectionFilter() {
8870
9015
  }
8871
9016
  }, []);
8872
9017
  useEffect(function () {
8873
- if (storedName || selectedFilterValue || selectedLocationValue) {
9018
+ if (storedClientId || selectedFilterValue || selectedLocationValue) {
8874
9019
  setIsButtonEnabled(true);
8875
9020
  } else {
8876
9021
  setIsButtonEnabled(false);
8877
9022
  }
8878
- }, [storedName, selectedFilterValue, selectedLocationValue]);
9023
+ }, [storedClientId, selectedFilterValue, selectedLocationValue]);
8879
9024
  useEffect(function () {}, [location.pathname]);
8880
9025
  useEffect(function () {
8881
9026
  if (!selectedFilterValue || selectedFilterValue === null) {
@@ -8891,8 +9036,7 @@ function SelectionFilter() {
8891
9036
  }, [selectedFilterValue, selectedLocationValue]);
8892
9037
  var handleClear = function handleClear() {
8893
9038
  setClear(false);
8894
- localStorage.removeItem('clientName');
8895
- localStorage.removeItem('clientId');
9039
+ localStorage.removeItem('clientDetails');
8896
9040
  setClear(true);
8897
9041
  };
8898
9042
  useEffect(function () {
@@ -8900,21 +9044,20 @@ function SelectionFilter() {
8900
9044
  dispatch({
8901
9045
  type: 'CLEAR_CLIENT'
8902
9046
  });
8903
- // window.location.href = '/returnclient';
8904
- window.location.replace('/returnclient');
9047
+ window.location.href = '/returnclient';
8905
9048
  }
8906
9049
  }, [clearState]);
8907
9050
  return React.createElement(Wrapper$j, null, React.createElement(FilterRow, null, React.createElement(LeftColumn, null, React.createElement(FilterColumn, null, React.createElement(Label$g, null, "Clients"), React.createElement(StyledAntSelect$2, {
8908
9051
  options: clientOptions,
8909
9052
  placeholder: "Select Client Name",
8910
- onChange: handleSelectChange,
9053
+ onChange: handleClientChange,
8911
9054
  style: {
8912
9055
  minWidth: '14vw'
8913
9056
  },
8914
9057
  value: storedName,
8915
9058
  allowClear: true,
8916
9059
  onClear: handleClear
8917
- })), storedName && location.pathname.includes("filter/") ? React.createElement(React.Fragment, null, React.createElement(FilterColumn, null, React.createElement(Label$g, null, "Action Type"), React.createElement(StyledAntSelect$2, {
9060
+ })), React.createElement(React.Fragment, null, React.createElement(FilterColumn, null, React.createElement(Label$g, null, "Action Type"), React.createElement(StyledAntSelect$2, {
8918
9061
  options: actionTypeOptions,
8919
9062
  placeholder: "Select Action Type",
8920
9063
  value: selectedFilterValue,
@@ -8924,7 +9067,7 @@ function SelectionFilter() {
8924
9067
  },
8925
9068
  allowClear: true
8926
9069
  })), React.createElement(FilterColumn, null, React.createElement(Label$g, null, "Location "), React.createElement(StyledAntSelect$2, {
8927
- options: (filteredLocationOptions == null ? void 0 : filteredLocationOptions.length) > 0 ? filteredLocationOptions : LocationOptions,
9070
+ options: locationOptions,
8928
9071
  value: selectedLocationValue,
8929
9072
  placeholder: "Select Location",
8930
9073
  onChange: handleLocationChange,
@@ -8933,7 +9076,7 @@ function SelectionFilter() {
8933
9076
  },
8934
9077
  allowClear: true,
8935
9078
  mode: "multiple"
8936
- }))) : null), React.createElement(RightColumn$1, null, React.createElement(ApplyButton, {
9079
+ })))), React.createElement(RightColumn$1, null, React.createElement(ApplyButton, {
8937
9080
  onClick: applyFilters,
8938
9081
  disabled: !isButtonEnabled
8939
9082
  }, "Apply"))));
@@ -9042,9 +9185,8 @@ var Container$13 = /*#__PURE__*/styled.div(_templateObject$1T || (_templateObjec
9042
9185
  var ButtonText = /*#__PURE__*/styled.button(_templateObject2$1n || (_templateObject2$1n = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: white;\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n\n display: flex;\n padding: 7px 12px;\n justify-content: center;\n align-items: center;\n gap: 2px;\n border-radius: 15px;\n background: #3a3630;\n font-family: 'Lato';\n cursor: pointer;\n border: none;\n\n &:disabled {\n border-radius: 15px;\n background: rgba(136, 128, 117, 0.35);\n color: #888075;\n cursor: not-allowed;\n }\n"])));
9043
9186
 
9044
9187
  var ReturnFilter = function ReturnFilter() {
9045
- var _useParams = useParams(),
9046
- clientName = _useParams.clientName;
9047
- return React.createElement(React.Fragment, null, React.createElement(StyledFiter, null, React.createElement(Text$8, null, " ", clientName), React.createElement(StyledFIlterELements, null, React.createElement(StyledTableFilter, null)), React.createElement(RightFilters, null)));
9188
+ var storedName = localStorage.getItem('clientName');
9189
+ return React.createElement(React.Fragment, null, React.createElement(StyledFiter, null, React.createElement(Text$8, null, storedName), React.createElement(StyledFIlterELements, null, React.createElement(StyledTableFilter, null)), React.createElement(RightFilters, null)));
9048
9190
  };
9049
9191
 
9050
9192
  var _templateObject$1U, _templateObject2$1o, _templateObject3$Q, _templateObject4$u, _templateObject34, _templateObject35, _templateObject36, _templateObject37;
@@ -9055,7 +9197,7 @@ var StyledTableWrapper$2 = /*#__PURE__*/styled.div(_templateObject3$Q || (_templ
9055
9197
  var StyledTable$3 = /*#__PURE__*/styled.table(_templateObject4$u || (_templateObject4$u = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-spacing: 0 10px;\n width: 100%;\n /* min-width: 1600px; */\n thead {\n tr {\n border-radius: 40px;\n border-spacing: 0 10px;\n font-family: 'lato', sans-serif;\n .emailInvoiceCheckbox {\n padding-right: 0px;\n width: 0;\n > div {\n width: fit-content;\n }\n }\n .emailInvoiceNo {\n padding-left: 12px;\n }\n .emailInvoiceShare {\n width: 100px;\n }\n th {\n color: #3a3630;\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: normal;\n padding: 11px 15px;\n background: #f0f2f2;\n border-right: none;\n border-left: none;\n text-align: left;\n border: 1px solid rgba(0, 0, 0, 0.08);\n border-width: 1px 0;\n &:first-child {\n border-radius: 100px 0 0 100px;\n border-left: 1px solid rgba(0, 0, 0, 0.08);\n }\n &:last-child {\n border-radius: 0px 100px 100px 0;\n border-right: 1px solid rgba(0, 0, 0, 0.08);\n }\n }\n }\n }\n tbody {\n tr {\n td {\n color: #3a3630;\n font-size: 13px;\n font-style: normal;\n font-weight: 400;\n line-height: normal;\n padding: 12px 15px;\n background: #fff;\n border: 1px solid rgba(0, 0, 0, 0.08);\n border-right: none;\n border-left: none;\n\n .shareIconContainer {\n display: flex;\n width: 24px;\n height: 24px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 10px;\n flex-shrink: 0;\n border-radius: 15px;\n background: #edebe8;\n cursor: pointer;\n }\n .statuscontainer {\n display: flex;\n padding: 6px 10px;\n justify-content: center;\n align-items: center;\n gap: 5px;\n flex: 1 0 0;\n border-radius: 22px;\n background: rgba(41, 204, 106, 0.15);\n }\n }\n &:nth-child(even) td {\n background: #f6fbff;\n }\n td:first-child {\n border-radius: 100px 0 0 100px;\n border-left: 1px solid rgba(0, 0, 0, 0.08);\n }\n td:last-child {\n border-radius: 0px 100px 100px 0;\n border-right: 1px solid rgba(0, 0, 0, 0.08);\n }\n .flex {\n display: flex;\n flex-direction: row;\n gap: 5px;\n height: 29px;\n align-items: center;\n }\n\n &.insideTable {\n td {\n border-radius: 0;\n border: none;\n &:last-child {\n border-radius: 0;\n border-right: none;\n }\n }\n table {\n border-spacing: 0;\n width: 100%;\n border-radius: 5px;\n border: 1px solid rgba(0, 0, 0, 0.08);\n overflow: hidden;\n border-top-left-radius: 15px;\n border-top-right-radius: 15px;\n thead {\n tr {\n border-bottom: none;\n th {\n padding: 14px 20px;\n text-align: left;\n border-top: 0;\n border-right: 0;\n border-left: 0;\n background: #f8fafc;\n\n &:first-child {\n border-radius: 0;\n border-left: 1px solid rgba(0, 0, 0, 0.08);\n border-top-left-radius: 15px;\n }\n &:last-child {\n border-radius: 0;\n }\n }\n }\n }\n tbody {\n tr {\n td {\n padding: 14px 20px;\n text-align: left;\n border-bottom: 1px solid rgba(58, 54, 48, 0.15);\n background: #fff;\n > svg {\n transform: scale(1.5);\n background-color: #edebe8;\n border-radius: 20px;\n padding: 5px;\n }\n &:last-child {\n border-radius: 0;\n border-right: none;\n }\n }\n }\n }\n }\n }\n }\n }\n .actions {\n display: flex;\n align-items: center;\n gap: 20px;\n > svg {\n transform: scale(1.5);\n background-color: #edebe8;\n border-radius: 20px;\n padding: 5px;\n }\n\n .close-icon {\n transform: scale(1.3);\n background-color: transparent;\n border-radius: 0;\n padding: 0;\n }\n }\n"])));
9056
9198
  var EmptyDataContainer$1 = /*#__PURE__*/styled.div(_templateObject34 || (_templateObject34 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: center;\n"])));
9057
9199
  var ClearAll = /*#__PURE__*/styled.div(_templateObject35 || (_templateObject35 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-radius: 20px;\n border: 1px solid #edebe8;\n background: #fff;\n display: flex;\n padding: 6px 6px;\n justify-content: center;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n\n &.active {\n background: #313130;\n & > div {\n color: #fff;\n }\n }\n"])));
9058
- var StyledFilterBtnIcon = /*#__PURE__*/styled.div(_templateObject36 || (_templateObject36 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 24px;\n height: 24px;\n justify-content: center;\n align-items: center;\n border-radius: 20px;\n border: 1px solid #e2e0db;\n background: #f1f5f6;\n .cross {\n position: relative;\n &:after {\n display: inline-block;\n content: 'X';\n font-style: normal;\n font-size: 14px;\n color: #000;\n }\n }\n"])));
9200
+ var StyledFilterBtnIcon = /*#__PURE__*/styled.div(_templateObject36 || (_templateObject36 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 24px;\n height: 24px;\n justify-content: center;\n align-items: center;\n border-radius: 20px;\n border: 1px solid #e2e0db;\n background: #b2b3b3;\n .cross {\n position: relative;\n &:after {\n display: inline-block;\n content: 'X';\n font-style: normal;\n font-size: 14px;\n color: #000;\n }\n }\n"])));
9059
9201
  var StyledFilterBtnLabel = /*#__PURE__*/styled.div(_templateObject37 || (_templateObject37 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: #6a7378;\n font-size: 13px;\n font-style: normal;\n font-weight: 400;\n line-height: 16px;\n white-space: nowrap;\n"])));
9060
9202
 
9061
9203
  var PrinterIcon = function PrinterIcon() {
@@ -9246,7 +9388,7 @@ var PrintDropDownReturn = function PrintDropDownReturn(_ref) {
9246
9388
  var legacyProductId = _ref.legacyProductId;
9247
9389
  console.log(legacyProductId, 'legacyProductId');
9248
9390
  var downloadFiles = function downloadFiles() {
9249
- var url = "https://toolbox.bjshomedelivery.com/offload/return_label?gsit_products_id=" + legacyProductId;
9391
+ var url = "https://us.toolbox.bjshomedelivery.com/offload/return_label?gsit_products_id=" + legacyProductId;
9250
9392
  window.open(url, '_blank'); // Opens the URL in a new tab
9251
9393
  };
9252
9394
  return React.createElement(OptionsList, null, options == null ? void 0 : options.map(function (item, index) {
@@ -9426,7 +9568,7 @@ var ReturnOrderTable = function ReturnOrderTable() {
9426
9568
  account_number: createReturn == null ? void 0 : createReturn.account_number,
9427
9569
  customer_id: +(createReturn == null ? void 0 : createReturn.customer_id),
9428
9570
  products: [legacy_product_id],
9429
- return_action: [order_product_return_action == null ? void 0 : order_product_return_action.type] || null,
9571
+ return_action: order_product_return_action != null && order_product_return_action.type ? [order_product_return_action.type] : null,
9430
9572
  return_location_token: return_location || null
9431
9573
  };
9432
9574
  setNewPayload(function (prevPayload) {
@@ -9481,7 +9623,7 @@ var ReturnOrderTable = function ReturnOrderTable() {
9481
9623
  }, React.createElement(Checkbox$1, {
9482
9624
  checked: selectAll,
9483
9625
  onChange: handleSelectAll
9484
- })) : React.createElement("th", null), React.createElement("th", null, "Product Location"), React.createElement("th", null, "Return Location"), React.createElement("th", null, "Recipient"), React.createElement("th", null, "Code"), React.createElement("th", null, "Description"), React.createElement("th", null, "Part"), React.createElement("th", null, "Weight"), React.createElement("th", null, "CBM"), React.createElement("th", null, "Return Reason"), React.createElement("th", null, "Collected"), React.createElement("th", null, "Collection Reason"), React.createElement("th", {
9626
+ })) : React.createElement("th", null), React.createElement("th", null, "Product Location"), React.createElement("th", null, "Return Location"), React.createElement("th", null, "Recipient"), React.createElement("th", null, "Return Action"), React.createElement("th", null, "Code"), React.createElement("th", null, "Description"), React.createElement("th", null, "Part"), React.createElement("th", null, "Weight"), React.createElement("th", null, "CBM"), React.createElement("th", null, "Return Reason"), React.createElement("th", null, "Collected"), React.createElement("th", null, "Collection Reason"), React.createElement("th", {
9485
9627
  className: "emailInvoiceShare"
9486
9628
  }, "Labels"))), React.createElement("tbody", null, load ? React.createElement("tr", null, React.createElement("td", {
9487
9629
  colSpan: 13
@@ -9490,7 +9632,7 @@ var ReturnOrderTable = function ReturnOrderTable() {
9490
9632
  }))) : (returnData == null ? void 0 : returnData.length) === 0 ? React.createElement("tr", null, React.createElement("td", {
9491
9633
  colSpan: 14
9492
9634
  }, React.createElement(EmptyDataContainer$1, null, React.createElement(Empty, null)))) : returnData == null ? void 0 : returnData.map(function (item, index) {
9493
- var _item$order_product_r2, _item$orders_products, _item$orders_products2, _item$order_data, _item$order_data2, _item$return_reasons, _item$order_product_r3, _item$collection_reas;
9635
+ var _item$order_product_r2, _item$orders_products, _item$orders_products2, _item$order_data, _item$order_data2, _item$order_product_r3, _item$return_reasons, _item$order_product_r4, _item$collection_reas;
9494
9636
  return React.createElement("tr", {
9495
9637
  key: item.id
9496
9638
  }, React.createElement("td", null, (item == null || (_item$order_product_r2 = item.order_product_return_action) == null ? void 0 : _item$order_product_r2.type) == 'RTS' ? React.createElement(React.Fragment, null, React.createElement(Checkbox$1, {
@@ -9518,7 +9660,7 @@ var ReturnOrderTable = function ReturnOrderTable() {
9518
9660
  style: {
9519
9661
  color: '#888075'
9520
9662
  }
9521
- }, displayValueOrNA(item == null || (_item$order_data2 = item.order_data) == null || (_item$order_data2 = _item$order_data2.order_recipient) == null ? void 0 : _item$order_data2.postcode)))), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.code)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.description)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.parts_count)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.weight), ' ', item != null && item.weight && (item == null ? void 0 : item.weight) !== null ? 'KG' : ''), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.cube)), React.createElement("td", null, displayValueOrNA(item == null || (_item$return_reasons = item.return_reasons) == null ? void 0 : _item$return_reasons.reason)), React.createElement("td", null, (item == null || (_item$order_product_r3 = item.order_product_returns) == null ? void 0 : _item$order_product_r3.length) > 0 ? item.order_product_returns.map(function (ret) {
9663
+ }, displayValueOrNA(item == null || (_item$order_data2 = item.order_data) == null || (_item$order_data2 = _item$order_data2.order_recipient) == null ? void 0 : _item$order_data2.postcode)))), React.createElement("td", null, displayValueOrNA(item == null || (_item$order_product_r3 = item.order_product_return_action) == null ? void 0 : _item$order_product_r3.type)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.code)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.description)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.parts_count)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.weight), ' ', item != null && item.weight && (item == null ? void 0 : item.weight) !== null ? 'KG' : ''), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.cube)), React.createElement("td", null, displayValueOrNA(item == null || (_item$return_reasons = item.return_reasons) == null ? void 0 : _item$return_reasons.reason)), React.createElement("td", null, (item == null || (_item$order_product_r4 = item.order_product_returns) == null ? void 0 : _item$order_product_r4.length) > 0 ? item.order_product_returns.map(function (ret) {
9522
9664
  return ret != null && ret.collected_at ? format(new Date(ret.collected_at), 'dd/MM/yyyy') : 'UNKNOWN';
9523
9665
  }) : 'UNKNOWN'), React.createElement("td", null, displayValueOrNA(item == null || (_item$collection_reas = item.collection_reasons) == null ? void 0 : _item$collection_reas.reason)), React.createElement("td", null, React.createElement("ul", {
9524
9666
  className: "actionbox"
@@ -9680,8 +9822,6 @@ var ModalManager = function ModalManager() {
9680
9822
  popupName = _useAtom[0],
9681
9823
  dispatch = _useAtom[1];
9682
9824
  var _useProductDetails = useProductDetails();
9683
- var _useCreateOrderProduc = useCreateOrderProducts(),
9684
- orderProduct = _useCreateOrderProduc[0];
9685
9825
  var _useDeleteProdsID = useDeleteProdsID(),
9686
9826
  selectedRows = _useDeleteProdsID[0];
9687
9827
  var _useState = useState(false),
@@ -9705,14 +9845,12 @@ var ModalManager = function ModalManager() {
9705
9845
  var _usefetchAgain = usefetchAgain(),
9706
9846
  setCallForFetch = _usefetchAgain[1];
9707
9847
  var navigate = useNavigate();
9708
- console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
9709
9848
  var _closeModal = function closeModal() {
9710
9849
  dispatch({
9711
9850
  type: 'close'
9712
9851
  });
9713
9852
  };
9714
9853
  var validateForm = function validateForm() {
9715
- console.log(selectedRows, 'selectedRowsselectedRowsselectedRows');
9716
9854
  return (selectedRows == null ? void 0 : selectedRows.length) > 0;
9717
9855
  };
9718
9856
  useEffect(function () {
@@ -9730,7 +9868,7 @@ var ModalManager = function ModalManager() {
9730
9868
  confirmLoading = _useApiHook.loading,
9731
9869
  apiError = _useApiHook.error,
9732
9870
  setError = _useApiHook.setError;
9733
- console.log(response, 'data'), useEffect(function () {
9871
+ useEffect(function () {
9734
9872
  SetPostLoading(confirmLoading);
9735
9873
  }, [confirmLoading]);
9736
9874
  var handleConfirmReturn = function handleConfirmReturn() {
@@ -10062,20 +10200,29 @@ var OptionsListLi$1 = /*#__PURE__*/styled.li(_templateObject2$1u || (_templateOb
10062
10200
  return disabled ? 'transparent' : '#f0f0f0';
10063
10201
  });
10064
10202
 
10203
+ var _templateObject$1$;
10065
10204
  var OrderTable = function OrderTable(_ref) {
10066
10205
  var loadingskeleton = _ref.loadingskeleton;
10067
10206
  // const [, setSelectedReturnOrder] = useSelectedOrders();
10068
10207
  // const [selectAll, setSelectAll] = useState(false);
10069
- // const defaultSelectStyle = { width: '100%' };
10070
- var defaultPopupClassName = 'dropDownStyle';
10071
- var defaultSelectWrapperClass = 'rounded';
10072
10208
  var dropdownRefParent = useRef(null);
10073
10209
  var dropdownRef = useRef(null);
10074
10210
  var _usePrintOptionTOggle = usePrintOptionTOggle(),
10075
10211
  printToogle = _usePrintOptionTOggle[0],
10076
10212
  setPrintToggle = _usePrintOptionTOggle[1];
10213
+ var _useAssignData = useAssignData(),
10214
+ assignData = _useAssignData[0];
10215
+ var _useOrderId = useOrderId(),
10216
+ setOrderId = _useOrderId[1];
10077
10217
  var _useReturnAfterOrderD = useReturnAfterOrderData(),
10078
10218
  returnAfterOrder = _useReturnAfterOrderD[0];
10219
+ var _useAssignPayload = useAssignPayload(),
10220
+ assignPayload = _useAssignPayload[0],
10221
+ setAssignPayload = _useAssignPayload[1];
10222
+ var _useState = useState(false),
10223
+ setAssign = _useState[1];
10224
+ var _useCallApiAgain = useCallApiAgain(),
10225
+ setCallAPi = _useCallApiAgain[1];
10079
10226
  var OpenDropDown = function OpenDropDown(index) {
10080
10227
  setPrintToggle(function (prevIndex) {
10081
10228
  return prevIndex === index ? null : index;
@@ -10118,14 +10265,6 @@ var OrderTable = function OrderTable(_ref) {
10118
10265
  // }
10119
10266
  // });
10120
10267
  // };
10121
- // console.log('', returnAfterOrder);
10122
- var assigneOptions = [{
10123
- label: 'BJS Distribution',
10124
- value: 'bjs-dist'
10125
- }, {
10126
- label: 'Haulage',
10127
- value: 'haulage'
10128
- }];
10129
10268
  var getStatusClass = function getStatusClass(status) {
10130
10269
  switch (status) {
10131
10270
  case 'Cancelled':
@@ -10170,14 +10309,56 @@ var OrderTable = function OrderTable(_ref) {
10170
10309
  };
10171
10310
  }
10172
10311
  };
10173
- var _useOrderId = useOrderId(),
10174
- setOrderId = _useOrderId[1];
10175
- // console.log(id, 'idid');
10176
- return React.createElement(React.Fragment, null, React.createElement(StyledTableWrapper, {
10312
+ // API for Assign
10313
+ var _useApiHook = useApiHook({
10314
+ endpoint: "return_orders/update/assign/",
10315
+ method: 'PUT',
10316
+ body: [assignPayload],
10317
+ performAction: false
10318
+ }),
10319
+ actionResponse = _useApiHook.data,
10320
+ setAssignAction = _useApiHook.setShouldPerformAction,
10321
+ AssignLoading = _useApiHook.loading,
10322
+ apiError = _useApiHook.error;
10323
+ //client options
10324
+ var assignOptions = assignData == null ? void 0 : assignData.map(function (option) {
10325
+ var _option$type, _option$type2;
10326
+ return {
10327
+ label: (option == null || (_option$type = option.type) == null || (_option$type = _option$type.charAt(0)) == null ? void 0 : _option$type.toUpperCase()) + (option == null || (_option$type2 = option.type) == null ? void 0 : _option$type2.slice(1)),
10328
+ value: option == null ? void 0 : option.bjs_delivery
10329
+ };
10330
+ });
10331
+ var handleAssignPayload = function handleAssignPayload(Id, value) {
10332
+ setCallAPi(false);
10333
+ setAssign(value);
10334
+ setAssignPayload(_extends({}, assignPayload, {
10335
+ return_order_id: Id,
10336
+ bjs_delivery: value
10337
+ }));
10338
+ setAssignAction(true);
10339
+ };
10340
+ useEffect(function () {
10341
+ //@ts-ignore
10342
+ if ((actionResponse == null ? void 0 : actionResponse.code) === 200) {
10343
+ setCallAPi(true);
10344
+ notification.success({
10345
+ message: 'Success',
10346
+ // @ts-ignore
10347
+ description: "" + (actionResponse == null ? void 0 : actionResponse.message)
10348
+ });
10349
+ // @ts-ignore
10350
+ } else if (apiError != null && apiError.detail) {
10351
+ var _apiError$detail$;
10352
+ notification.error({
10353
+ message: 'Failure',
10354
+ // @ts-ignore
10355
+ description: "" + (apiError == null || (_apiError$detail$ = apiError.detail[0]) == null ? void 0 : _apiError$detail$.msg)
10356
+ });
10357
+ }
10358
+ }, [actionResponse, apiError]);
10359
+ return React.createElement(React.Fragment, null, AssignLoading && React.createElement(Loader, null), React.createElement(StyledTableWrapper, {
10177
10360
  className: "fortables"
10178
- }, React.createElement(StyledTable$1, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", {
10179
- className: "emailInvoiceNo"
10180
- }, "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", {
10361
+ }, 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", {
10181
10362
  className: "emailInvoiceShare"
10182
10363
  }, "Labels"))), React.createElement("tbody", null, loadingskeleton ? React.createElement("tr", null, React.createElement("td", {
10183
10364
  colSpan: 16
@@ -10223,17 +10404,18 @@ var OrderTable = function OrderTable(_ref) {
10223
10404
  style: {
10224
10405
  color: '#888075'
10225
10406
  }
10226
- }, displayValueOrNA(item == null || (_item$order_recipient2 = item.order_recipient) == null ? void 0 : _item$order_recipient2.postcode)))), React.createElement("td", null, displayValueOrNA(item == null || (_item$customer_data = item.customer_data) == null ? void 0 : _item$customer_data.customer_name)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.consignment)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.order_number)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.box_count)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.weight), ' ', item != null && item.weight && (item == null ? void 0 : item.weight) !== null ? 'KG' : ''), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.cube)), React.createElement("td", null, React.createElement(AntSelect, {
10227
- options: assigneOptions,
10407
+ }, displayValueOrNA(item == null || (_item$order_recipient2 = item.order_recipient) == null ? void 0 : _item$order_recipient2.postcode)))), React.createElement("td", null, displayValueOrNA(item == null || (_item$customer_data = item.customer_data) == null ? void 0 : _item$customer_data.customer_name)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.consignment)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.order_number)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.box_count)), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.weight), ' ', item != null && item.weight && (item == null ? void 0 : item.weight) !== null ? 'KG' : ''), React.createElement("td", null, displayValueOrNA(item == null ? void 0 : item.cube)), React.createElement("td", {
10408
+ key: item.id
10409
+ }, React.createElement(StyledAntSelect$3, {
10410
+ options: assignOptions,
10228
10411
  placeholder: "Select",
10229
- onChange: function onChange() {},
10230
- // defaultValue={item?.assign || ''}
10231
- // style={defaultSelectStyle}
10232
- disabled // onSearch={handleSearch}
10233
- : true,
10234
- showSearch: true,
10235
- popupClassName: defaultPopupClassName,
10236
- selectWrapperClass: defaultSelectWrapperClass
10412
+ onChange: function onChange(value) {
10413
+ return handleAssignPayload(item == null ? void 0 : item.id, value);
10414
+ },
10415
+ style: {
10416
+ width: '150px'
10417
+ },
10418
+ value: item == null ? void 0 : item.bjs_delivery
10237
10419
  })), React.createElement("td", null, React.createElement("ul", {
10238
10420
  className: "statuscontainer",
10239
10421
  style: {
@@ -10264,8 +10446,9 @@ var OrderTable = function OrderTable(_ref) {
10264
10446
  }, React.createElement(LoadIcon, null)))));
10265
10447
  })))));
10266
10448
  };
10449
+ var StyledAntSelect$3 = /*#__PURE__*/styled(Select)(_templateObject$1$ || (_templateObject$1$ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .ant-select-selector {\n /* width: 22vw; */\n border-radius: 22px;\n }\n .ant-select-clear {\n top: 40% !important;\n font-size: 18px !important;\n }\n"])));
10267
10450
 
10268
- var _templateObject$1$;
10451
+ var _templateObject$20;
10269
10452
  // import DownloadIcon from '../../../../assets/icons/DownloadIcon';
10270
10453
  var TableFilters = function TableFilters() {
10271
10454
  return React.createElement(Container$16, null);
@@ -10282,7 +10465,7 @@ var TableFilters = function TableFilters() {
10282
10465
  // // </StyledBulkFilterCover>
10283
10466
  // );
10284
10467
  };
10285
- var Container$16 = /*#__PURE__*/styled.div(_templateObject$1$ || (_templateObject$1$ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n /* align-items: flex-start; */\n gap: 16px;\n align-items: center;\n"])));
10468
+ var Container$16 = /*#__PURE__*/styled.div(_templateObject$20 || (_templateObject$20 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n /* align-items: flex-start; */\n gap: 16px;\n align-items: center;\n"])));
10286
10469
 
10287
10470
  var FilterIcon = function FilterIcon() {
10288
10471
  return React.createElement("svg", {
@@ -10395,7 +10578,6 @@ var initialState$2 = {
10395
10578
  }
10396
10579
  };
10397
10580
  var filterReducer$1 = function filterReducer(state, action) {
10398
- console.log(action, 'action');
10399
10581
  switch (action.type) {
10400
10582
  case 'SET_DATE_FILTER':
10401
10583
  return _extends({}, state, {
@@ -10431,6 +10613,22 @@ var filterReducer$1 = function filterReducer(state, action) {
10431
10613
  value: action.payload
10432
10614
  }])
10433
10615
  });
10616
+ // case 'CLEAR_CLIENT':
10617
+ // return {
10618
+ // ...state,
10619
+ // 'x-filters': state['x-filters'].filter(f => f.field !== 'customer_id'),
10620
+ // };
10621
+ // case 'CLEAR_STATUS_ORDER':
10622
+ // return {
10623
+ // ...state,
10624
+ // 'x-filters': state['x-filters'].filter(f => f.field !== 'status_id'),
10625
+ // };
10626
+ case 'CLEAR_DATE':
10627
+ return _extends({}, state, {
10628
+ 'x-filters': state['x-filters'].filter(function (f) {
10629
+ return f.field !== 'created_at';
10630
+ })
10631
+ });
10434
10632
  case 'SET_PAGE':
10435
10633
  return _extends({}, state, {
10436
10634
  'x-pagination': _extends({}, state['x-pagination'], {
@@ -10460,7 +10658,7 @@ var filtersReducerReturnAtom = /*#__PURE__*/atom(function (get) {
10460
10658
  return set(filtersStateAtom$1, filterReducer$1(get(filtersStateAtom$1), action));
10461
10659
  });
10462
10660
 
10463
- var _templateObject$20, _templateObject2$1v;
10661
+ var _templateObject$21, _templateObject2$1v;
10464
10662
  var ReturnOrderFilter = function ReturnOrderFilter() {
10465
10663
  var _useAtom = useAtom(filtersReducerReturnAtom),
10466
10664
  dispatch = _useAtom[1];
@@ -10477,7 +10675,6 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10477
10675
  var _useState3 = useState(),
10478
10676
  statusOrder = _useState3[0],
10479
10677
  setStatusOfOrder = _useState3[1];
10480
- console.log(selectedClient, 'fffffselectedClient');
10481
10678
  var zoneOptions = [{
10482
10679
  label: 'Zone 1',
10483
10680
  value: 'zone1'
@@ -10497,11 +10694,9 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10497
10694
  // date change here
10498
10695
  var handleDateChange = function handleDateChange(date) {
10499
10696
  setSelectedDate(date ? date == null ? void 0 : date.$d : null);
10500
- console.log(selectedDate, 'selected');
10501
10697
  };
10502
10698
  useEffect(function () {
10503
10699
  if (selectedDate) {
10504
- console.log(selectedDate, 'selected');
10505
10700
  dispatch({
10506
10701
  type: 'SET_DATE_FILTER',
10507
10702
  payload: selectedDate
@@ -10518,10 +10713,9 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10518
10713
  var _option$customer_name, _option$customer_name2;
10519
10714
  return {
10520
10715
  label: (option == null || (_option$customer_name = option.customer_name) == null || (_option$customer_name = _option$customer_name.charAt(0)) == null ? void 0 : _option$customer_name.toUpperCase()) + (option == null || (_option$customer_name2 = option.customer_name) == null ? void 0 : _option$customer_name2.slice(1)),
10521
- value: option == null ? void 0 : option.id
10716
+ value: option == null ? void 0 : option.customer_id
10522
10717
  };
10523
10718
  });
10524
- console.log(clientOptions, 'clientOptions');
10525
10719
  //status of order
10526
10720
  var orderOptions = statusOfOrder == null ? void 0 : statusOfOrder.map(function (option) {
10527
10721
  var _option$status_type, _option$status_type2;
@@ -10532,7 +10726,6 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10532
10726
  });
10533
10727
  var handleClientChange = function handleClientChange(value) {
10534
10728
  if (value === selectedClient) return;
10535
- console.log(value, 'value');
10536
10729
  setSelectedClient(value);
10537
10730
  dispatch({
10538
10731
  type: 'SET_CLIENT_FILTER',
@@ -10546,7 +10739,6 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10546
10739
  };
10547
10740
  var handleStatusOfOrder = function handleStatusOfOrder(value) {
10548
10741
  if (value === statusOfOrder) return;
10549
- console.log(value, 'value');
10550
10742
  setStatusOfOrder(value);
10551
10743
  dispatch({
10552
10744
  type: 'SET_STATUS_ORDER_FILTER',
@@ -10566,6 +10758,14 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10566
10758
  type: 'CLEAR_ALL_FILTER'
10567
10759
  });
10568
10760
  };
10761
+ //clearing filters
10762
+ useEffect(function () {
10763
+ if (selectedDate === null) {
10764
+ dispatch({
10765
+ type: 'CLEAR_DATE'
10766
+ });
10767
+ }
10768
+ }, [selectedDate]);
10569
10769
  return React.createElement(React.Fragment, null, React.createElement(StyledFiter, null, React.createElement(StyledFIlterELements, null, React.createElement(LeftSideConatiner, null, React.createElement("div", {
10570
10770
  className: "filtercontainer"
10571
10771
  }, React.createElement("div", {
@@ -10585,12 +10785,13 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10585
10785
  value: selectedDate ? dayjs(selectedDate) : null,
10586
10786
  format: "DD/MM/YY",
10587
10787
  placeholder: "Date",
10588
- needConfirm: true
10788
+ needConfirm: true,
10789
+ allowClear: true
10589
10790
  }))), React.createElement("div", {
10590
10791
  className: "datefilter"
10591
10792
  }, React.createElement("div", {
10592
10793
  className: "dateiconcontainer"
10593
- }, React.createElement(StatusIcon, null)), React.createElement(StyledAntSelect$3, null, React.createElement(Select, {
10794
+ }, React.createElement(StatusIcon, null)), React.createElement(StyledAntSelect$4, null, React.createElement(Select, {
10594
10795
  options: orderOptions,
10595
10796
  className: "custom-select",
10596
10797
  placeholder: "Status of Order",
@@ -10603,7 +10804,7 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10603
10804
  className: "datefilter"
10604
10805
  }, React.createElement("div", {
10605
10806
  className: "dateiconcontainer"
10606
- }, React.createElement(ClientIcon, null)), React.createElement(StyledAntSelect$3, null, React.createElement(Select, {
10807
+ }, React.createElement(ClientIcon, null)), React.createElement(StyledAntSelect$4, null, React.createElement(Select, {
10607
10808
  options: clientOptions,
10608
10809
  className: "custom-select",
10609
10810
  placeholder: "Client",
@@ -10621,7 +10822,7 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10621
10822
  }
10622
10823
  }, React.createElement("div", {
10623
10824
  className: "dateiconcontainer"
10624
- }, React.createElement(AssigneIcon, null)), React.createElement(StyledAntSelect$3, null, React.createElement(Select, {
10825
+ }, React.createElement(AssigneIcon, null)), React.createElement(StyledAntSelect$4, null, React.createElement(Select, {
10625
10826
  options: zoneOptions,
10626
10827
  className: "custom-select",
10627
10828
  placeholder: "Asignee",
@@ -10636,9 +10837,9 @@ var ReturnOrderFilter = function ReturnOrderFilter() {
10636
10837
  className: "cross"
10637
10838
  })), React.createElement(StyledFilterBtnLabel, null, "Clear all"))) : null)), React.createElement(TableFilters, null)));
10638
10839
  };
10639
- var StyledDatePicker = /*#__PURE__*/styled.div(_templateObject$20 || (_templateObject$20 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .custom-datepicker {\n border: none;\n }\n"])));
10840
+ var StyledDatePicker = /*#__PURE__*/styled.div(_templateObject$21 || (_templateObject$21 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .custom-datepicker {\n border: none;\n }\n"])));
10640
10841
  // const DropdownContainer = styled.div``;
10641
- var StyledAntSelect$3 = /*#__PURE__*/styled.div(_templateObject2$1v || (_templateObject2$1v = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .custom-select {\n border: none;\n width: 80px;\n }\n .ant-select-selector {\n border: 1px solid #ffffff !important;\n }\n :where(.css-dev-only-do-not-override-m4timi).ant-select-single:not(.ant-select-customize-input)\n .ant-select-selector {\n padding: 0 5px;\n }\n :where(.css-dev-only-do-not-override-m4timi).ant-select-outlined:not(.ant-select-customize-input)\n .ant-select-selector {\n border: none;\n }\n .roundbox {\n display: flex;\n width: 18px;\n height: 18px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n border-radius: 18px;\n background: #fff;\n box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.1);\n left: 359px;\n position: absolute;\n border-radius: 18px;\n background: #fff;\n box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.1);\n top: 16px;\n }\n"])));
10842
+ var StyledAntSelect$4 = /*#__PURE__*/styled.div(_templateObject2$1v || (_templateObject2$1v = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .custom-select {\n border: none;\n width: 80px;\n }\n .ant-select-selector {\n border: 1px solid #ffffff !important;\n }\n :where(.css-dev-only-do-not-override-m4timi).ant-select-single:not(.ant-select-customize-input)\n .ant-select-selector {\n padding: 0 5px;\n }\n :where(.css-dev-only-do-not-override-m4timi).ant-select-outlined:not(.ant-select-customize-input)\n .ant-select-selector {\n border: none;\n }\n .roundbox {\n display: flex;\n width: 18px;\n height: 18px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n border-radius: 18px;\n background: #fff;\n box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.1);\n left: 359px;\n position: absolute;\n border-radius: 18px;\n background: #fff;\n box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.1);\n top: 16px;\n }\n .ant-select-clear {\n top: 40% !important;\n font-size: 18px !important;\n }\n"])));
10642
10843
 
10643
10844
  var PAGE_SIZE_OPTIONS$1 = [50, 100, 150];
10644
10845
  var MAX_PAGES_TO_SHOW$1 = 5;
@@ -10724,25 +10925,20 @@ var ReturnPagination = function ReturnPagination(_ref) {
10724
10925
  }, React.createElement(NextIcon, null)))));
10725
10926
  };
10726
10927
 
10727
- var _templateObject$21, _templateObject2$1w;
10928
+ var _templateObject$22, _templateObject2$1w;
10728
10929
  var _excluded$5 = ["count"];
10729
10930
  var ReturnAfterTable = function ReturnAfterTable() {
10730
10931
  var _useReturnAfterOrderD = useReturnAfterOrderData(),
10932
+ returnAfterOrder = _useReturnAfterOrderD[0],
10731
10933
  setReturnOrderData = _useReturnAfterOrderD[1];
10732
10934
  var _useLoading = useLoading(),
10733
10935
  setLoading = _useLoading[1];
10734
10936
  var _useAtom = useAtom(filtersReducerReturnAtom),
10735
10937
  state = _useAtom[0];
10938
+ var _useCallApiAgain = useCallApiAgain(),
10939
+ callApi = _useCallApiAgain[0];
10736
10940
  var filters = state['x-filters'],
10737
10941
  pagination = state['x-pagination'];
10738
- var splitPath = function splitPath(str) {
10739
- var _str$split;
10740
- var parts = str == null || (_str$split = str.split('/')) == null ? void 0 : _str$split.filter(function (part) {
10741
- return part !== '';
10742
- }); // Filter out empty parts
10743
- return parts;
10744
- };
10745
- var paths = splitPath(location.pathname);
10746
10942
  var _UsePaginationReturnD = UsePaginationReturnData(),
10747
10943
  paginationObj = _UsePaginationReturnD[0];
10748
10944
  var _useState = useState(1),
@@ -10752,7 +10948,6 @@ var ReturnAfterTable = function ReturnAfterTable() {
10752
10948
  setItemsPerPage = _useItemsPerReturnPag[1];
10753
10949
  var _UsePaginationData = UsePaginationData(),
10754
10950
  setPaginationObject = _UsePaginationData[1];
10755
- console.log(paths, 'paths');
10756
10951
  var page = paginationObj.page,
10757
10952
  total = paginationObj.total;
10758
10953
  var handlePageChange = function handlePageChange(page) {
@@ -10765,13 +10960,18 @@ var ReturnAfterTable = function ReturnAfterTable() {
10765
10960
  endpoint: '/return_orders/?skip_filters=0',
10766
10961
  method: 'GET',
10767
10962
  filters: filters,
10768
- pagination: pagination
10963
+ pagination: pagination,
10964
+ performAction: false
10769
10965
  }),
10770
10966
  fetchedReturnOrderData = _useApiHook.data,
10771
- staticDataLoading = _useApiHook.loading,
10967
+ loading = _useApiHook.loading,
10968
+ setShouldPerformAction = _useApiHook.setShouldPerformAction,
10772
10969
  paginationData = _useApiHook.paginationData;
10773
10970
  useEffect(function () {
10774
- setLoading(staticDataLoading);
10971
+ callApi ? setShouldPerformAction(true) : setShouldPerformAction(false);
10972
+ }, [callApi]);
10973
+ useEffect(function () {
10974
+ setLoading(loading);
10775
10975
  if (fetchedReturnOrderData && fetchedReturnOrderData != null && fetchedReturnOrderData.data) {
10776
10976
  setReturnOrderData(fetchedReturnOrderData == null ? void 0 : fetchedReturnOrderData.data);
10777
10977
  if (paginationData !== null) {
@@ -10785,7 +10985,7 @@ var ReturnAfterTable = function ReturnAfterTable() {
10785
10985
  });
10786
10986
  }
10787
10987
  }
10788
- }, [fetchedReturnOrderData, staticDataLoading]);
10988
+ }, [fetchedReturnOrderData, loading, returnAfterOrder]);
10789
10989
  return React.createElement("div", null, React.createElement(DashBoardWrapper$2, null, React.createElement("div", {
10790
10990
  className: "Tableconatiner"
10791
10991
  }, React.createElement(Container$17, null, React.createElement(ReturnOrderFilter, null), React.createElement(OrderTable, null), total > 0 && React.createElement(ReturnPagination, {
@@ -10796,13 +10996,13 @@ var ReturnAfterTable = function ReturnAfterTable() {
10796
10996
  onItemsPerPageChange: handleItemsPerPageChange
10797
10997
  })))));
10798
10998
  };
10799
- var Container$17 = /*#__PURE__*/styled.div(_templateObject$21 || (_templateObject$21 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n /* top: -30px; */\n"])));
10999
+ var Container$17 = /*#__PURE__*/styled.div(_templateObject$22 || (_templateObject$22 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n /* top: -30px; */\n"])));
10800
11000
  var DashBoardWrapper$2 = /*#__PURE__*/styled.section(_templateObject2$1w || (_templateObject2$1w = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .Tableconatiner {\n border-radius: 12px;\n background: #fff;\n box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);\n display: block;\n padding: 15px 20px;\n }\n .headerWrap,\n .tableData,\n .styleCovered {\n transition: all ease 0.5s;\n }\n &.stickyTableHead {\n h2 {\n font-size: 21px;\n }\n .headerWrap {\n height: 84px;\n padding: 10px;\n border-radius: 0px 0px 15px 15px;\n > div {\n position: relative;\n z-index: 10;\n }\n }\n .styleCovered {\n margin-top: -32px;\n width: 67%;\n float: right;\n gap: 5px;\n padding-right: 11px;\n\n li {\n padding: 4px 10px 5px 5px;\n gap: 5px;\n .svgCover {\n width: 30px;\n height: 30px;\n svg {\n height: auto;\n width: 58%;\n }\n }\n .countDigit {\n font-size: 19px;\n }\n }\n .countMess {\n font-size: 13px;\n }\n }\n .dmsBulkFilter {\n min-height: unset;\n gap: 4px;\n > div {\n padding: 4px 12px;\n label {\n font-size: 11px;\n }\n }\n }\n\n .StyledFilterList {\n gap: 4px;\n li {\n height: 29px;\n padding: 3px 8px;\n gap: 4px;\n .StyledFilterBtnIcon {\n width: 20px;\n height: 20px;\n svh {\n width: 10px;\n height: auto;\n }\n }\n .StyledFilterBtnLabel {\n font-size: 13px;\n }\n }\n }\n .StyledFilterLabel {\n padding-left: 10px;\n span {\n font-size: 13px;\n }\n }\n .cardcontainer.tableData {\n max-height: calc(100vh - 310px);\n min-height: calc(100vh - 310px);\n }\n\n .tableData {\n max-height: calc(100vh - 320px);\n min-height: calc(100vh - 320px);\n\n margin-top: 8px;\n thead {\n position: sticky;\n top: 0;\n z-index: 9;\n th {\n font-size: 13px;\n padding: 2px 15px;\n }\n }\n }\n }\n"])));
10801
11001
 
10802
11002
  var _templateObject2$1x;
10803
11003
  var StyledBulkItem = /*#__PURE__*/styled.div(_templateObject2$1x || (_templateObject2$1x = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 8px 12px;\n display: flex;\n align-items: center;\n /* border-right: 1px solid #d0d5dd; */\n gap: 8px;\n cursor: pointer;\n position: relative;\n\n @media screen and (max-width: 1030px) {\n padding: 8px 11px;\n }\n\n ul {\n margin: 0;\n padding: 0;\n list-style: none;\n box-sizing: border-box;\n top: 54px;\n }\n &:last-child {\n border-right: none;\n }\n &.active svg.arrowDown {\n transform: rotate(180deg);\n }\n label {\n color: #6a7378;\n text-align: center;\n font-family: 'Open Sans';\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 18px;\n cursor: pointer;\n }\n\n &.noPadding {\n padding: 0;\n }\n"])));
10804
11004
 
10805
- var _templateObject$22, _templateObject2$1y;
11005
+ var _templateObject$23, _templateObject2$1y;
10806
11006
  var SearchType = function SearchType() {
10807
11007
  var _useState = useState(''),
10808
11008
  searchText = _useState[0],
@@ -10817,7 +11017,7 @@ var SearchType = function SearchType() {
10817
11017
  onChange: handleInputChange
10818
11018
  }));
10819
11019
  };
10820
- var Search = /*#__PURE__*/styled.div(_templateObject$22 || (_templateObject$22 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n svg {\n position: absolute;\n left: 12px;\n top: 50%;\n transform: translateY(-50%);\n }\n"])));
11020
+ var Search = /*#__PURE__*/styled.div(_templateObject$23 || (_templateObject$23 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n svg {\n position: absolute;\n left: 12px;\n top: 50%;\n transform: translateY(-50%);\n }\n"])));
10821
11021
  var SearchInput = /*#__PURE__*/styled.input(_templateObject2$1y || (_templateObject2$1y = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-radius: 20px;\n border: 1px solid #e0e2e7;\n background: #fff;\n box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);\n display: flex;\n padding: 8.5px 12px;\n align-items: center;\n gap: 8px;\n align-self: stretch;\n padding-left: 39px;\n"])));
10822
11022
 
10823
11023
  var BulkFilter = function BulkFilter() {
@@ -10892,14 +11092,14 @@ var Filters = function Filters() {
10892
11092
  return React.createElement(React.Fragment, null, React.createElement(StyledFiter, null, React.createElement(StyledFIlterELements, null, React.createElement(StyledTableFilter, null)), React.createElement(BulkFilter, null)));
10893
11093
  };
10894
11094
 
10895
- var ReturnTable$1 = function ReturnTable(_ref) {
10896
- var loadingskeleton = _ref.loadingskeleton;
11095
+ var ReturnTable$1 = function ReturnTable() {
10897
11096
  var _useClientData = useClientData(),
10898
11097
  clientData = _useClientData[0];
10899
11098
  var _useState = useState([]),
10900
11099
  updatedData = _useState[0],
10901
11100
  setUpdatedData = _useState[1];
10902
11101
  var _useLoading = useLoading(),
11102
+ statsLoading = _useLoading[0],
10903
11103
  setLoading = _useLoading[1];
10904
11104
  var _useOrderStaticData = useOrderStaticData(),
10905
11105
  setOrderStaticData = _useOrderStaticData[1];
@@ -10925,19 +11125,19 @@ var ReturnTable$1 = function ReturnTable(_ref) {
10925
11125
  useEffect(function () {
10926
11126
  var updatedClientData = clientData == null ? void 0 : clientData.map(function (client) {
10927
11127
  var matchingCustomer = customers == null ? void 0 : customers.find(function (customer) {
10928
- return (customer == null ? void 0 : customer.id) === (client == null ? void 0 : client.customer_id);
11128
+ return (customer == null ? void 0 : customer.customer_id) === (client == null ? void 0 : client.customer_id);
10929
11129
  });
10930
11130
  return _extends({}, client, {
10931
- uuid: matchingCustomer ? matchingCustomer == null ? void 0 : matchingCustomer.uuid : null
11131
+ account_number: matchingCustomer ? matchingCustomer == null ? void 0 : matchingCustomer.account_number : null
10932
11132
  });
10933
11133
  });
10934
11134
  setUpdatedData(updatedClientData);
10935
11135
  }, [customers, clientData]);
10936
11136
  //handle Redirect
10937
- var handleRedirect = function handleRedirect(customerName, customerId, customerUuid) {
11137
+ var handleRedirect = function handleRedirect(customerName, customerId, account_number) {
10938
11138
  localStorage.setItem('clientName', customerName);
10939
11139
  localStorage.setItem('clientId', customerId == null ? void 0 : customerId.toString());
10940
- localStorage.setItem('uuid', customerUuid);
11140
+ localStorage.setItem('account_number', account_number);
10941
11141
  if (customerId) {
10942
11142
  dispatch({
10943
11143
  type: 'SET_CLIENT_FILTER',
@@ -10953,12 +11153,13 @@ var ReturnTable$1 = function ReturnTable(_ref) {
10953
11153
  payload: []
10954
11154
  });
10955
11155
  }
10956
- var selectedClientString = customerName == null ? void 0 : customerName.replace(/\s+/g, '-');
10957
- navigate("filter/" + selectedClientString);
11156
+ navigate("filter/" + customerId);
11157
+ //forlocal
11158
+ // navigate(`/filter/${customerId}`);
10958
11159
  };
10959
11160
  return React.createElement(React.Fragment, null, React.createElement(StyledTableWrapper$2, {
10960
11161
  id: "tableScrolling"
10961
- }, React.createElement(StyledTable$3, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", null, "Trading Name"), React.createElement("th", null, "Client"), React.createElement("th", null, "Orders"), React.createElement("th", null, "Products"), React.createElement("th", null, "RTS"), React.createElement("th", null, "Pending"), React.createElement("th", null, "Dispose"), React.createElement("th", null, "Re-allocate"), React.createElement("th", null, "Re-Del"), React.createElement("th", null, "Recycle"), React.createElement("th", null, "Unknown"))), React.createElement("tbody", null, loadingskeleton ? React.createElement("tr", null, React.createElement("td", {
11162
+ }, React.createElement(StyledTable$3, null, React.createElement("thead", null, React.createElement("tr", null, React.createElement("th", null, "Trading Name"), React.createElement("th", null, "Client"), React.createElement("th", null, "Orders"), React.createElement("th", null, "Products"), React.createElement("th", null, "RTS"), React.createElement("th", null, "Pending"), React.createElement("th", null, "Dispose"), React.createElement("th", null, "Re-allocate"), React.createElement("th", null, "Re-Del"), React.createElement("th", null, "Recycle"), React.createElement("th", null, "Unknown"))), React.createElement("tbody", null, statsLoading ? React.createElement("tr", null, React.createElement("td", {
10962
11163
  colSpan: 11
10963
11164
  }, React.createElement(Skeleton, {
10964
11165
  active: true
@@ -10969,35 +11170,88 @@ var ReturnTable$1 = function ReturnTable(_ref) {
10969
11170
  key: index
10970
11171
  }, React.createElement("td", null, key == null ? void 0 : key.trading_as), React.createElement("td", {
10971
11172
  onClick: function onClick() {
10972
- return handleRedirect(key == null ? void 0 : key.customer_name, key == null ? void 0 : key.customer_id, key == null ? void 0 : key.uuid);
11173
+ return handleRedirect(key == null ? void 0 : key.customer_name, key == null ? void 0 : key.customer_id, key == null ? void 0 : key.account_number);
10973
11174
  },
10974
11175
  style: {
10975
11176
  color: '#0099ff',
10976
11177
  fontWeight: 600,
10977
11178
  cursor: 'pointer'
10978
11179
  }
10979
- }, React.createElement("span", null, key == null ? void 0 : key.customer_name)), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.return_orders))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.return_order_products))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.RTS))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.PENDING))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.DISPOSE))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key['RE-ALLOCATE']), ' ')), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key['RE-DEL']))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.RECYCLE))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.UNKNOWN))));
11180
+ }, React.createElement("span", null, key == null ? void 0 : key.customer_name)), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.orders))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.return_order_products))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.RTS))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.PENDING))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.DISPOSE))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key['RE-ALLOCATE']), ' ')), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key['RE-DEL']))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.RECYCLE))), React.createElement("td", null, React.createElement(ColumStyle, null, React.createElement(GreyBox, null, key == null ? void 0 : key.UNKNOWN))));
10980
11181
  })))));
10981
11182
  };
10982
11183
 
10983
- var _templateObject$23, _templateObject2$1z, _templateObject3$T;
11184
+ // let todayDate = new Date();
11185
+ var initialState$3 = {
11186
+ 'x-filters': [
11187
+ // {
11188
+ // field: 'action_date',
11189
+ // op: '>=',
11190
+ // value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T00:00:00+00:00`,
11191
+ // },
11192
+ // {
11193
+ // field: 'action_date',
11194
+ // op: '<=',
11195
+ // value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T23:59:59+00:00`,
11196
+ // },
11197
+ // { field: 'status', op: 'count', value: '' },
11198
+ ],
11199
+ 'x-pagination': {
11200
+ page: 1,
11201
+ per_page: 50
11202
+ }
11203
+ };
11204
+ var filterReducer$2 = function filterReducer(state, action) {
11205
+ switch (action.type) {
11206
+ case 'SET_PAGE':
11207
+ return _extends({}, state, {
11208
+ 'x-pagination': _extends({}, state['x-pagination'], {
11209
+ page: action.payload
11210
+ })
11211
+ });
11212
+ case 'SET_PERPAGE':
11213
+ return _extends({}, state, {
11214
+ 'x-pagination': _extends({}, state['x-pagination'], {
11215
+ per_page: action.payload
11216
+ })
11217
+ });
11218
+ case 'CLEAR_FILTERS':
11219
+ return _extends({}, state);
11220
+ case 'CLEAR_ALL_FILTER':
11221
+ return _extends({}, state);
11222
+ default:
11223
+ return state;
11224
+ }
11225
+ };
11226
+ var filtersStateAtom$2 = /*#__PURE__*/atom(initialState$3);
11227
+ var overviewfiltersReducerAtom = /*#__PURE__*/atom(function (get) {
11228
+ return get(filtersStateAtom$2);
11229
+ }, function (get, set, action) {
11230
+ return set(filtersStateAtom$2, filterReducer$2(get(filtersStateAtom$2), action));
11231
+ });
11232
+
11233
+ var _templateObject$24, _templateObject2$1z, _templateObject3$T;
11234
+ // import { notification } from 'antd';
11235
+ // import Pagination from './table-view/Pagination';
10984
11236
  // import Pagination from './table-view/Pagination';
10985
11237
  // import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
10986
11238
  function ReturnMainTable() {
10987
- // const [state] = useAtom(overviewfiltersReducerAtom);
10988
- // const [paginationObj] = UsePaginationData();
11239
+ var _useAtom = useAtom(overviewfiltersReducerAtom),
11240
+ state = _useAtom[0];
11241
+ // const [paginationObj] = UsePaginationOverviewData();
10989
11242
  // const [, setCurrentPage] = useState(1);
10990
- // const [itemsPerPage, setItemsPerPage] = useItemsPerPage();
10991
- // const { 'x-pagination': pagination } = state;
11243
+ // const [itemsPerPage, setItemsPerPage] = useItemsPerOverviewPage();
11244
+ var pagination = state['x-pagination'];
10992
11245
  // const { page, total } = paginationObj;
10993
11246
  // const [selectedClient] = useTableName();
10994
- // const [, setPaginationObject] = UsePaginationData();
10995
11247
  var _useStickyStatus = useStickyStatus(),
10996
11248
  isScrolled = _useStickyStatus[0];
10997
11249
  var _useLoading = useLoading(),
10998
11250
  setLoading = _useLoading[1];
10999
11251
  var _useClientData = useClientData(),
11000
11252
  setClientData = _useClientData[1];
11253
+ var _useTableName = useTableName(),
11254
+ tableName = _useTableName[0];
11001
11255
  // const handlePageChange = (page: number) => {
11002
11256
  // setCurrentPage(page);
11003
11257
  // };
@@ -11005,19 +11259,15 @@ function ReturnMainTable() {
11005
11259
  // setItemsPerPage(itemsPerPage);
11006
11260
  // };
11007
11261
  var _useApiHook = useApiHook({
11008
- endpoint: "/return_orders/get/client-returns/",
11262
+ endpoint: "/return_orders/stats/",
11009
11263
  method: 'GET',
11010
11264
  //@ts-ignore
11011
- pagination: {
11012
- page: 1,
11013
- per_page: 200,
11014
- is_pagination: false
11015
- }
11265
+ pagination: pagination
11016
11266
  }),
11017
11267
  fetchedClientData = _useApiHook.data,
11018
- staticDataLoading = _useApiHook.loading;
11268
+ statsDataLoading = _useApiHook.loading;
11019
11269
  useEffect(function () {
11020
- setLoading(staticDataLoading);
11270
+ setLoading(statsDataLoading);
11021
11271
  if (fetchedClientData && fetchedClientData.data) {
11022
11272
  var result = fetchedClientData == null ? void 0 : fetchedClientData.data;
11023
11273
  setClientData(result);
@@ -11031,33 +11281,32 @@ function ReturnMainTable() {
11031
11281
  // });
11032
11282
  // }
11033
11283
  }
11034
- }, [staticDataLoading]);
11035
- var getClient = localStorage.getItem('clientName');
11284
+ }, [statsDataLoading]);
11036
11285
  return React.createElement(React.Fragment, null, React.createElement(DashBoardWrapper$3, {
11037
11286
  className: " " + (isScrolled ? 'stickyTableHead' : '')
11038
11287
  }, React.createElement("div", {
11039
11288
  className: "Tableconatiner"
11040
- }, React.createElement(HeaderFilter, null), React.createElement(Container$18, null, React.createElement(Row$7, null, React.createElement(Text$8, null, "Client Return"), getClient ? React.createElement(ReturnFilter, null) : React.createElement(Filters, null)), React.createElement(ReturnTable$1, null)))));
11289
+ }, React.createElement(HeaderFilter, null), React.createElement(Container$18, null, React.createElement(Row$7, null, React.createElement(Text$8, null, "Client Return"), tableName ? React.createElement(ReturnFilter, null) : React.createElement(Filters, null)), React.createElement(ReturnTable$1, null)))));
11041
11290
  }
11042
- var Row$7 = /*#__PURE__*/styled.div(_templateObject$23 || (_templateObject$23 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n"])));
11291
+ var Row$7 = /*#__PURE__*/styled.div(_templateObject$24 || (_templateObject$24 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n"])));
11043
11292
  var Container$18 = /*#__PURE__*/styled.div(_templateObject2$1z || (_templateObject2$1z = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n top: -46px;\n"])));
11044
11293
  var DashBoardWrapper$3 = /*#__PURE__*/styled.section(_templateObject3$T || (_templateObject3$T = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .Tableconatiner {\n border-radius: 12px;\n background: #fff;\n box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);\n display: block;\n padding: 15px 20px;\n }\n .headerWrap,\n .tableData,\n .styleCovered {\n transition: all ease 0.5s;\n }\n &.stickyTableHead {\n h2 {\n font-size: 21px;\n }\n .headerWrap {\n height: 84px;\n padding: 10px;\n border-radius: 0px 0px 15px 15px;\n > div {\n position: relative;\n z-index: 10;\n }\n }\n .styleCovered {\n margin-top: -32px;\n width: 67%;\n float: right;\n gap: 5px;\n padding-right: 11px;\n\n li {\n padding: 4px 10px 5px 5px;\n gap: 5px;\n .svgCover {\n width: 30px;\n height: 30px;\n svg {\n height: auto;\n width: 58%;\n }\n }\n .countDigit {\n font-size: 19px;\n }\n }\n .countMess {\n font-size: 13px;\n }\n }\n .dmsBulkFilter {\n min-height: unset;\n gap: 4px;\n > div {\n padding: 4px 12px;\n label {\n font-size: 11px;\n }\n }\n }\n\n .StyledFilterList {\n gap: 4px;\n li {\n height: 29px;\n padding: 3px 8px;\n gap: 4px;\n .StyledFilterBtnIcon {\n width: 20px;\n height: 20px;\n svh {\n width: 10px;\n height: auto;\n }\n }\n .StyledFilterBtnLabel {\n font-size: 13px;\n }\n }\n }\n .StyledFilterLabel {\n padding-left: 10px;\n span {\n font-size: 13px;\n }\n }\n .cardcontainer.tableData {\n max-height: calc(100vh - 310px);\n min-height: calc(100vh - 310px);\n }\n\n .tableData {\n max-height: calc(100vh - 320px);\n min-height: calc(100vh - 320px);\n\n margin-top: 8px;\n thead {\n position: sticky;\n top: 0;\n z-index: 9;\n th {\n font-size: 13px;\n padding: 2px 15px;\n }\n }\n }\n }\n"])));
11045
11294
 
11046
- var _templateObject$24, _templateObject2$1A;
11047
- var HeaderWrapper = /*#__PURE__*/styled.div(_templateObject$24 || (_templateObject$24 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n padding: 20px;\n gap: 10px;\n border-radius: 0px 0px 30px 30px;\n background: #313130;\n height: 151px;\n background: url(./assets/bgBlack.png) no-repeat;\n background-size: cover;\n background-color: #000000d9;\n"])));
11295
+ var _templateObject$25, _templateObject2$1A;
11296
+ var HeaderWrapper = /*#__PURE__*/styled.div(_templateObject$25 || (_templateObject$25 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n padding: 20px;\n gap: 10px;\n border-radius: 0px 0px 30px 30px;\n background: #313130;\n height: 151px;\n background: url(./assets/bgBlack.png) no-repeat;\n background-size: cover;\n background-color: #000000d9;\n"])));
11048
11297
  var StyledFlex = /*#__PURE__*/styled.div(_templateObject2$1A || (_templateObject2$1A = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n"])));
11049
11298
 
11050
- var _templateObject$25;
11299
+ var _templateObject$26;
11051
11300
  var HeaderTitle = function HeaderTitle(props) {
11052
11301
  return React.createElement(React.Fragment, null, React.createElement(Title$7, null, props.title));
11053
11302
  };
11054
- var Title$7 = /*#__PURE__*/styled.h2(_templateObject$25 || (_templateObject$25 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0px;\n padding: 0px;\n color: #fff;\n font-size: 26px;\n font-style: normal;\n font-weight: 700;\n line-height: 36px;\n text-transform: uppercase;\n margin-bottom: 8px;\n"])));
11303
+ var Title$7 = /*#__PURE__*/styled.h2(_templateObject$26 || (_templateObject$26 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0px;\n padding: 0px;\n color: #fff;\n font-size: 26px;\n font-style: normal;\n font-weight: 700;\n line-height: 36px;\n text-transform: uppercase;\n margin-bottom: 8px;\n"])));
11055
11304
 
11056
- var _templateObject$26, _templateObject2$1B;
11305
+ var _templateObject$27, _templateObject2$1B;
11057
11306
  function Breadcrumb(props) {
11058
11307
  return React.createElement(BreadcrumbContainer, null, React.createElement(BreadcrumbList, null, props.title || ''), React.createElement(BreadcrumbList, null, props.subtitle || ''), props.subPart && React.createElement(React.Fragment, null, React.createElement(BreadcrumbList, null, props.subPart)));
11059
11308
  }
11060
- var BreadcrumbContainer = /*#__PURE__*/styled.div(_templateObject$26 || (_templateObject$26 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n"])));
11309
+ var BreadcrumbContainer = /*#__PURE__*/styled.div(_templateObject$27 || (_templateObject$27 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n"])));
11061
11310
  var BreadcrumbList = /*#__PURE__*/styled.span(_templateObject2$1B || (_templateObject2$1B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: #edebe8;\n font-family: 'Open Sans', sans-serif;\n font-size: 13px;\n font-style: normal;\n font-weight: 400;\n line-height: 16px;\n"])));
11062
11311
 
11063
11312
  var RouterHeader = function RouterHeader(_ref) {
@@ -11080,20 +11329,16 @@ var RouterHeader = function RouterHeader(_ref) {
11080
11329
  })))));
11081
11330
  };
11082
11331
 
11083
- // import { filtersReducerAtom } from './components/order-daily-overview/header-filters/filterStore';
11084
11332
  function ReturnClient() {
11085
- var _selectedClientString;
11086
11333
  notification.config({
11087
11334
  top: 80
11088
11335
  });
11089
11336
  var LoadingMessage = function LoadingMessage() {
11090
11337
  return React.createElement("div", null, "Loading...");
11091
11338
  };
11092
- var _useTableName = useTableName(),
11093
- selectedClient = _useTableName[0];
11339
+ var _useIdForTableName = useIdForTableName(),
11340
+ selectedClientId = _useIdForTableName[0];
11094
11341
  var navigate = useNavigate();
11095
- var selectedClientString = selectedClient == null ? void 0 : selectedClient.replace(/\s+/g, '-');
11096
- selectedClientString = (_selectedClientString = selectedClientString) == null ? void 0 : _selectedClientString.toLowerCase();
11097
11342
  var _useCustomerData = useCustomerData(),
11098
11343
  setCustomers = _useCustomerData[1];
11099
11344
  var _useActionType = useActionType(),
@@ -11102,7 +11347,14 @@ function ReturnClient() {
11102
11347
  setLocationData = _useLocationData[1];
11103
11348
  var _useStatusOrderData = useStatusOrderData(),
11104
11349
  setStatusOfOrders = _useStatusOrderData[1];
11105
- // const [dispatchvalue] = useAtom(filtersReducerAtom);
11350
+ var _useAssignData = useAssignData(),
11351
+ setAssignData = _useAssignData[1];
11352
+ var _useActionTypeOptions = useActionTypeOptions(),
11353
+ setActionTypeOptions = _useActionTypeOptions[1];
11354
+ var _useLocationOptions = useLocationOptions(),
11355
+ setLocationOptions = _useLocationOptions[1];
11356
+ var _useTableName = useTableName(),
11357
+ setTableName = _useTableName[1];
11106
11358
  var splitPath = function splitPath(str) {
11107
11359
  var _str$split;
11108
11360
  var parts = str == null || (_str$split = str.split('/')) == null ? void 0 : _str$split.filter(function (part) {
@@ -11115,23 +11367,25 @@ function ReturnClient() {
11115
11367
  if (paths[paths.length - 1] === 'returnclient') {
11116
11368
  localStorage.removeItem('clientName');
11117
11369
  localStorage.removeItem('clientId');
11118
- localStorage.removeItem('uuid');
11119
- // dispatch({ type: 'CLEAR_CLIENT' });
11370
+ localStorage.removeItem('account_number');
11371
+ setActionTypeOptions([]);
11372
+ setLocationOptions([]);
11373
+ setTableName('');
11120
11374
  }
11121
11375
  }, [location.pathname]);
11122
11376
  useEffect(function () {
11123
- if (selectedClient) {
11124
- var _selectedClientString2 = selectedClient.replace(/\s+/g, '-');
11125
- navigate("filter/" + _selectedClientString2);
11377
+ if (selectedClientId) {
11378
+ navigate("filter/" + selectedClientId);
11126
11379
  }
11127
- }, [selectedClient]);
11380
+ }, [selectedClientId]);
11128
11381
  //API for client data
11129
11382
  var _useApiHook = useApiHook({
11130
- endpoint: "/customers/",
11383
+ endpoint: "/return_orders/customers/",
11131
11384
  method: 'GET',
11132
11385
  //@ts-ignore
11133
11386
  pagination: {
11134
- is_pagination: false
11387
+ page: 1,
11388
+ per_page: 50
11135
11389
  }
11136
11390
  }),
11137
11391
  fetchedCustomerData = _useApiHook.data,
@@ -11161,13 +11415,16 @@ function ReturnClient() {
11161
11415
  }, [loading]);
11162
11416
  useEffect(function () {
11163
11417
  if (fetchedStaticData && fetchedStaticData != null && fetchedStaticData.data) {
11164
- var _fetchedStaticData$da, _fetchedStaticData$da2;
11418
+ var _fetchedStaticData$da, _fetchedStaticData$da2, _fetchedStaticData$da3;
11165
11419
  setActionType(fetchedStaticData == null || (_fetchedStaticData$da = fetchedStaticData.data) == null ? void 0 : _fetchedStaticData$da.flatMap(function (i) {
11166
11420
  return i == null ? void 0 : i.order_product_return_action;
11167
11421
  }));
11168
11422
  setStatusOfOrders(fetchedStaticData == null || (_fetchedStaticData$da2 = fetchedStaticData.data) == null ? void 0 : _fetchedStaticData$da2.flatMap(function (i) {
11169
11423
  return i == null ? void 0 : i.order_stock_alias;
11170
11424
  }));
11425
+ setAssignData(fetchedStaticData == null || (_fetchedStaticData$da3 = fetchedStaticData.data) == null ? void 0 : _fetchedStaticData$da3.flatMap(function (i) {
11426
+ return i == null ? void 0 : i.assign_client;
11427
+ }));
11171
11428
  }
11172
11429
  }, [actionLoading]);
11173
11430
  useEffect(function () {
@@ -11187,7 +11444,7 @@ function ReturnClient() {
11187
11444
  path: "order-return/:id",
11188
11445
  element: React.createElement(OrderView, null)
11189
11446
  }), React.createElement(Route, {
11190
- path: "filter/:clientName",
11447
+ path: "filter/:clientId",
11191
11448
  element: React.createElement(ReturnTable, null)
11192
11449
  }))));
11193
11450
  }