@bjsdistribution/dms-client-return 0.1.97-prod → 0.1.98-prod
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/ChevronDownIcon.js +26 -0
- package/dist/assets/icons/ChevronDownIcon.js.map +1 -0
- package/dist/common/modals/order-action-modal/OrderActionModal.js.map +1 -1
- package/dist/common/modals/order-action-modal/footer/OrderActionFooter.js.map +1 -1
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.js +7 -7
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.js.map +1 -1
- package/dist/components/order-view/order-actions/actions/split-order/SplitOrderTable.js +222 -55
- package/dist/components/order-view/order-actions/actions/split-order/SplitOrderTable.js.map +1 -1
- package/dist/components/order-view/order-actions/actions/split-order/index.js +50 -37
- package/dist/components/order-view/order-actions/actions/split-order/index.js.map +1 -1
- package/dist/components/order-view/products-info/collapsed-content/index.js +1 -1
- package/dist/components/order-view/products-info/collapsed-content/index.js.map +1 -1
- package/dist/components/order-view/products-info/index.js +36 -36
- package/dist/components/order-view/products-info/index.js.map +1 -1
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.js +333 -162
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.js.map +1 -1
- package/dist/components/order-view/return-client-products/product-table/palletGrouping.js +47 -0
- package/dist/components/order-view/return-client-products/product-table/palletGrouping.js.map +1 -0
- package/dist/components/order-view/store.js +164 -159
- package/dist/components/order-view/store.js.map +1 -1
- package/dist/types/common/modals/order-action-modal/OrderActionModal.d.ts +2 -1
- package/dist/types/common/modals/order-action-modal/footer/OrderActionFooter.d.ts +1 -1
- package/dist/types/components/order-view/return-client-products/product-table/palletGrouping.d.ts +23 -0
- package/dist/types/components/order-view/store.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/components/order-view/order-actions/actions/split-order/index.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';\nimport styled from 'styled-components';\nimport SplitOrderTable from './SplitOrderTable';\nimport { useCurrentAction, useOrderDetails, useOrderId } from '../../../store';\nimport { useApiHook } from '@bjsdistribution/dms-component-library';\nimport { ApiResponse } from '../../../types';\n\nimport { useSelectedSplit, useSplitOrderPayload } from '../../store';\nimport { notification } from 'antd';\nimport { useNavigate } from 'react-router-dom';\n\nfunction SplitOrder() {\n const [, setCurrentAction] = useCurrentAction();\n const [orderDetails] = useOrderDetails();\n const orderRecipient = orderDetails?.order_recipient;\n const infoText = `${orderRecipient?.recipient_name}, ${orderRecipient?.postcode}`;\n const [orderId, setOrderID] = useOrderId();\n const [payload] = useSplitOrderPayload();\n const [seledtedSplitOrder, setSelectedSplit] = useSelectedSplit();\n\n const onClose = () => {\n setCurrentAction(undefined);\n };\n const navigate = useNavigate();\n const {\n data: response,\n setShouldPerformAction: setPerformAction,\n } = useApiHook<{\n data: ApiResponse[];\n }>({\n endpoint: `/v1/return/split/${orderId}`,\n method: 'POST',\n body: payload,\n performAction: false,\n });\n\n const onSubmitSplitOrder = () => {\n if (orderId) {\n setPerformAction(true);\n }\n };\n //@ts-ignore\n const newId = response?.data?.new_order;\n useEffect(() => {\n //@ts-ignore\n if (response?.code === 200) {\n const currentPath = location.pathname\n .split('/')\n .slice(0, -1)\n .join('/');\n console.log(currentPath, 'currentPath');\n navigate(`${currentPath}/${newId}`);\n setOrderID(newId);\n setSelectedSplit([]);\n notification.success({\n message: 'Success',\n description:\n //@ts-ignore\n response?.message || 'Sucess',\n });\n setCurrentAction(undefined);\n setSelectedSplit([]);\n }\n }, [response]);\n\n const isSubmitDisabled = () => {\n if (seledtedSplitOrder?.length > 0) {\n return !seledtedSplitOrder;\n }\n return true;\n };\n\n return (\n <OrderActionModal\n headerTitle=\"Split Order\"\n showAdditionalInfo\n infoText={infoText}\n onCloseHeader={onClose}\n onSubmit={onSubmitSplitOrder}\n submitBtnTitle=\"Split Order\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/order-view/order-actions/actions/split-order/index.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';\nimport styled from 'styled-components';\nimport SplitOrderTable from './SplitOrderTable';\nimport { useCurrentAction, useOrderDetails, useOrderId } from '../../../store';\nimport { useApiHook } from '@bjsdistribution/dms-component-library';\nimport { ApiResponse } from '../../../types';\n\nimport { useSelectedSplit, useSplitOrderPayload } from '../../store';\nimport { notification, Spin } from 'antd';\nimport { useNavigate } from 'react-router-dom';\n\nfunction SplitOrder() {\n const [, setCurrentAction] = useCurrentAction();\n const [orderDetails] = useOrderDetails();\n const orderRecipient = orderDetails?.order_recipient;\n const infoText = `${orderRecipient?.recipient_name}, ${orderRecipient?.postcode}`;\n const [orderId, setOrderID] = useOrderId();\n const [payload] = useSplitOrderPayload();\n const [seledtedSplitOrder, setSelectedSplit] = useSelectedSplit();\n\n const onClose = () => {\n setCurrentAction(undefined);\n };\n const navigate = useNavigate();\n const {\n data: response,\n loading: splitLoading,\n setShouldPerformAction: setPerformAction,\n } = useApiHook<{\n data: ApiResponse[];\n }>({\n endpoint: `/v1/return/split/${orderId}`,\n method: 'POST',\n body: payload,\n performAction: false,\n });\n\n const onSubmitSplitOrder = () => {\n if (orderId) {\n setPerformAction(true);\n }\n };\n //@ts-ignore\n const newId = response?.data?.new_order;\n useEffect(() => {\n //@ts-ignore\n if (response?.code === 200) {\n const currentPath = location.pathname\n .split('/')\n .slice(0, -1)\n .join('/');\n console.log(currentPath, 'currentPath');\n navigate(`${currentPath}/${newId}`);\n setOrderID(newId);\n setSelectedSplit([]);\n notification.success({\n message: 'Success',\n description:\n //@ts-ignore\n response?.message || 'Sucess',\n });\n setCurrentAction(undefined);\n setSelectedSplit([]);\n }\n }, [response]);\n\n const isSubmitDisabled = () => {\n // Block re-submits while the split is in flight — it creates a new B number.\n if (splitLoading) {\n return true;\n }\n if (seledtedSplitOrder?.length > 0) {\n return !seledtedSplitOrder;\n }\n return true;\n };\n\n return (\n <OrderActionModal\n headerTitle=\"Split Order\"\n showAdditionalInfo\n infoText={infoText}\n onCloseHeader={onClose}\n onSubmit={onSubmitSplitOrder}\n submitBtnTitle={\n splitLoading ? (\n <SubmitLabel>\n <Spin size=\"small\" />\n Splitting...\n </SubmitLabel>\n ) : (\n 'Split Order'\n )\n }\n footerActions={\n <>\n {/* <CheckContainer>\n <label className=\"check\">\n <input type=\"checkbox\" />\n Force Split\n </label>\n </CheckContainer> */}\n </>\n }\n isSubmitDisabled={isSubmitDisabled()}\n >\n <ContentContainer>\n <SplitOrderTable />\n </ContentContainer>\n </OrderActionModal>\n );\n}\n\nconst SubmitLabel = styled.span`\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n /* The button label is light, so the default dark spinner would be invisible. */\n .ant-spin-dot-item {\n background-color: currentColor;\n }\n`;\n\nconst ContentContainer = styled.div`\n /* display: flex; */\n padding: 15px 12px;\n flex: 1 0 0;\n border-radius: 15px;\n background: white;\n display: flex;\n flex-direction: column;\n gap: 15px;\n overflow: auto;\n min-height: 500px;\n overflow-x: hidden;\n max-height: 500px;\n scrollbar-width: thin;\n`;\n\nexport default SplitOrder;\n"],"names":["SplitOrder","setCurrentAction","useCurrentAction","orderDetails","useOrderDetails","orderRecipient","infoText","orderId","setOrderID","useOrderId","payload","useSplitOrderPayload","seledtedSplitOrder","setSelectedSplit","useSelectedSplit","onClose","navigate","useNavigate","response","splitLoading","setPerformAction","useApiHook","onSubmitSplitOrder","newId","useEffect","currentPath","notification","jsx","OrderActionModal","jsxs","SubmitLabel","Spin","Fragment","ContentContainer","SplitOrderTable","styled"],"mappings":";;;;;;;;;;AAYA,SAASA,IAAa;AACpB,QAAM,CAAA,EAAGC,CAAgB,IAAIC,EAAA,GACvB,CAACC,CAAY,IAAIC,EAAA,GACjBC,IAAiBF,GAAc,iBAC/BG,IAAW,GAAG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;AAAA,MAAA,EAAA,CAEvB,IAEA;AAAA,MAGJ,eACE,gBAAAJ,EAAAK,GAAA,EAOA;AAAA,MAEF,kBApCEb,IACK,KAELP,GAAoB,SAAS,IACxB,CAACA,IAEH;AAAA,MAgCL,UAAA,gBAAAe,EAACM,GAAA,EACC,UAAA,gBAAAN,EAACO,GAAA,CAAA,CAAgB,EAAA,CACnB;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,MAAMJ,IAAcK,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWrBF,IAAmBE,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as o, jsx as s, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { SectionHeader as f } from "@bjsdistribution/dms-component-library";
|
|
3
3
|
import n from "styled-components";
|
|
4
|
-
import {
|
|
4
|
+
import { useReturnProductDetails as m } from "../../store.js";
|
|
5
5
|
import { WEIGHT_UNIT as u, VOLUME_UNIT_CONVERT as h } from "../../../../common/utils.js";
|
|
6
6
|
function z() {
|
|
7
7
|
const [t] = m(), r = (e, a) => e?.reduce((c, d) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/order-view/products-info/collapsed-content/index.tsx"],"sourcesContent":["import { SectionHeader } from '@bjsdistribution/dms-component-library';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/order-view/products-info/collapsed-content/index.tsx"],"sourcesContent":["import { SectionHeader } from '@bjsdistribution/dms-component-library';\nimport React from 'react';\nimport styled from 'styled-components';\nimport { useReturnProductDetails } from '../../store';\nimport { WEIGHT_UNIT, VOLUME_UNIT_CONVERT } from '../../../../common/utils';\n\nfunction CollapsedContent() {\n const [productsData] = useReturnProductDetails();\n\n const calculateTotal = (items: any[], field: 'cube' | 'weight') => {\n return items\n ?.reduce((total, item) => {\n const val = parseFloat(item?.[field]);\n return total + (isNaN(val) ? 0 : val);\n }, 0)\n .toFixed(2);\n };\n\n return (\n <Container>\n <SectionHeader label=\"Products\" />\n <Dimensions>Products to be Returned</Dimensions>\n\n {productsData?.length > 0 && (\n <>\n <Items style={{ display: 'flex' }}>\n Total: {calculateTotal(productsData, 'weight')}\n {WEIGHT_UNIT} / {calculateTotal(productsData, 'cube')}{VOLUME_UNIT_CONVERT}\n </Items>\n\n <Items style={{ display: 'flex' }}>\n Orders- {new Set(productsData?.map((item: any) => item?.order_id).filter((id: any) => id != null)).size} / Products- {productsData?.length}\n </Items>\n </>\n )}\n </Container>\n );\n}\n\nconst Dimensions = styled.span`\n color: #6a7378;\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 24px; /* 171.429% */\n`;\n\nconst Container = styled.div`\n display: flex;\n align-items: center;\n /* justify-content: space-between; */\n width: 100%;\n gap: 30px;\n`;\n\nconst Items = styled.span`\n font-family: 'Roboto', sans-serif;\n font-size: 14px;\n font-weight: 500;\n line-height: 24px;\n color: #8e8a85;\n text-transform: capitalize;\n color: #6a7378;\n`;\n\nexport default CollapsedContent;\n"],"names":["CollapsedContent","productsData","useReturnProductDetails","calculateTotal","items","field","total","item","val","Container","jsx","SectionHeader","Dimensions","jsxs","Fragment","Items","WEIGHT_UNIT","VOLUME_UNIT_CONVERT","id","styled"],"mappings":";;;;;AAMA,SAASA,IAAmB;AAC1B,QAAM,CAACC,CAAY,IAAIC,EAAA,GAEjBC,IAAiB,CAACC,GAAcC,MAC7BD,GACH,OAAO,CAACE,GAAOC,MAAS;AACxB,UAAMC,IAAM,WAAWD,IAAOF,CAAK,CAAC;AACpC,WAAOC,KAAS,MAAME,CAAG,IAAI,IAAIA;AAAA,EACnC,GAAG,CAAC,EACH,QAAQ,CAAC;AAGd,2BACGC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAA,EAAc,OAAM,WAAA,CAAW;AAAA,IAChC,gBAAAD,EAACE,KAAW,UAAA,0BAAA,CAAuB;AAAA,IAElCX,GAAc,SAAS,KACtB,gBAAAY,EAAAC,GAAA,EACE,UAAA;AAAA,MAAA,gBAAAD,EAACE,GAAA,EAAM,OAAO,EAAE,SAAS,UAAU,UAAA;AAAA,QAAA;AAAA,QACzBZ,EAAeF,GAAc,QAAQ;AAAA,QAC5Ce;AAAA,QAAY;AAAA,QAAIb,EAAeF,GAAc,MAAM;AAAA,QAAGgB;AAAA,MAAA,GACzD;AAAA,wBAECF,GAAA,EAAM,OAAO,EAAE,SAAS,UAAU,UAAA;AAAA,QAAA;AAAA,QACxB,IAAI,IAAId,GAAc,IAAI,CAACM,MAAcA,GAAM,QAAQ,EAAE,OAAO,CAACW,MAAYA,KAAM,IAAI,CAAC,EAAE;AAAA,QAAK;AAAA,QAAcjB,GAAc;AAAA,MAAA,EAAA,CACtI;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;AAEA,MAAMW,IAAaO,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQpBV,IAAYU,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQnBJ,IAAQI,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as e, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as D, useEffect as f } from "react";
|
|
3
3
|
import S from "./expanded-content/index.js";
|
|
4
|
-
import
|
|
4
|
+
import P from "./collapsed-content/index.js";
|
|
5
5
|
import v from "../../../common/expand-collapse/index.js";
|
|
6
|
-
import { useOrderDetails as O, useProductDetails as
|
|
7
|
-
import { useLoading as
|
|
8
|
-
import { useAxios as
|
|
9
|
-
import { Spin as
|
|
10
|
-
function
|
|
11
|
-
const [
|
|
6
|
+
import { useOrderDetails as L, useReturnProductDetails as O, useProductDetails as k } from "../store.js";
|
|
7
|
+
import { useLoading as w } from "../../order-daily-overview/store/store.js";
|
|
8
|
+
import { useAxios as m } from "@bjsdistribution/dms-component-library";
|
|
9
|
+
import { Spin as T, notification as F } from "antd";
|
|
10
|
+
function q({ locationloading: g }) {
|
|
11
|
+
const [x] = L(), r = x, [h, s] = D(!1), { fetchData: b } = m({
|
|
12
12
|
endpoint: `/v1/export/csv/${r?.id}`,
|
|
13
13
|
method: "POST"
|
|
14
|
-
}),
|
|
15
|
-
t.stopPropagation(), s(!0),
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
|
|
14
|
+
}), C = (t) => {
|
|
15
|
+
t.stopPropagation(), s(!0), b().then((i) => {
|
|
16
|
+
const u = i?.data?.url || i?.url;
|
|
17
|
+
if (u) {
|
|
18
|
+
const n = document.createElement("a");
|
|
19
|
+
n.href = u, n.download = `products_export_${r?.id}.csv`, document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
20
20
|
}
|
|
21
21
|
s(!1);
|
|
22
22
|
}).catch((i) => {
|
|
23
|
-
|
|
23
|
+
F.error({
|
|
24
24
|
message: "Failed to export csv",
|
|
25
25
|
description: i?.message || "Export error"
|
|
26
26
|
}), s(!1);
|
|
27
27
|
});
|
|
28
|
-
}, [, l] =
|
|
28
|
+
}, [, l] = O(), [, c] = k(), [, E] = w(), {
|
|
29
29
|
data: o,
|
|
30
30
|
loading: d,
|
|
31
|
-
fetchData:
|
|
32
|
-
} =
|
|
31
|
+
fetchData: p
|
|
32
|
+
} = m({
|
|
33
33
|
endpoint: `/v1/return/products/${r?.id}`,
|
|
34
34
|
method: "GET",
|
|
35
35
|
pagination: { is_pagination: !1 }
|
|
36
36
|
});
|
|
37
|
-
|
|
38
|
-
r?.id &&
|
|
39
|
-
}, [r.id]),
|
|
40
|
-
if (
|
|
37
|
+
f(() => {
|
|
38
|
+
r?.id && p();
|
|
39
|
+
}, [r.id]), f(() => {
|
|
40
|
+
if (E(d), o && o.data) {
|
|
41
41
|
const t = o.data;
|
|
42
|
-
t?.length > 0 ? l(t) : l([]);
|
|
42
|
+
t?.length > 0 ? (l(t), c(t)) : (l([]), c([]));
|
|
43
43
|
}
|
|
44
44
|
}, [o, d]);
|
|
45
|
-
const
|
|
45
|
+
const a = !o?.data || o?.data?.length === 0;
|
|
46
46
|
return /* @__PURE__ */ e(
|
|
47
47
|
v,
|
|
48
48
|
{
|
|
49
|
-
collapsedContent: /* @__PURE__ */ e(
|
|
50
|
-
extraActions: /* @__PURE__ */
|
|
49
|
+
collapsedContent: /* @__PURE__ */ e(P, {}),
|
|
50
|
+
extraActions: /* @__PURE__ */ y(
|
|
51
51
|
"div",
|
|
52
52
|
{
|
|
53
53
|
style: {
|
|
54
54
|
display: "flex",
|
|
55
55
|
alignItems: "center",
|
|
56
|
-
cursor:
|
|
57
|
-
opacity:
|
|
56
|
+
cursor: a ? "not-allowed" : "pointer",
|
|
57
|
+
opacity: a ? 0.5 : 1,
|
|
58
58
|
marginRight: "16px",
|
|
59
59
|
backgroundColor: "rgb(243 243 243)",
|
|
60
60
|
border: "1px solid #E2E8F0",
|
|
@@ -64,32 +64,32 @@ function A({ locationloading: m }) {
|
|
|
64
64
|
transition: "background-color 0.2s"
|
|
65
65
|
},
|
|
66
66
|
onClick: (t) => {
|
|
67
|
-
|
|
67
|
+
a || C(t);
|
|
68
68
|
},
|
|
69
69
|
onMouseOver: (t) => {
|
|
70
|
-
|
|
70
|
+
a || (t.currentTarget.style.backgroundColor = "#E2E8F0");
|
|
71
71
|
},
|
|
72
72
|
onMouseOut: (t) => {
|
|
73
|
-
|
|
73
|
+
a || (t.currentTarget.style.backgroundColor = "rgb(243 243 243)");
|
|
74
74
|
},
|
|
75
75
|
children: [
|
|
76
76
|
/* @__PURE__ */ e("span", { style: { color: "#475569", fontFamily: "Lato", fontSize: "13px", fontWeight: 600, whiteSpace: "nowrap", letterSpacing: "0.3px" }, children: "EXPORT CSV" }),
|
|
77
|
-
/* @__PURE__ */ e("span", { style: { marginLeft: "6px", display: "flex", alignItems: "center" }, children: /* @__PURE__ */ e(
|
|
77
|
+
/* @__PURE__ */ e("span", { style: { marginLeft: "6px", display: "flex", alignItems: "center" }, children: /* @__PURE__ */ e(T, { spinning: h, size: "small" }) })
|
|
78
78
|
]
|
|
79
79
|
}
|
|
80
80
|
),
|
|
81
81
|
children: /* @__PURE__ */ e(
|
|
82
82
|
S,
|
|
83
83
|
{
|
|
84
|
-
callReturnProducts:
|
|
84
|
+
callReturnProducts: p,
|
|
85
85
|
loading: d,
|
|
86
|
-
locationloading:
|
|
86
|
+
locationloading: g
|
|
87
87
|
}
|
|
88
88
|
)
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
export {
|
|
93
|
-
|
|
93
|
+
q as default
|
|
94
94
|
};
|
|
95
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/order-view/products-info/index.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport ExpandedContent from './expanded-content';\nimport CollapsedContent from './collapsed-content';\nimport CollapsableForm from '../../../common/expand-collapse';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/order-view/products-info/index.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport ExpandedContent from './expanded-content';\nimport CollapsedContent from './collapsed-content';\nimport CollapsableForm from '../../../common/expand-collapse';\nimport {\n useOrderDetails,\n useProductDetails,\n useReturnProductDetails,\n} from '../store';\nimport { useLoading } from '../../order-daily-overview/store/store';\nimport { useAxios } from '@bjsdistribution/dms-component-library';\nimport { notification, Spin } from 'antd';\nimport { useState } from 'react';\n\ninterface ApiResponse {\n message: string;\n code: number;\n error: string | null;\n error_traceback: string | null;\n data: [];\n setShouldPerformAction: boolean;\n}\n\nfunction ProductsInfo({ locationloading }: any) {\n const [data] = useOrderDetails();\n const returnOrder = data;\n\n const [spinLoading, setSpinLoading] = useState<boolean>(false);\n\n // Export functionality\n const { fetchData: callExportCSV } = useAxios<any>({\n endpoint: `/v1/export/csv/${returnOrder?.id}`,\n method: 'POST',\n });\n\n const handleExportCSV = (e: React.MouseEvent) => {\n e.stopPropagation();\n setSpinLoading(true);\n\n callExportCSV()\n .then((res: any) => {\n const urlToDownload = res?.data?.url || res?.url;\n if (urlToDownload) {\n const a = document.createElement('a');\n a.href = urlToDownload;\n a.download = `products_export_${returnOrder?.id}.csv`;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n }\n setSpinLoading(false);\n })\n .catch(err => {\n notification.error({\n message: 'Failed to export csv',\n description: err?.message || 'Export error',\n });\n setSpinLoading(false);\n });\n };\n\n // For API Call\n const [, setProductsData] = useReturnProductDetails();\n /**\n * The order-action modals (force-debrief, confirm, cancel/uncancel) read the legacy\n * `productDetails` atom, and on a fresh page load this fetch is its only writer —\n * `/order/order_products/` is fetched solely after a cancel/uncancel. Keep writing\n * it so those screens are unaffected.\n *\n * The pallet-aware screens (this product section and the split modal) read\n * `returnProductDetails` instead: they need return-order products, which are the\n * only ones carrying pallet data, and that atom cannot be overwritten with\n * order-product records by a cancel/uncancel.\n */\n const [, setLegacyProductsData] = useProductDetails();\n const [, setLoading] = useLoading();\n const {\n data: returnOrdersData,\n loading,\n fetchData: callReturnProducts,\n } = useAxios<{\n data: ApiResponse[];\n }>({\n endpoint: `/v1/return/products/${returnOrder?.id}`,\n method: 'GET',\n pagination: { is_pagination: false },\n });\n\n useEffect(() => {\n if (returnOrder?.id) {\n callReturnProducts();\n }\n }, [returnOrder.id]);\n\n useEffect(() => {\n setLoading(loading);\n if (returnOrdersData && returnOrdersData.data) {\n const requiredData = returnOrdersData.data;\n if (requiredData?.length > 0) {\n setProductsData(requiredData);\n setLegacyProductsData(requiredData);\n } else {\n setProductsData([]);\n setLegacyProductsData([]);\n }\n }\n }, [returnOrdersData, loading]);\n\n const isExportDisabled = !returnOrdersData?.data || returnOrdersData?.data?.length === 0;\n\n return (\n <CollapsableForm\n collapsedContent={<CollapsedContent />}\n extraActions={\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n cursor: isExportDisabled ? 'not-allowed' : 'pointer',\n opacity: isExportDisabled ? 0.5 : 1,\n marginRight: '16px',\n backgroundColor: 'rgb(243 243 243)',\n border: '1px solid #E2E8F0',\n padding: '6px 14px',\n borderRadius: '10px',\n boxShadow: '0 1px 2px rgba(0,0,0,0.05)',\n transition: 'background-color 0.2s',\n }}\n onClick={(e) => {\n if (isExportDisabled) return;\n handleExportCSV(e);\n }}\n onMouseOver={(e) => {\n if (!isExportDisabled) e.currentTarget.style.backgroundColor = '#E2E8F0';\n }}\n onMouseOut={(e) => {\n if (!isExportDisabled) e.currentTarget.style.backgroundColor = 'rgb(243 243 243)';\n }}\n >\n <span style={{ color: '#475569', fontFamily: 'Lato', fontSize: '13px', fontWeight: 600, whiteSpace: 'nowrap', letterSpacing: '0.3px' }}>\n EXPORT CSV\n </span>\n <span style={{ marginLeft: '6px', display: 'flex', alignItems: 'center' }}>\n <Spin spinning={spinLoading} size=\"small\" />\n </span>\n </div>\n }\n >\n <ExpandedContent\n callReturnProducts={callReturnProducts}\n loading={loading}\n locationloading={locationloading}\n />\n </CollapsableForm>\n );\n}\n\nexport default ProductsInfo;\n"],"names":["ProductsInfo","locationloading","data","useOrderDetails","returnOrder","spinLoading","setSpinLoading","useState","callExportCSV","useAxios","handleExportCSV","e","res","urlToDownload","a","err","notification","setProductsData","useReturnProductDetails","setLegacyProductsData","useProductDetails","setLoading","useLoading","returnOrdersData","loading","callReturnProducts","useEffect","requiredData","isExportDisabled","jsx","CollapsableForm","CollapsedContent","jsxs","Spin","ExpandedContent"],"mappings":";;;;;;;;;AAuBA,SAASA,EAAa,EAAE,iBAAAC,KAAwB;AAC9C,QAAM,CAACC,CAAI,IAAIC,EAAA,GACTC,IAAcF,GAE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