@bjsdistribution/dms-client-return 0.1.33-prod → 0.1.34-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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.33-prod",
2
+ "version": "0.1.34-prod",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -34,6 +34,7 @@ import ChargeLog from './actions/charge-log';
34
34
  import ReminderModal from './actions/create-task-reminder';
35
35
  import TaskModal from './actions/create-task-reminder/TaskModal';
36
36
  import ForceDebriefModal from './actions/force-debrief/ForceDebriefModal';
37
+ import { useNavigate } from 'react-router-dom';
37
38
 
38
39
  function OrderActions() {
39
40
  const [currentAction, setCurrentAction] = useCurrentAction();
@@ -47,6 +48,7 @@ function OrderActions() {
47
48
  const [, setLoading] = useLoading();
48
49
  const [, setTasksData] = useTasksData();
49
50
  const [, setReminderNotifyData] = useReminderNotiData();
51
+ const navigate = useNavigate();
50
52
 
51
53
  // call orders api
52
54
 
@@ -58,19 +60,35 @@ function OrderActions() {
58
60
  });
59
61
 
60
62
  useEffect(() => {
61
- setLoading(loading);
62
- if (fetchedData && fetchedData?.data) {
63
- const requiredData = fetchedData?.data;
64
- setOrderDetails(requiredData[0]);
65
- setPrevOrderDetails(requiredData[0]);
66
- setCurrentAction(undefined);
67
- }
68
- if (
69
- (fetchedData && fetchedData?.data === null) ||
70
- fetchedData?.data?.length === 0
71
- ) {
72
- setCurrentAction(undefined);
73
- }
63
+ const fetchData = async () => {
64
+ try {
65
+ setLoading(loading);
66
+
67
+ if (fetchedData && fetchedData?.data) {
68
+ const requiredData = fetchedData?.data;
69
+ setOrderDetails(requiredData[0]);
70
+ setPrevOrderDetails(requiredData[0]);
71
+ setCurrentAction(undefined);
72
+ }
73
+
74
+ if (
75
+ (fetchedData && fetchedData?.data === null) ||
76
+ fetchedData?.data?.length === 0
77
+ ) {
78
+ setCurrentAction(undefined);
79
+ }
80
+ } catch (error) {
81
+ //@ts-ignore
82
+
83
+ if (error?.response?.status === 404) {
84
+ navigate('/404');
85
+ } else {
86
+ console.error('Error fetching order data:', error);
87
+ }
88
+ }
89
+ };
90
+
91
+ fetchData();
74
92
  }, [loading]);
75
93
 
76
94
  // orders api ends