@bjsdistribution/dms-client-return 0.0.39 → 0.0.41

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.39",
2
+ "version": "0.0.41",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -59,7 +59,7 @@
59
59
  "testEnvironment": "jest-environment-jsdom-sixteen"
60
60
  },
61
61
  "devDependencies": {
62
- "@bjsdistribution/dms-component-library": "0.1.4",
62
+ "@bjsdistribution/dms-component-library": "0.1.11",
63
63
  "@size-limit/preset-small-lib": "^11.0.1",
64
64
  "@tippyjs/react": "^4.2.6",
65
65
  "@types/react": "^18.2.47",
@@ -48,15 +48,19 @@ function SelectionFilter() {
48
48
  const [actionTypeOptions, setActionTypeOptions] = useActionTypeOptions();
49
49
  const [locationOptions, setLocationOptions] = useLocationOptions();
50
50
 
51
- const clientOptions = customers?.map((option: any) => ({
52
- label:
53
- option?.customer_name?.charAt(0)?.toUpperCase() +
54
- option?.customer_name?.slice(1),
55
- value: option?.customer_id,
56
- actions: option?.actions,
57
- return_locations: option?.return_locations,
58
- account_number: option?.account_number,
59
- }));
51
+ const clientOptions = customers
52
+ ?.filter(
53
+ (option: any) => 'customer_id' in option && option.customer_id != null
54
+ )
55
+ .map((option: any) => ({
56
+ label:
57
+ option?.customer_name?.charAt(0)?.toUpperCase() +
58
+ option?.customer_name?.slice(1),
59
+ value: option?.customer_id,
60
+ actions: option?.actions,
61
+ return_locations: option?.return_locations,
62
+ account_number: option?.account_number,
63
+ }));
60
64
 
61
65
  //client change
62
66
  const handleClientChange = (value: any, option: any) => {
@@ -66,6 +70,31 @@ function SelectionFilter() {
66
70
  localStorage.setItem('clientName', option?.label);
67
71
  localStorage.setItem('clientId', value?.toString());
68
72
  localStorage.setItem('account_number', option?.account_number);
73
+ const storedClientId = localStorage.getItem('clientId');
74
+
75
+ const filteredClient = clientOptions?.find(
76
+ (client: any) => client?.value == storedClientId
77
+ );
78
+
79
+ if (filteredClient) {
80
+ const mappedActions = Array.isArray(filteredClient?.actions)
81
+ ? filteredClient?.actions?.map((action: any) => ({
82
+ label: action,
83
+ value: action,
84
+ }))
85
+ : [];
86
+
87
+ setActionTypeOptions(mappedActions);
88
+
89
+ const mappedLocations = Array.isArray(filteredClient?.return_locations)
90
+ ? filteredClient?.return_locations?.map((location: any) => ({
91
+ label: location?.location_name,
92
+ value: location?.token,
93
+ }))
94
+ : [];
95
+
96
+ setLocationOptions(mappedLocations);
97
+ }
69
98
 
70
99
  //set payload
71
100
  setReturnPayload((prevState: any) => ({
@@ -306,7 +306,6 @@ const ReturnOrderTable = () => {
306
306
 
307
307
  const mergedPayload = Object.values(groupedPayload);
308
308
  setGrouped(mergedPayload);
309
- console.log(mergedPayload, 'mergedPayload');
310
309
  }, [newpayload]);
311
310
 
312
311
  return (
@@ -428,7 +427,10 @@ const ReturnOrderTable = () => {
428
427
  <div className="awaiting">Awaiting</div>
429
428
  )}
430
429
  </td>
431
- <td> {displayValueOrNA(item?.new_location)}</td>
430
+ <td>
431
+ {' '}
432
+ {displayValueOrNA(item?.return_locations?.location_name)}
433
+ </td>
432
434
  <td>
433
435
  <ul style={{ listStyleType: 'none', padding: 0 }}>
434
436
  <li
@@ -32,7 +32,7 @@ interface ApiResponse {
32
32
  const ReturnTable: React.FC = () => {
33
33
  const [clientData] = useClientData();
34
34
  const [updatedData, setUpdatedData] = useState<any>([]);
35
- const [statsLoading, setLoading] = useStatsLoading();
35
+ const [statsLoading] = useStatsLoading();
36
36
  const [, setOrderStaticData] = useOrderStaticData();
37
37
  const [, dispatch] = useAtom(filtersReducerAtom);
38
38
  const navigate = useNavigate();
@@ -93,7 +93,7 @@ const ReturnTable: React.FC = () => {
93
93
  });
94
94
 
95
95
  useEffect(() => {
96
- setLoading(staticDataLoading);
96
+ // setLoading(staticDataLoading);
97
97
  if (fetchedStaticData && fetchedStaticData.data) {
98
98
  const result = fetchedStaticData?.data;
99
99
  setOrderStaticData(result[0]);
@@ -148,6 +148,8 @@ const ReturnTable: React.FC = () => {
148
148
  // navigate(`/filter/${customerId}`);
149
149
  };
150
150
 
151
+ console.log(statsLoading, 'statsLoading');
152
+
151
153
  return (
152
154
  <>
153
155
  {statsLoading && <Loader />}
@@ -11,8 +11,6 @@ const PrintDropDownReturn = ({
11
11
  }: {
12
12
  legacyProductId: number;
13
13
  }) => {
14
- console.log(legacyProductId, 'legacyProductId');
15
-
16
14
  const downloadFiles = () => {
17
15
  const url = `https://us.toolbox.bjshomedelivery.com/offload/return_label?gsit_products_id=${legacyProductId}`;
18
16
  window.open(url, '_blank'); // Opens the URL in a new tab
@@ -76,7 +76,7 @@ const CreateReturnModal = () => {
76
76
  onChange={() => handleSelectLocations(returnLoc.id)}
77
77
  />
78
78
  <StyledText style={{ marginLeft: '8px' }}>
79
- {displayValueOrNA(returnLoc?.new_location)}
79
+ {displayValueOrNA(returnLoc?.return_locations?.location_name)}
80
80
  </StyledText>
81
81
  </li>
82
82
  ))}
@@ -55,7 +55,7 @@ const ModalManager = () => {
55
55
  data: response,
56
56
  setShouldPerformAction,
57
57
  loading: confirmLoading,
58
- error: apiError,
58
+ // error: apiError,
59
59
  setError,
60
60
  } = useApiHook<{
61
61
  data: ApiResponse[];
@@ -80,11 +80,12 @@ const ModalManager = () => {
80
80
 
81
81
  useEffect(() => {
82
82
  // @ts-ignore
83
- if (apiError && apiError?.code !== 200) {
83
+ if (response && response?.code == 500) {
84
+ // @ts-ignore
84
85
  notification.error({
85
86
  message: 'Failure',
86
87
  // @ts-ignore
87
- description: `${apiError?.message}`,
88
+ description: `${response?.message}`,
88
89
  });
89
90
  dispatch({ type: 'close' });
90
91
  setSelectedReturnOrder([]);
@@ -115,7 +116,7 @@ const ModalManager = () => {
115
116
  // for dev
116
117
  navigate('/returnclient/order-return');
117
118
  }
118
- }, [response, apiError, postLoading]);
119
+ }, [postLoading]);
119
120
 
120
121
  return (
121
122
  <>