@bjsdistribution/dms-client-return 0.0.84 → 0.0.85

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.84",
2
+ "version": "0.0.85",
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.58",
62
+ "@bjsdistribution/dms-component-library": "0.1.78",
63
63
  "@size-limit/preset-small-lib": "^11.0.1",
64
64
  "@tippyjs/react": "^4.2.6",
65
65
  "@types/react": "^18.2.47",
@@ -26,6 +26,8 @@ import {
26
26
  useGsitOrderId,
27
27
  useOrderProductId,
28
28
  useLiveRecalling,
29
+ useGlobalStateHitOrder,
30
+ useAtom,
29
31
  } from './store';
30
32
  import { OrdersType } from './types';
31
33
  import { useLocation } from 'react-router-dom';
@@ -36,6 +38,7 @@ import DetailsFilters from './details-filters/DetailsFilters';
36
38
  import { useSubContracterData, useVisibilityData } from '../store';
37
39
  import Notification from './notification';
38
40
  import Order from './order-resources/expanded-content';
41
+ import { setResourcesCall } from './order-actions/store';
39
42
 
40
43
  interface ApiResponse {
41
44
  message: string;
@@ -71,6 +74,7 @@ function OrderView() {
71
74
  const systemLogsData = useSystemLogs();
72
75
  const [, setVisibilityData] = useVisibilityData();
73
76
  const [, setSubContracterData] = useSubContracterData();
77
+ const [recallOrders] = useGlobalStateHitOrder();
74
78
 
75
79
  // query param
76
80
  const location = useLocation();
@@ -167,10 +171,10 @@ function OrderView() {
167
171
  });
168
172
  useEffect(() => {
169
173
  if (orderId) {
170
- orderUpdate(true);
174
+ orderUpdate(recallOrders);
171
175
  liveRecalling ? setLivePerformAction(false) : setLivePerformAction(true);
172
176
  }
173
- }, [orderId, liveRecalling]);
177
+ }, [orderId, liveRecalling, recallOrders]);
174
178
 
175
179
  useEffect(() => {
176
180
  setLoading(staticDataLoading);
@@ -222,6 +226,8 @@ function OrderView() {
222
226
  };
223
227
  }, [statusDataLoading, fetchedStatusData]);
224
228
 
229
+ const [getResources] = useAtom(setResourcesCall);
230
+
225
231
  useEffect(() => {
226
232
  setLoading(depotDataLoading);
227
233
  if (fetchedDepotData && fetchedDepotData.data) {
@@ -255,6 +261,19 @@ function OrderView() {
255
261
  performAction: false,
256
262
  });
257
263
 
264
+ useEffect(() => {
265
+ if (orderId) {
266
+ if (getResources) {
267
+ setActions(false);
268
+ setTimeout(() => {
269
+ setActions(true);
270
+ }, 200);
271
+ } else {
272
+ setActions(true);
273
+ }
274
+ }
275
+ }, [orderId, setActions, getResources]);
276
+
258
277
  useEffect(() => {
259
278
  if (orderId) {
260
279
  setActions(true);
@@ -9,6 +9,7 @@ import { useApiHook } from '@bjsdistribution/dms-component-library';
9
9
  import {
10
10
  useCurrentAction,
11
11
  useCustomerInfo,
12
+ useGlobalStateHitOrder,
12
13
  useLiveRecalling,
13
14
  useOrderDetails,
14
15
  useOrderId,
@@ -19,8 +20,7 @@ import {
19
20
  useErrorConfirmOrder,
20
21
  useOrderDetailsConfirmOrder,
21
22
  } from '../../store';
22
- import { ApiResponse, OrdersType } from '../../../types';
23
- import { useLoading } from '../../../../order-daily-overview/store/store';
23
+ import { ApiResponse } from '../../../types';
24
24
  import { notification } from 'antd';
25
25
  import { compareOrderDetailsStates, filterObject } from '../../../utils';
26
26
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
@@ -35,14 +35,14 @@ function ConfirmOrder() {
35
35
  orderDetailsConfirmOrder,
36
36
  setOrderDetailsConfirmOrder,
37
37
  ] = useOrderDetailsConfirmOrder();
38
- const [, setLoading] = useLoading();
39
38
  const [customerInfo] = useCustomerInfo();
40
39
  const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
41
40
  const [deliveryDate, setDeliveryDate] = useConfirmOrderDate();
42
- const [liveRecalling, setRecalling] = useLiveRecalling();
41
+ const [, setRecalling] = useLiveRecalling();
43
42
  const [orderId] = useOrderId();
44
43
  const [errorState] = useErrorConfirmOrder();
45
44
  const updateOrder = useUpdateOrder();
45
+ const [, setRecallOrders] = useGlobalStateHitOrder();
46
46
 
47
47
  const onClose = () => {
48
48
  setCurrentAction(undefined);
@@ -69,30 +69,6 @@ function ConfirmOrder() {
69
69
  performAction: false,
70
70
  });
71
71
 
72
- const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
73
- data: OrdersType[];
74
- }>({
75
- endpoint: `orders/${orderId}`,
76
- method: 'GET',
77
- performAction: false,
78
- });
79
-
80
- useEffect(() => {
81
- setLoading(loading);
82
- if (fetchedData && fetchedData.data) {
83
- const requiredData = fetchedData?.data;
84
- setOrderDetails(requiredData[0]);
85
- setPrevOrderDetails(requiredData[0]);
86
- setCurrentAction(undefined);
87
- }
88
- if (
89
- (fetchedData && fetchedData?.data === null) ||
90
- fetchedData?.data?.length === 0
91
- ) {
92
- setCurrentAction(undefined);
93
- }
94
- }, [loading, liveRecalling]);
95
-
96
72
  useEffect(() => {
97
73
  if (response) {
98
74
  //@ts-ignore
@@ -102,14 +78,11 @@ function ConfirmOrder() {
102
78
  // @ts-ignore
103
79
  description: response?.message || 'Order confirmed successfully',
104
80
  });
105
- setShouldPerformAction(true);
106
81
  setRecalling(true);
107
82
  setTimeout(() => {
108
83
  setRecalling(false);
109
84
  }, 2000);
110
85
  } else {
111
- setShouldPerformAction(false);
112
-
113
86
  notification.error({
114
87
  message: 'Error',
115
88
  description:
@@ -128,6 +101,7 @@ function ConfirmOrder() {
128
101
 
129
102
  const ConfirmOrder = async () => {
130
103
  setRecalling(false);
104
+ setRecallOrders(false);
131
105
 
132
106
  const keysToRemovefromOrders = [
133
107
  'order_locked',
@@ -159,6 +133,7 @@ function ConfirmOrder() {
159
133
  if (response && response?.data?.length > 0) {
160
134
  setOrderDetails(response?.data[0]);
161
135
  setPrevOrderDetails(response?.data[0]);
136
+ setRecallOrders(true);
162
137
  } else {
163
138
  setOrderDetails(prevOrderDetails);
164
139
  }
@@ -4,13 +4,21 @@ import {
4
4
  } from '@bjsdistribution/dms-component-library';
5
5
  import React from 'react';
6
6
  import styled from 'styled-components';
7
- import { useCurrentAction, useOrderDetails } from '../../../store';
7
+ import {
8
+ useCurrentAction,
9
+ useGlobalStateHitAuditLog,
10
+ useGlobalStateHitOrder,
11
+ useOrderDetails,
12
+ } from '../../../store';
8
13
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
9
14
 
10
15
  function OrderLock() {
11
16
  const [, setCurrentAction] = useCurrentAction();
12
17
  const [orderDetails, setOrderdetails] = useOrderDetails();
13
18
  const lockOrder = useUpdateOrder();
19
+ const [, setRecallOrders] = useGlobalStateHitOrder();
20
+ const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
21
+
14
22
  const title =
15
23
  orderDetails?.order_locked === true ? 'Unlocking Order' : 'Locking Order';
16
24
  const action = orderDetails?.order_locked === true ? 'Unlock' : 'Lock';
@@ -20,12 +28,16 @@ function OrderLock() {
20
28
  };
21
29
 
22
30
  const onComplete = async () => {
31
+ setRecallOrders(false);
23
32
  const isLocked =
24
33
  orderDetails?.order_locked === null ? false : orderDetails?.order_locked;
25
34
  const payload = [{ id: orderDetails?.id, order_locked: !isLocked }];
26
35
  const response = await lockOrder(payload);
27
36
  if (response.data) {
28
37
  setOrderdetails(response.data[0]);
38
+ setOrderdetails(response?.data[0]);
39
+ setRecallAuditLog(true);
40
+ setRecallOrders(true);
29
41
  }
30
42
  onClose();
31
43
  };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
3
3
  import styled from 'styled-components';
4
4
  import SplitOrderTable from './SplitOrderTable';
@@ -37,28 +37,23 @@ function SplitOrder() {
37
37
  const onSubmitSplitOrder = () => {
38
38
  if (orderId) {
39
39
  setPerformAction(true);
40
- //@ts-ignore
41
- if (response?.data && response?.code === 200) {
42
- notification.success({
43
- message: 'Success',
44
- description:
45
- //@ts-ignore
46
- response?.message || 'Sucess',
47
- });
48
- } else {
49
- // alert(response?.error_traceback);
50
- notification.error({
51
- message: 'Error',
52
- description:
53
- //@ts-ignore
54
- response?.message ||
55
- 'An error has occurred. Please try again later.',
56
- });
57
- }
58
- setSelectedSplit([]);
59
40
  }
60
41
  };
61
42
 
43
+ useEffect(() => {
44
+ //@ts-ignore
45
+ if (response?.code === 200) {
46
+ notification.success({
47
+ message: 'Success',
48
+ description:
49
+ //@ts-ignore
50
+ response?.message || 'Sucess',
51
+ });
52
+ setCurrentAction(undefined);
53
+ setSelectedSplit([]);
54
+ }
55
+ }, [response]);
56
+
62
57
  const isSubmitDisabled = () => {
63
58
  if (seledtedSplitOrder?.length > 0) {
64
59
  return !seledtedSplitOrder;
@@ -11,6 +11,7 @@ import {
11
11
  useUpdateApiCall,
12
12
  useLiveRecalling,
13
13
  useGlobalStateHitAuditLog,
14
+ useGlobalStateHitOrder,
14
15
  } from '../../../store';
15
16
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
16
17
  import { compareOrderDetailsStates, filterObject } from '../../../utils';
@@ -25,6 +26,8 @@ function OrderDetailsFooter() {
25
26
  const [, setCallApi] = useUpdateApiCall(); //single detail
26
27
  const [, setRecalling] = useLiveRecalling();
27
28
  const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
29
+ const [, setRecallOrders] = useGlobalStateHitOrder();
30
+
28
31
  const errorFound = () => {
29
32
  const isError =
30
33
  errorState?.w3wError.length > 0 ||
@@ -77,9 +80,12 @@ function OrderDetailsFooter() {
77
80
  };
78
81
 
79
82
  const onSave = async () => {
83
+ setRecallAuditLog(false);
84
+ setRecallOrders(false);
80
85
  const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
81
86
  const response = await updateOrder([payload]);
82
87
  setCallApi(false);
88
+ setRecallOrders(true);
83
89
  // setLogsCallAPi(prev => !prev);
84
90
  if (response && response?.data?.length > 0) {
85
91
  setOrderDetails(response?.data[0]);
@@ -21,7 +21,7 @@ function DepotDropdown() {
21
21
  return (
22
22
  <FormContainer>
23
23
  <Label label="Depot" htmlFor="depotDropdown" />
24
- <SelectDropdown
24
+ <StyledSelectDropdown
25
25
  placeholder="Select Depot"
26
26
  inputId="depotDropdown"
27
27
  openMenuOnFocus={false}
@@ -33,7 +33,7 @@ function DepotDropdown() {
33
33
  styles={{
34
34
  ...dropdownStyles,
35
35
 
36
- control: styles => ({
36
+ control: (styles: any) => ({
37
37
  ...styles,
38
38
  borderRadius: '25px',
39
39
  cursor: 'pointer',
@@ -50,5 +50,7 @@ const FormContainer = styled.div`
50
50
  gap: 6px;
51
51
  flex: 1;
52
52
  `;
53
-
53
+ export const StyledSelectDropdown = styled(SelectDropdown)`
54
+ min-width: 160px;
55
+ `;
54
56
  export default DepotDropdown;
@@ -52,7 +52,8 @@ function ScheduleAfter() {
52
52
  onChange={onChange}
53
53
  value={scheduleDate === null ? scheduleDate : dayjs(scheduleDate)}
54
54
  format="DD/MM/YY"
55
- style={{ borderRadius: '25px' }}
55
+ disabledDate={current => current && current < dayjs().startOf('day')}
56
+ allowClear={false}
56
57
  />
57
58
  </MainContainer>
58
59
  );
@@ -1,8 +1,9 @@
1
- import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
1
+ import { Label } from '@bjsdistribution/dms-component-library';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { vehicleTypeOptions } from '../../helper';
5
5
  import { useOrderDetails } from '../../../store';
6
+ import { StyledSelectDropdown } from './Depot';
6
7
 
7
8
  function VehicleTypeDropdown() {
8
9
  const [orderDetails, setOrderDetails] = useOrderDetails();
@@ -18,7 +19,7 @@ function VehicleTypeDropdown() {
18
19
  return (
19
20
  <FormContainer>
20
21
  <Label label="Vehicle Type" htmlFor="vehicleType" />
21
- <SelectDropdown
22
+ <StyledSelectDropdown
22
23
  placeholder="Select vehicle type"
23
24
  options={vehicleTypeOptions}
24
25
  inputId="vehicleType"
@@ -477,6 +477,13 @@ export function useGlobalStateHitAuditLog() {
477
477
  return useAtom(globalStateHitAuditLog);
478
478
  }
479
479
 
480
+ const globalOrderGetApi = atom<boolean>(true);
481
+
482
+ export function useGlobalStateHitOrder() {
483
+ return useAtom(globalOrderGetApi);
484
+ }
485
+
486
+
480
487
  // Popup state Manage
481
488
  const initialState = null;
482
489