@bjsdistribution/dms-client-return 0.1.88-prod → 0.1.89-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.
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as p, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as x } from "react";
|
|
3
3
|
import d from "styled-components";
|
|
4
4
|
import "../order-view/store.js";
|
|
5
|
-
import { useAxios as
|
|
6
|
-
import { useParams as
|
|
7
|
-
import { Spin as
|
|
8
|
-
import { useClientOutstandingReturnData as
|
|
9
|
-
import { dateFilterCPReducer as
|
|
10
|
-
import { useAtom as
|
|
11
|
-
const
|
|
12
|
-
const [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
] =
|
|
5
|
+
import { useAxios as c } from "@bjsdistribution/dms-component-library";
|
|
6
|
+
import { useParams as O } from "react-router-dom";
|
|
7
|
+
import { Spin as g, notification as n } from "antd";
|
|
8
|
+
import { useClientPortal as T, useClientOutstandingReturnData as A, useReturnConfirmedOrderData as F, useSelectedClientAfterOrders as R } from "../store.js";
|
|
9
|
+
import { dateFilterCPReducer as I } from "./DateFilterStore.js";
|
|
10
|
+
import { useAtom as N } from "jotai";
|
|
11
|
+
const X = ({ data: o, payload: f }) => {
|
|
12
|
+
const [s] = T(), [h] = A(), [_] = F(), [
|
|
13
|
+
u,
|
|
14
|
+
v
|
|
15
|
+
] = R(), { status: l } = O(), [w, i] = x(!1), [y, m] = x(!1), [b] = N(I), { "x-filters": E } = b, { fetchData: C } = c({
|
|
16
16
|
endpoint: "/v1/export/generate/",
|
|
17
17
|
method: "POST"
|
|
18
|
-
}), { fetchData:
|
|
18
|
+
}), { fetchData: S } = c({
|
|
19
19
|
endpoint: "/v1/export/download/",
|
|
20
20
|
method: "POST"
|
|
21
|
-
}),
|
|
22
|
-
|
|
21
|
+
}), P = (e) => {
|
|
22
|
+
S({
|
|
23
23
|
endPointQuery: `${e?.data?.file_reference}`
|
|
24
24
|
}).then((t) => {
|
|
25
|
-
t?.data?.url && window.open(t?.data?.url, "_blank"), i(!1);
|
|
25
|
+
t?.data?.url && window.open(t?.data?.url, "_blank"), i(!1), s && window.dispatchEvent(new CustomEvent("file_exported"));
|
|
26
26
|
}).catch((t) => {
|
|
27
27
|
n.error({
|
|
28
28
|
message: "Failed to download file",
|
|
29
29
|
description: t
|
|
30
30
|
}), i(!1);
|
|
31
31
|
});
|
|
32
|
-
},
|
|
32
|
+
}, k = () => {
|
|
33
33
|
let e = null;
|
|
34
34
|
const t = process.env.REACT_APP_API_PATH || "https://development.dmsbackend.bjshomedelivery.com";
|
|
35
|
-
|
|
36
|
-
isExportedData:
|
|
35
|
+
l === "outstanding_return" ? e = {
|
|
36
|
+
isExportedData: h?.length > 0,
|
|
37
37
|
file_type: "csv",
|
|
38
38
|
moduleName: "return",
|
|
39
39
|
filter: [
|
|
@@ -43,15 +43,15 @@ const J = ({ data: o, payload: p }) => {
|
|
|
43
43
|
url: `${t}/v1/return/product/pending/`,
|
|
44
44
|
reference: "return_outstanding_export",
|
|
45
45
|
feature_name: "return"
|
|
46
|
-
} : ["scheduled_for_return", "return_completed"].includes(
|
|
47
|
-
isExportedData:
|
|
46
|
+
} : ["scheduled_for_return", "return_completed"].includes(l) && (e = {
|
|
47
|
+
isExportedData: _?.length > 0,
|
|
48
48
|
file_type: "csv",
|
|
49
49
|
moduleName: "return",
|
|
50
50
|
url: `${t}/v1/return/orders/`,
|
|
51
|
-
reference:
|
|
51
|
+
reference: l === "scheduled_for_return" ? "return_scheduled_export" : "return_completed_export",
|
|
52
52
|
feature_name: "return",
|
|
53
|
-
filter:
|
|
54
|
-
}), e?.isExportedData ? (i(!0),
|
|
53
|
+
filter: E
|
|
54
|
+
}), e?.isExportedData ? (i(!0), C({
|
|
55
55
|
payload: {
|
|
56
56
|
file_type: e?.file_type,
|
|
57
57
|
url: e?.url,
|
|
@@ -60,35 +60,36 @@ const J = ({ data: o, payload: p }) => {
|
|
|
60
60
|
filter: e?.filter
|
|
61
61
|
}
|
|
62
62
|
}).then((r) => {
|
|
63
|
-
setTimeout(() =>
|
|
63
|
+
setTimeout(() => P(r), 1e4);
|
|
64
64
|
}).catch((r) => {
|
|
65
65
|
n.error({
|
|
66
66
|
message: "Failed to export csv",
|
|
67
67
|
description: r
|
|
68
68
|
}), i(!1);
|
|
69
69
|
})) : n.warning({ message: "No data to Export" });
|
|
70
|
-
}, { fetchData:
|
|
71
|
-
endpoint:
|
|
70
|
+
}, { fetchData: D } = c({
|
|
71
|
+
endpoint: u?.length === 0 ? "/v1/orders/import/manifest/csv/?fetch_all_orders=true" : "/v1/orders/import/manifest/csv/",
|
|
72
72
|
method: "POST"
|
|
73
73
|
});
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */ a(
|
|
74
|
+
return /* @__PURE__ */ p(L, { className: "dmsBulkFilter", children: [
|
|
75
|
+
/* @__PURE__ */ a(B, { type: "left", onClick: k, children: /* @__PURE__ */ p("div", { className: "label", children: [
|
|
76
76
|
"Export CSV ",
|
|
77
|
-
/* @__PURE__ */ a(
|
|
77
|
+
/* @__PURE__ */ a(g, { spinning: w })
|
|
78
78
|
] }) }),
|
|
79
|
-
/* @__PURE__ */ a(
|
|
79
|
+
/* @__PURE__ */ a(z, { onClick: async () => {
|
|
80
80
|
if (o && o?.length > 0)
|
|
81
81
|
try {
|
|
82
|
-
if (!
|
|
82
|
+
if (!f) {
|
|
83
83
|
console.error("Payload is missing");
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
m(!0);
|
|
87
|
+
const e = [...u || []], t = e?.length > 0 ? { order_ids: e } : f, r = await D({
|
|
87
88
|
payload: t
|
|
88
89
|
});
|
|
89
90
|
r?.data?.url ? (n.success({
|
|
90
91
|
message: "Success",
|
|
91
|
-
description: r?.message || "Export completed."
|
|
92
|
+
description: s ? "Export completed. Click the highlighted download icon in the top header to view & download your file." : r?.message || "Export completed."
|
|
92
93
|
}), r?.data?.url && window.open(r.data.url)) : n.info({
|
|
93
94
|
message: "Info",
|
|
94
95
|
description: `${r?.message}`
|
|
@@ -99,27 +100,30 @@ const J = ({ data: o, payload: p }) => {
|
|
|
99
100
|
description: "Something went wrong during export."
|
|
100
101
|
});
|
|
101
102
|
} finally {
|
|
102
|
-
|
|
103
|
+
m(!1), v([]), s && window.dispatchEvent(new CustomEvent("file_exported"));
|
|
103
104
|
}
|
|
104
105
|
else
|
|
105
106
|
n.warning({ message: "No data to Export" });
|
|
106
|
-
}, children: /* @__PURE__ */
|
|
107
|
+
}, children: /* @__PURE__ */ p($, { children: [
|
|
108
|
+
"Export Manifest ",
|
|
109
|
+
/* @__PURE__ */ a(g, { spinning: y })
|
|
110
|
+
] }) })
|
|
107
111
|
] });
|
|
108
|
-
},
|
|
112
|
+
}, $ = d.div`
|
|
109
113
|
color: #6a7378;
|
|
110
114
|
text-align: center;
|
|
111
115
|
font-size: 14px;
|
|
112
116
|
font-style: normal;
|
|
113
117
|
font-weight: 500;
|
|
114
118
|
line-height: 18px;
|
|
115
|
-
`,
|
|
119
|
+
`, L = d.div`
|
|
116
120
|
border-radius: 100px;
|
|
117
121
|
border: 1px solid rgba(208, 213, 221, 0.5);
|
|
118
122
|
background: #fff;
|
|
119
123
|
display: flex;
|
|
120
124
|
min-height: 40px;
|
|
121
125
|
// gap: 8px;
|
|
122
|
-
`,
|
|
126
|
+
`, z = d.div`
|
|
123
127
|
padding: 6px 12px;
|
|
124
128
|
display: flex;
|
|
125
129
|
align-items: center;
|
|
@@ -177,7 +181,7 @@ const J = ({ data: o, payload: p }) => {
|
|
|
177
181
|
&.noPadding {
|
|
178
182
|
padding: 0;
|
|
179
183
|
}
|
|
180
|
-
`,
|
|
184
|
+
`, B = d.div`
|
|
181
185
|
display: flex;
|
|
182
186
|
background: #fff;
|
|
183
187
|
min-height: 40px;
|
|
@@ -198,9 +202,9 @@ const J = ({ data: o, payload: p }) => {
|
|
|
198
202
|
}
|
|
199
203
|
`;
|
|
200
204
|
export {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
B as ExportCSVButton,
|
|
206
|
+
L as StyledBulkFilterCover,
|
|
207
|
+
z as StyledBulkItem,
|
|
208
|
+
X as default
|
|
205
209
|
};
|
|
206
210
|
//# sourceMappingURL=ReturnRTFilters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReturnRTFilters.js","sources":["../../../src/components/client-portal/ReturnRTFilters.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { useAtom } from '../order-view/store';\nimport { useAxios } from '@bjsdistribution/dms-component-library';\nimport { useParams } from 'react-router-dom';\n// import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';\nimport { notification, Spin } from 'antd';\nimport {\n useClientOutstandingReturnData,\n useReturnConfirmedOrderData,\n useSelectedClientAfterOrders,\n // useSelectedClientPortOrders,\n} from '../store';\nimport { dateFilterCPReducer } from './DateFilterStore';\n\nconst ReturnRTFilters = ({ data, payload }: { data: any; payload: any }) => {\n const [outstandingReturnData] = useClientOutstandingReturnData();\n const [returnConfirmedData] = useReturnConfirmedOrderData();\n const [\n selectedOrderIds,\n setSelectedOrderIds,\n ] = useSelectedClientAfterOrders();\n // const [\n // selectedPendingOrderIds,\n // setSelectedPendingOrderIds,\n // ] = useSelectedClientPortOrders();\n const { status } = useParams<{ status: any }>();\n const [spinLoading, setSpinLoading] = useState<boolean>(false);\n const [state] = useAtom(dateFilterCPReducer);\n const { 'x-filters': filters } = state;\n\n //export csv\n const { fetchData: callExportCSV } = useAxios<{\n data: any[];\n message: string;\n }>({\n endpoint: `/v1/export/generate/`,\n method: 'POST',\n });\n const { fetchData: downloadFile } = useAxios({\n endpoint: '/v1/export/download/',\n method: 'POST',\n });\n const download: any = (response: any) => {\n downloadFile({\n endPointQuery: `${response?.data?.file_reference}`,\n })\n .then((response: any) => {\n if (response?.data?.url) {\n window.open(response?.data?.url, '_blank');\n }\n setSpinLoading(false);\n })\n .catch((err: any) => {\n notification.error({\n message: 'Failed to download file',\n description: err,\n });\n setSpinLoading(false);\n });\n };\n\n const handleExportCSV = () => {\n let moduleInfo: any | null = null;\n const url =\n process.env.REACT_APP_API_PATH ||\n 'https://development.dmsbackend.bjshomedelivery.com';\n if (status === 'outstanding_return') {\n moduleInfo = {\n isExportedData: outstandingReturnData?.length > 0,\n file_type: 'csv',\n moduleName: 'return',\n filter: [\n { field: 'isdeleted', op: '=', value: 0 },\n { field: 'product_return_action_id', op: '=', value: 'RTS' },\n ],\n url: `${url}/v1/return/product/pending/`,\n reference: 'return_outstanding_export',\n feature_name: 'return',\n };\n } else if (['scheduled_for_return', 'return_completed'].includes(status)) {\n moduleInfo = {\n isExportedData: returnConfirmedData?.length > 0,\n file_type: 'csv',\n moduleName: 'return',\n url: `${url}/v1/return/orders/`,\n\n reference:\n status === 'scheduled_for_return'\n ? 'return_scheduled_export'\n : 'return_completed_export',\n feature_name: 'return',\n filter: filters,\n };\n }\n\n if (moduleInfo?.isExportedData) {\n setSpinLoading(true);\n\n callExportCSV({\n payload: {\n file_type: moduleInfo?.file_type,\n url: moduleInfo?.url,\n reference: moduleInfo?.reference,\n feature_name: moduleInfo?.feature_name,\n filter: moduleInfo?.filter,\n },\n })\n .then((res: any) => {\n setTimeout(() => download(res), 10000);\n })\n .catch(err => {\n notification.error({\n message: 'Failed to export csv',\n description: err,\n });\n setSpinLoading(false);\n });\n } else {\n notification.warning({ message: 'No data to Export' });\n }\n };\n\n const { fetchData: callExportApi } = useAxios<{\n data: any[];\n message: string;\n }>({\n endpoint:\n selectedOrderIds?.length === 0\n ? `/v1/orders/import/manifest/csv/?fetch_all_orders=true`\n : '/v1/orders/import/manifest/csv/',\n method: 'POST',\n });\n\n // const handleExportManifest = async () => {\n // const exportOrderIds =\n // status === 'outstanding_return'\n // ? selectedPendingOrderIds\n // : status === 'scheduled_for_return' || status === 'return_completed'\n // ? selectedOrderIds\n // : [];\n\n // try {\n // const response = (await callExportApi({\n // payload: { order_ids: exportOrderIds },\n // })) as {\n // code: number | null;\n // error?: string | null;\n // data?: {\n // url?: string;\n // };\n // message?: string;\n // };\n\n // if (response?.data?.url) {\n // notification.success({\n // message: 'Success',\n // description: response?.message || 'Export completed.',\n // });\n // window.open(response?.data?.url, '_blank');\n\n // if (status === 'outstanding_return') {\n // setSelectedPendingOrderIds([]);\n // } else if (\n // status === 'scheduled_for_return' ||\n // status === 'return_completed'\n // ) {\n // setSelectedOrderIds([]);\n // }\n // } else {\n // notification.error({\n // message: 'No File URL',\n // description: 'Export succeeded but no download URL was returned.',\n // });\n // }\n // } catch (error) {\n // console.error('Error during export or download:', error);\n // notification.error({\n // message: 'Export Failed',\n // description: 'Something went wrong during export.',\n // });\n\n // if (status === 'outstanding_return') {\n // setSelectedPendingOrderIds([]);\n // } else if (\n // status === 'scheduled_for_return' ||\n // status === 'return_completed'\n // ) {\n // setSelectedOrderIds([]);\n // }\n // }\n // };\n\n const handleExport = async () => {\n if (data && data?.length > 0) {\n try {\n if (!payload) {\n console.error('Payload is missing');\n return;\n }\n\n const currentIds = [...(selectedOrderIds || [])];\n\n const finalPayload =\n currentIds?.length > 0 ? { order_ids: currentIds } : payload;\n\n const response = (await callExportApi({\n payload: finalPayload,\n })) as {\n code: number | null;\n error?: string | null;\n data?: { url?: string; message?: string };\n message?: string;\n };\n\n if (response?.data?.url) {\n notification.success({\n message: 'Success',\n description: response?.message || 'Export completed.',\n });\n if (response?.data?.url) {\n window.open(response.data.url);\n }\n } else {\n notification.info({\n message: 'Info',\n description: `${response?.message}`,\n });\n }\n } catch (error) {\n console.error('Error during export or download:', error);\n notification.error({\n message: 'Export Failed',\n description: 'Something went wrong during export.',\n });\n } finally {\n setSelectedOrderIds([]);\n }\n } else {\n notification.warning({ message: 'No data to Export' });\n }\n };\n\n return (\n <StyledBulkFilterCover className=\"dmsBulkFilter\">\n {/* <ExportButton moduleInfoModule={moduleInfo} /> */}\n <ExportCSVButton type=\"left\" onClick={handleExportCSV}>\n <div className=\"label\">\n Export CSV <Spin spinning={spinLoading} />\n </div>\n </ExportCSVButton>\n <StyledBulkItem onClick={handleExport}>\n <Text>Export Manifest</Text>\n </StyledBulkItem>\n </StyledBulkFilterCover>\n );\n};\n\nconst Text = styled.div`\n color: #6a7378;\n text-align: center;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px;\n`;\nexport const StyledBulkFilterCover = styled.div`\n border-radius: 100px;\n border: 1px solid rgba(208, 213, 221, 0.5);\n background: #fff;\n display: flex;\n min-height: 40px;\n // gap: 8px;\n`;\n\nexport const StyledBulkItem = styled.div`\n padding: 6px 12px;\n display: flex;\n align-items: center;\n border-right: 1px solid #d0d5dd;\n gap: 8px;\n position: relative;\n a {\n text-decoration: none;\n }\n &.disabled {\n /* opacity: 0.5; */\n width: 150px;\n cursor: default;\n a {\n cursor: default;\n\n label {\n cursor: default;\n }\n }\n }\n &:hover:not(:disabled) {\n background: #f0f0f0;\n cursor: pointer;\n }\n\n @media screen and (max-width: 1030px) {\n padding: 6px 4px;\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: #3a3630;\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`;\n\nexport const ExportCSVButton = styled.div<{\n type: 'left' | 'right' | 'middle';\n}>`\n display: flex;\n background: #fff;\n min-height: 40px;\n padding: 8px 12px;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n border-radius: ${props =>\n props?.type === 'left'\n ? '50px 0px 0px 50px'\n : props?.type === 'right'\n ? ' 0px 50px 50px 0px'\n : ''};\n border-right: ${props => (props.type === 'right' ? '' : '1px solid #d0d5dd')};\n .label {\n color: #6a7378;\n text-align: center;\n font-family: Lato;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px;\n }\n`;\nexport default ReturnRTFilters;\n"],"names":["ReturnRTFilters","data","payload","outstandingReturnData","useClientOutstandingReturnData","returnConfirmedData","useReturnConfirmedOrderData","selectedOrderIds","setSelectedOrderIds","useSelectedClientAfterOrders","status","useParams","spinLoading","setSpinLoading","useState","state","useAtom","dateFilterCPReducer","filters","callExportCSV","useAxios","downloadFile","download","response","err","notification","handleExportCSV","moduleInfo","url","res","callExportApi","jsxs","StyledBulkFilterCover","jsx","ExportCSVButton","Spin","StyledBulkItem","currentIds","finalPayload","error","Text","styled","props"],"mappings":";;;;;;;;;;AAeA,MAAMA,IAAkB,CAAC,EAAE,MAAAC,GAAM,SAAAC,QAA2C;AAC1E,QAAM,CAACC,CAAqB,IAAIC,EAAA,GAC1B,CAACC,CAAmB,IAAIC,EAAA,GACxB;AAAA,IACJC;AAAA,IACAC;AAAA,EAAA,IACEC,EAAA,GAKE,EAAE,QAAAC,EAAA,IAAWC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAkB,EAAK,GACvD,CAACC,CAAK,IAAIC,EAAQC,CAAmB,GACrC,EAAE,aAAaC,EAAA,IAAYH,GAG3B,EAAE,WAAWI,EAAA,IAAkBC,EAGlC;AAAA,IACD,UAAU;AAAA,IACV,QAAQ;AAAA,EAAA,CACT,GACK,EAAE,WAAWC,EAAA,IAAiBD,EAAS;AAAA,IAC3C,UAAU;AAAA,IACV,QAAQ;AAAA,EAAA,CACT,GACKE,IAAgB,CAACC,MAAkB;AACvC,IAAAF,EAAa;AAAA,MACX,eAAe,GAAGE,GAAU,MAAM,cAAc;AAAA,IAAA,CACjD,EACE,KAAK,CAACA,MAAkB;AACvB,MAAIA,GAAU,MAAM,OAClB,OAAO,KAAKA,GAAU,MAAM,KAAK,QAAQ,GAE3CV,EAAe,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,EAAoB,CAAA,CAAE;AAAA,QACxB;AAAA;AAEA,QAAAiB,EAAa,QAAQ,EAAE,SAAS,oBAAA,CAAqB;AAAA,IAEzD,GAWM,UAAA,gBAAAQ,EAACO,GAAA,EAAK,6BAAe,GACvB;AAAA,EAAA,GACF;AAEJ,GAEMA,IAAOC,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQPT,IAAwBS,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAS/BL,IAAiBK,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA4DxBP,IAAkBO,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAUnB,CAAAC,MACfA,GAAO,SAAS,SACZ,sBACAA,GAAO,SAAS,UAChB,uBACA,EAAE;AAAA,kBACQ,CAAAA,MAAUA,EAAM,SAAS,UAAU,KAAK,mBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"ReturnRTFilters.js","sources":["../../../src/components/client-portal/ReturnRTFilters.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { useAtom } from '../order-view/store';\nimport { useAxios } from '@bjsdistribution/dms-component-library';\nimport { useParams } from 'react-router-dom';\n// import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';\nimport { notification, Spin } from 'antd';\nimport {\n useClientOutstandingReturnData,\n useReturnConfirmedOrderData,\n useSelectedClientAfterOrders,\n useClientPortal,\n // useSelectedClientPortOrders,\n} from '../store';\nimport { dateFilterCPReducer } from './DateFilterStore';\n\nconst ReturnRTFilters = ({ data, payload }: { data: any; payload: any }) => {\n const [isClientPortal] = useClientPortal();\n const [outstandingReturnData] = useClientOutstandingReturnData();\n const [returnConfirmedData] = useReturnConfirmedOrderData();\n const [\n selectedOrderIds,\n setSelectedOrderIds,\n ] = useSelectedClientAfterOrders();\n // const [\n // selectedPendingOrderIds,\n // setSelectedPendingOrderIds,\n // ] = useSelectedClientPortOrders();\n const { status } = useParams<{ status: any }>();\n const [spinLoading, setSpinLoading] = useState<boolean>(false);\n const [manifestLoading, setManifestLoading] = useState<boolean>(false);\n const [state] = useAtom(dateFilterCPReducer);\n const { 'x-filters': filters } = state;\n\n //export csv\n const { fetchData: callExportCSV } = useAxios<{\n data: any[];\n message: string;\n }>({\n endpoint: `/v1/export/generate/`,\n method: 'POST',\n });\n const { fetchData: downloadFile } = useAxios({\n endpoint: '/v1/export/download/',\n method: 'POST',\n });\n const download: any = (response: any) => {\n downloadFile({\n endPointQuery: `${response?.data?.file_reference}`,\n })\n .then((response: any) => {\n if (response?.data?.url) {\n window.open(response?.data?.url, '_blank');\n }\n setSpinLoading(false);\n if (isClientPortal) {\n window.dispatchEvent(new CustomEvent('file_exported'));\n }\n })\n .catch((err: any) => {\n notification.error({\n message: 'Failed to download file',\n description: err,\n });\n setSpinLoading(false);\n });\n };\n\n const handleExportCSV = () => {\n let moduleInfo: any | null = null;\n const url =\n process.env.REACT_APP_API_PATH ||\n 'https://development.dmsbackend.bjshomedelivery.com';\n if (status === 'outstanding_return') {\n moduleInfo = {\n isExportedData: outstandingReturnData?.length > 0,\n file_type: 'csv',\n moduleName: 'return',\n filter: [\n { field: 'isdeleted', op: '=', value: 0 },\n { field: 'product_return_action_id', op: '=', value: 'RTS' },\n ],\n url: `${url}/v1/return/product/pending/`,\n reference: 'return_outstanding_export',\n feature_name: 'return',\n };\n } else if (['scheduled_for_return', 'return_completed'].includes(status)) {\n moduleInfo = {\n isExportedData: returnConfirmedData?.length > 0,\n file_type: 'csv',\n moduleName: 'return',\n url: `${url}/v1/return/orders/`,\n\n reference:\n status === 'scheduled_for_return'\n ? 'return_scheduled_export'\n : 'return_completed_export',\n feature_name: 'return',\n filter: filters,\n };\n }\n\n if (moduleInfo?.isExportedData) {\n setSpinLoading(true);\n\n callExportCSV({\n payload: {\n file_type: moduleInfo?.file_type,\n url: moduleInfo?.url,\n reference: moduleInfo?.reference,\n feature_name: moduleInfo?.feature_name,\n filter: moduleInfo?.filter,\n },\n })\n .then((res: any) => {\n setTimeout(() => download(res), 10000);\n })\n .catch(err => {\n notification.error({\n message: 'Failed to export csv',\n description: err,\n });\n setSpinLoading(false);\n });\n } else {\n notification.warning({ message: 'No data to Export' });\n }\n };\n\n const { fetchData: callExportApi } = useAxios<{\n data: any[];\n message: string;\n }>({\n endpoint:\n selectedOrderIds?.length === 0\n ? `/v1/orders/import/manifest/csv/?fetch_all_orders=true`\n : '/v1/orders/import/manifest/csv/',\n method: 'POST',\n });\n\n // const handleExportManifest = async () => {\n // const exportOrderIds =\n // status === 'outstanding_return'\n // ? selectedPendingOrderIds\n // : status === 'scheduled_for_return' || status === 'return_completed'\n // ? selectedOrderIds\n // : [];\n\n // try {\n // const response = (await callExportApi({\n // payload: { order_ids: exportOrderIds },\n // })) as {\n // code: number | null;\n // error?: string | null;\n // data?: {\n // url?: string;\n // };\n // message?: string;\n // };\n\n // if (response?.data?.url) {\n // notification.success({\n // message: 'Success',\n // description: response?.message || 'Export completed.',\n // });\n // window.open(response?.data?.url, '_blank');\n\n // if (status === 'outstanding_return') {\n // setSelectedPendingOrderIds([]);\n // } else if (\n // status === 'scheduled_for_return' ||\n // status === 'return_completed'\n // ) {\n // setSelectedOrderIds([]);\n // }\n // } else {\n // notification.error({\n // message: 'No File URL',\n // description: 'Export succeeded but no download URL was returned.',\n // });\n // }\n // } catch (error) {\n // console.error('Error during export or download:', error);\n // notification.error({\n // message: 'Export Failed',\n // description: 'Something went wrong during export.',\n // });\n\n // if (status === 'outstanding_return') {\n // setSelectedPendingOrderIds([]);\n // } else if (\n // status === 'scheduled_for_return' ||\n // status === 'return_completed'\n // ) {\n // setSelectedOrderIds([]);\n // }\n // }\n // };\n\n const handleExport = async () => {\n if (data && data?.length > 0) {\n try {\n if (!payload) {\n console.error('Payload is missing');\n return;\n }\n setManifestLoading(true);\n\n const currentIds = [...(selectedOrderIds || [])];\n\n const finalPayload =\n currentIds?.length > 0 ? { order_ids: currentIds } : payload;\n\n const response = (await callExportApi({\n payload: finalPayload,\n })) as {\n code: number | null;\n error?: string | null;\n data?: { url?: string; message?: string };\n message?: string;\n };\n\n if (response?.data?.url) {\n notification.success({\n message: 'Success',\n description: isClientPortal\n ? 'Export completed. Click the highlighted download icon in the top header to view & download your file.'\n : response?.message || 'Export completed.',\n });\n if (response?.data?.url) {\n window.open(response.data.url);\n }\n } else {\n notification.info({\n message: 'Info',\n description: `${response?.message}`,\n });\n }\n } catch (error) {\n console.error('Error during export or download:', error);\n notification.error({\n message: 'Export Failed',\n description: 'Something went wrong during export.',\n });\n } finally {\n setManifestLoading(false);\n setSelectedOrderIds([]);\n if (isClientPortal) {\n window.dispatchEvent(new CustomEvent('file_exported'));\n }\n }\n } else {\n notification.warning({ message: 'No data to Export' });\n }\n };\n\n return (\n <StyledBulkFilterCover className=\"dmsBulkFilter\">\n {/* <ExportButton moduleInfoModule={moduleInfo} /> */}\n <ExportCSVButton type=\"left\" onClick={handleExportCSV}>\n <div className=\"label\">\n Export CSV <Spin spinning={spinLoading} />\n </div>\n </ExportCSVButton>\n <StyledBulkItem onClick={handleExport}>\n <Text>\n Export Manifest <Spin spinning={manifestLoading} />\n </Text>\n </StyledBulkItem>\n </StyledBulkFilterCover>\n );\n};\n\nconst Text = styled.div`\n color: #6a7378;\n text-align: center;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px;\n`;\nexport const StyledBulkFilterCover = styled.div`\n border-radius: 100px;\n border: 1px solid rgba(208, 213, 221, 0.5);\n background: #fff;\n display: flex;\n min-height: 40px;\n // gap: 8px;\n`;\n\nexport const StyledBulkItem = styled.div`\n padding: 6px 12px;\n display: flex;\n align-items: center;\n border-right: 1px solid #d0d5dd;\n gap: 8px;\n position: relative;\n a {\n text-decoration: none;\n }\n &.disabled {\n /* opacity: 0.5; */\n width: 150px;\n cursor: default;\n a {\n cursor: default;\n\n label {\n cursor: default;\n }\n }\n }\n &:hover:not(:disabled) {\n background: #f0f0f0;\n cursor: pointer;\n }\n\n @media screen and (max-width: 1030px) {\n padding: 6px 4px;\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: #3a3630;\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`;\n\nexport const ExportCSVButton = styled.div<{\n type: 'left' | 'right' | 'middle';\n}>`\n display: flex;\n background: #fff;\n min-height: 40px;\n padding: 8px 12px;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n border-radius: ${props =>\n props?.type === 'left'\n ? '50px 0px 0px 50px'\n : props?.type === 'right'\n ? ' 0px 50px 50px 0px'\n : ''};\n border-right: ${props => (props.type === 'right' ? '' : '1px solid #d0d5dd')};\n .label {\n color: #6a7378;\n text-align: center;\n font-family: Lato;\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px;\n }\n`;\nexport default ReturnRTFilters;\n"],"names":["ReturnRTFilters","data","payload","isClientPortal","useClientPortal","outstandingReturnData","useClientOutstandingReturnData","returnConfirmedData","useReturnConfirmedOrderData","selectedOrderIds","setSelectedOrderIds","useSelectedClientAfterOrders","status","useParams","spinLoading","setSpinLoading","useState","manifestLoading","setManifestLoading","state","useAtom","dateFilterCPReducer","filters","callExportCSV","useAxios","downloadFile","download","response","err","notification","handleExportCSV","moduleInfo","url","res","callExportApi","jsxs","StyledBulkFilterCover","jsx","ExportCSVButton","Spin","StyledBulkItem","currentIds","finalPayload","error","Text","styled","props"],"mappings":";;;;;;;;;;AAgBA,MAAMA,IAAkB,CAAC,EAAE,MAAAC,GAAM,SAAAC,QAA2C;AAC1E,QAAM,CAACC,CAAc,IAAIC,EAAA,GACnB,CAACC,CAAqB,IAAIC,EAAA,GAC1B,CAACC,CAAmB,IAAIC,EAAA,GACxB;AAAA,IACJC;AAAA,IACAC;AAAA,EAAA,IACEC,EAAA,GAKE,EAAE,QAAAC,EAAA,IAAWC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAkB,EAAK,GACvD,CAACC,GAAiBC,CAAkB,IAAIF,EAAkB,EAAK,GAC/D,CAACG,CAAK,IAAIC,EAAQC,CAAmB,GACrC,EAAE,aAAaC,EAAA,IAAYH,GAG3B,EAAE,WAAWI,EAAA,IAAkBC,EAGlC;AAAA,IACD,UAAU;AAAA,IACV,QAAQ;AAAA,EAAA,CACT,GACK,EAAE,WAAWC,EAAA,IAAiBD,EAAS;AAAA,IAC3C,UAAU;AAAA,IACV,QAAQ;AAAA,EAAA,CACT,GACKE,IAAgB,CAACC,MAAkB;AACvC,IAAAF,EAAa;AAAA,MACX,eAAe,GAAGE,GAAU,MAAM,cAAc;AAAA,IAAA,CACjD,EACE,KAAK,CAACA,MAAkB;AACvB,MAAIA,GAAU,MAAM,OAClB,OAAO,KAAKA,GAAU,MAAM,KAAK,QAAQ,GAE3CZ,EAAe,EAAK,GAChBZ,KACF,OAAO,cAAc,IAAI,YAAY,eAAe,CAAC;AAAA,IAEzD,CAAC,EACA,MAAM,CAACyB,MAAa;AACnB,MAAAC,EAAa,MAAM;AAAA,QACjB,SAAS;AAAA,QACT,aAAaD;AAAA,MAAA,CACd,GAC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