@bjsdistribution/dms-client-return 0.1.16-prod → 0.1.17-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/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/client-portal/DateFilterStore.d.ts +15 -0
- package/dist/components/client-portal/ReturnRTFilters.d.ts +3 -0
- package/dist/components/order-daily-overview/header/route-header/ClientRouterHeader.d.ts +11 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- package/dist/components/order-view/order-actions/types.d.ts +2 -2
- package/dist/components/order-view/types.d.ts +6 -0
- package/dist/components/order-view/utils.d.ts +8 -2
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +2 -0
- package/dist/dms-client-return.cjs.development.js +1780 -2272
- package/dist/dms-client-return.cjs.development.js.map +1 -1
- package/dist/dms-client-return.cjs.production.min.js +1 -1
- package/dist/dms-client-return.cjs.production.min.js.map +1 -1
- package/dist/dms-client-return.esm.js +1838 -2330
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/client-portal/DateFilterStore.ts +139 -0
- package/src/components/client-portal/OutstandingTable.tsx +16 -72
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +42 -87
- package/src/components/client-portal/ReturnOverview.tsx +11 -2
- package/src/components/client-portal/ReturnRTFilters.tsx +140 -43
- package/src/components/client-portal/ReturnSearchBar.tsx +42 -153
- package/src/components/client-portal/ReturnStatus.tsx +30 -66
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +12 -23
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +9 -86
- package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +166 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +2 -86
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +5 -2
- package/src/components/order-daily-overview/index.tsx +16 -4
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +36 -36
- package/src/components/order-view/notification/ReminderTemplate.tsx +13 -5
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +0 -29
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +86 -28
- package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +35 -20
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +11 -62
- package/src/components/order-view/order-actions/index.tsx +1 -5
- package/src/components/order-view/order-actions/types.ts +2 -2
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +55 -80
- package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx +9 -91
- package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +10 -182
- package/src/components/order-view/store.ts +6 -0
- package/src/components/order-view/types.ts +6 -0
- package/src/components/order-view/utils.ts +0 -33
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +85 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +33 -14
- package/src/components/store.ts +1 -1
- package/src/index.tsx +17 -2
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/helper.d.ts +0 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +0 -3
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +0 -57
- package/src/components/order-view/order-actions/actions/log-service-refusal/helper.ts +0 -26
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +0 -130
|
@@ -30,6 +30,8 @@ import { useReminderData } from '../../store';
|
|
|
30
30
|
|
|
31
31
|
export interface IProps {
|
|
32
32
|
callReminderApi: any;
|
|
33
|
+
callReminderForCount?: any;
|
|
34
|
+
callReminderTableApi?: any;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const ViewReminderModal = (props: IProps) => {
|
|
@@ -70,12 +72,15 @@ const ViewReminderModal = (props: IProps) => {
|
|
|
70
72
|
const handleDateChange = (date: any | null) => {
|
|
71
73
|
if (date && date.isValid()) {
|
|
72
74
|
const selectedDate = date.toISOString();
|
|
73
|
-
|
|
74
75
|
setReminderPayload({
|
|
75
76
|
...reminderPayload,
|
|
76
77
|
due_datetime: selectedDate,
|
|
77
78
|
});
|
|
78
79
|
} else {
|
|
80
|
+
setReminderPayload({
|
|
81
|
+
...reminderPayload,
|
|
82
|
+
due_datetime: null,
|
|
83
|
+
});
|
|
79
84
|
}
|
|
80
85
|
};
|
|
81
86
|
|
|
@@ -177,12 +182,24 @@ const ViewReminderModal = (props: IProps) => {
|
|
|
177
182
|
}
|
|
178
183
|
};
|
|
179
184
|
|
|
185
|
+
const arraysEqual = (a: any = [], b: any = []) => {
|
|
186
|
+
if (a.length !== b.length) return false;
|
|
187
|
+
return a.every((val: any, index: any) => val === b[index]);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const isSameDate = (d1: any, d2: any) => {
|
|
191
|
+
if (!d1 || !d2) return d1 === d2; // both null/undefined
|
|
192
|
+
const date1 = new Date(d1).toISOString();
|
|
193
|
+
const date2 = new Date(d2).toISOString();
|
|
194
|
+
return date1 === date2;
|
|
195
|
+
};
|
|
196
|
+
|
|
180
197
|
const hasReminderChanged = () => {
|
|
181
198
|
if (!reminderDataById || !reminderPayload) return false;
|
|
182
199
|
|
|
183
200
|
const original = {
|
|
184
201
|
due_datetime: reminderDataById?.due_datetime,
|
|
185
|
-
assigned_to: reminderDataById?.assigned_to,
|
|
202
|
+
assigned_to: reminderDataById?.assigned_to || [],
|
|
186
203
|
description: reminderDataById?.description?.trim(),
|
|
187
204
|
department: reminderDataById?.department,
|
|
188
205
|
status: reminderDataById?.status,
|
|
@@ -190,23 +207,23 @@ const ViewReminderModal = (props: IProps) => {
|
|
|
190
207
|
|
|
191
208
|
const updated = {
|
|
192
209
|
due_datetime: reminderPayload?.due_datetime,
|
|
193
|
-
assigned_to: reminderPayload?.assigned_to,
|
|
210
|
+
assigned_to: reminderPayload?.assigned_to || [],
|
|
194
211
|
description: reminderPayload?.description?.trim(),
|
|
195
212
|
department: reminderPayload?.department,
|
|
196
213
|
status: reminderPayload?.status,
|
|
197
214
|
};
|
|
198
215
|
|
|
199
216
|
const baseChanged =
|
|
200
|
-
original?.due_datetime
|
|
201
|
-
original?.assigned_to
|
|
217
|
+
!isSameDate(original?.due_datetime, updated?.due_datetime) ||
|
|
218
|
+
!arraysEqual(original?.assigned_to, updated?.assigned_to) ||
|
|
202
219
|
original?.description !== updated?.description ||
|
|
203
220
|
original?.status !== updated?.status;
|
|
204
221
|
|
|
205
222
|
const shouldCompareDept =
|
|
206
|
-
original
|
|
223
|
+
original?.department !== undefined && updated?.department !== undefined;
|
|
207
224
|
|
|
208
225
|
const departmentChanged = shouldCompareDept
|
|
209
|
-
? original
|
|
226
|
+
? original?.department !== updated?.department
|
|
210
227
|
: false;
|
|
211
228
|
|
|
212
229
|
return baseChanged || departmentChanged;
|
|
@@ -290,10 +307,12 @@ const ViewReminderModal = (props: IProps) => {
|
|
|
290
307
|
<DatePicker
|
|
291
308
|
format="DD/MM/YYYY HH:mm A"
|
|
292
309
|
value={
|
|
293
|
-
reminderPayload?.due_datetime
|
|
294
|
-
?
|
|
310
|
+
reminderPayload?.due_datetime !== undefined
|
|
311
|
+
? reminderPayload.due_datetime
|
|
312
|
+
? dayjs(reminderPayload.due_datetime)
|
|
313
|
+
: null
|
|
295
314
|
: reminderDataById?.due_datetime
|
|
296
|
-
? dayjs(reminderDataById
|
|
315
|
+
? dayjs(reminderDataById.due_datetime)
|
|
297
316
|
: null
|
|
298
317
|
}
|
|
299
318
|
onChange={handleDateChange}
|
|
@@ -318,13 +337,13 @@ const ViewReminderModal = (props: IProps) => {
|
|
|
318
337
|
name="text"
|
|
319
338
|
required
|
|
320
339
|
value={
|
|
321
|
-
reminderPayload?.description
|
|
322
|
-
|
|
323
|
-
|
|
340
|
+
reminderPayload?.description !== undefined
|
|
341
|
+
? reminderPayload.description
|
|
342
|
+
: reminderDataById?.description || ''
|
|
324
343
|
}
|
|
325
344
|
disabled={disabled}
|
|
326
345
|
onChange={onChangeDetails}
|
|
327
|
-
|
|
346
|
+
/>
|
|
328
347
|
</Right>
|
|
329
348
|
</ContentsContainer>
|
|
330
349
|
</OrderActionModal>
|
package/src/components/store.ts
CHANGED
|
@@ -132,7 +132,7 @@ function useSelectedClientAfterOrders() {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
//start date and end date
|
|
135
|
-
const startCPDate = atom<dayjs.Dayjs | null>(
|
|
135
|
+
const startCPDate = atom<dayjs.Dayjs | null>(null);
|
|
136
136
|
|
|
137
137
|
function useStartDate() {
|
|
138
138
|
return useAtom(startCPDate);
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React, { Suspense, useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Navigate,
|
|
4
|
+
Route,
|
|
5
|
+
Routes,
|
|
6
|
+
useLocation,
|
|
7
|
+
useSearchParams,
|
|
8
|
+
} from 'react-router-dom';
|
|
3
9
|
import ReturnTable from './components/order-daily-overview/return-order-table/ReturnTable';
|
|
4
10
|
import ReturnAfterTable from './components/order-daily-overview/return-after-table/ReturnAfterTable';
|
|
5
11
|
import {
|
|
@@ -28,6 +34,7 @@ import OrderViewQueryHandler from './OrderViewQueryHandler';
|
|
|
28
34
|
import OrderView from './components/order-view';
|
|
29
35
|
import ReturnOverview from './components/client-portal/ReturnOverview';
|
|
30
36
|
import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
|
|
37
|
+
import ClientRouterHeader from './components/order-daily-overview/header/route-header/ClientRouterHeader';
|
|
31
38
|
function ReturnClient() {
|
|
32
39
|
notification.config({
|
|
33
40
|
top: 80,
|
|
@@ -46,7 +53,7 @@ function ReturnClient() {
|
|
|
46
53
|
const [, setVisibilityData] = useVisibilityData();
|
|
47
54
|
const [, setOrderStaticData] = useOrderStaticData();
|
|
48
55
|
const [clientPortal, setClientPortal] = useClientPortal();
|
|
49
|
-
|
|
56
|
+
const location = useLocation();
|
|
50
57
|
const userType = JSON.parse(localStorage.getItem('user_type')!);
|
|
51
58
|
|
|
52
59
|
useEffect(() => {
|
|
@@ -117,14 +124,22 @@ function ReturnClient() {
|
|
|
117
124
|
}
|
|
118
125
|
}, [locationloading]);
|
|
119
126
|
|
|
127
|
+
const pathname = location.pathname;
|
|
128
|
+
const isViewPath = /^\/return\/view\/\d+$/.test(pathname);
|
|
129
|
+
|
|
120
130
|
return (
|
|
121
131
|
<>
|
|
132
|
+
{clientPortal && isViewPath && <ClientRouterHeader />}{' '}
|
|
122
133
|
{!clientPortal && <RouterHeader />}
|
|
123
134
|
<Suspense fallback={<LoadingMessage />}>
|
|
124
135
|
{clientPortal ? (
|
|
125
136
|
<Routes>
|
|
126
137
|
<Route path="" element={<Navigate to={'outstanding_return'} />} />
|
|
127
138
|
<Route path=":status" element={<ReturnOverview />} />
|
|
139
|
+
<Route
|
|
140
|
+
path="view/:id"
|
|
141
|
+
element={<OrderView locationloading={locationloading} />}
|
|
142
|
+
/>
|
|
128
143
|
</Routes>
|
|
129
144
|
) : (
|
|
130
145
|
<Routes>
|
package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import RadioButtonGroup from '../../../../../common/radio-group/RadioButtonGroup';
|
|
4
|
-
import { StandardOptionsType } from '@bjsdistribution/dms-component-library';
|
|
5
|
-
|
|
6
|
-
interface IProps {
|
|
7
|
-
refusedDelPointService: any;
|
|
8
|
-
setRefusedDelPointService: React.Dispatch<React.SetStateAction<any>>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const deliveryPoints: StandardOptionsType[] = [
|
|
12
|
-
{
|
|
13
|
-
label: 'Hallway',
|
|
14
|
-
value: 'hallway',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: 'ROC',
|
|
18
|
-
value: 'room_of_choice',
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
function DeliveryPoint(props: IProps) {
|
|
23
|
-
const radioGroupHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
24
|
-
const service = event.target.value;
|
|
25
|
-
props?.setRefusedDelPointService(service);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Container>
|
|
30
|
-
<RadioButtonGroup
|
|
31
|
-
heading="Delivery Point"
|
|
32
|
-
options={deliveryPoints || []}
|
|
33
|
-
onChange={radioGroupHandler}
|
|
34
|
-
direction="horizontal"
|
|
35
|
-
selectedValue={props?.refusedDelPointService}
|
|
36
|
-
required={false}
|
|
37
|
-
/>
|
|
38
|
-
</Container>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const Container = styled.div`
|
|
43
|
-
display: flex;
|
|
44
|
-
/* height: 30px; */
|
|
45
|
-
padding: 1px;
|
|
46
|
-
align-items: flex-start;
|
|
47
|
-
align-self: stretch;
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
export default DeliveryPoint;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { TextArea } from '@bjsdistribution/dms-component-library';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
refusedReason: string;
|
|
7
|
-
setRefusedReason: React.Dispatch<React.SetStateAction<string>>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function Notes(props: IProps) {
|
|
11
|
-
const handleTextChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
12
|
-
props?.setRefusedReason(event.target.value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Container>
|
|
17
|
-
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
|
18
|
-
<Label>Notes</Label> <RequiredAsterisk>*</RequiredAsterisk>
|
|
19
|
-
</div>
|
|
20
|
-
<TextArea
|
|
21
|
-
rows={15}
|
|
22
|
-
onChange={handleTextChange}
|
|
23
|
-
placeholder="Why did the customer refuse the selected service(s)? Add notes..."
|
|
24
|
-
value={props?.refusedReason}
|
|
25
|
-
/>
|
|
26
|
-
</Container>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const RequiredAsterisk = styled.span`
|
|
31
|
-
color: red;
|
|
32
|
-
margin-left: 2px;
|
|
33
|
-
font-size: x-small;
|
|
34
|
-
`;
|
|
35
|
-
const Label = styled.span`
|
|
36
|
-
color: #6a7378;
|
|
37
|
-
font-family: 'Lato', sans-serif;
|
|
38
|
-
font-size: 14px;
|
|
39
|
-
font-style: normal;
|
|
40
|
-
font-weight: 500;
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const Container = styled.div`
|
|
44
|
-
display: flex;
|
|
45
|
-
gap: 5px;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
width: 100%;
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
export default Notes;
|
package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import Checkbox from '../../../../../common/checkbox';
|
|
4
|
-
import { getIcon } from './helper';
|
|
5
|
-
import { useOrderDetails, useOrderStaticData } from '../../../store';
|
|
6
|
-
import { OrderServiceType } from '../../../types';
|
|
7
|
-
interface IProps {
|
|
8
|
-
refusedServices: string[];
|
|
9
|
-
setRefusedServices: React.Dispatch<React.SetStateAction<string[]>>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function OrderServices(props: IProps) {
|
|
13
|
-
const [orderStaticData] = useOrderStaticData();
|
|
14
|
-
const [orderDetails] = useOrderDetails();
|
|
15
|
-
const orderServices = orderDetails?.order_services;
|
|
16
|
-
const orderServicesOptions = orderStaticData?.order_service_list;
|
|
17
|
-
|
|
18
|
-
const onClick = (service: string) => {
|
|
19
|
-
if (props?.refusedServices?.includes(service)) {
|
|
20
|
-
const filteredServices = props?.refusedServices?.filter(
|
|
21
|
-
(item: string) => item !== service
|
|
22
|
-
);
|
|
23
|
-
props?.setRefusedServices(filteredServices);
|
|
24
|
-
} else {
|
|
25
|
-
props?.setRefusedServices((prev: string[]) => [...prev, service]);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Container>
|
|
31
|
-
{orderServicesOptions.map((service: any) => {
|
|
32
|
-
const selected = !!orderServices?.find(
|
|
33
|
-
(s: OrderServiceType) =>
|
|
34
|
-
s?.order_service_list_id === service?.id && s.is_deleted === false
|
|
35
|
-
);
|
|
36
|
-
const isRefused = props?.refusedServices?.includes(service?.type);
|
|
37
|
-
return (
|
|
38
|
-
<Checkbox
|
|
39
|
-
checked={isRefused}
|
|
40
|
-
label={service?.type}
|
|
41
|
-
imageSrc={getIcon(service?.id)}
|
|
42
|
-
enabled={selected}
|
|
43
|
-
onClickCheckbox={onClick}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
})}
|
|
47
|
-
</Container>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const Container = styled.div`
|
|
52
|
-
display: flex;
|
|
53
|
-
gap: 15px;
|
|
54
|
-
flex-wrap: wrap;
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
export default OrderServices;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const baseURL = "/assets/images/";
|
|
2
|
-
|
|
3
|
-
// export type ServiceOffered =
|
|
4
|
-
// | "Assemble"
|
|
5
|
-
// | "Take Packaging Away"
|
|
6
|
-
// | "Disassemble"
|
|
7
|
-
// | "Collect Disposal"
|
|
8
|
-
// | "Unpack Items";
|
|
9
|
-
|
|
10
|
-
export const paths: Record<number, string> = {
|
|
11
|
-
1: 'assembly.svg', //1
|
|
12
|
-
2: 'disassembly.svg', //2
|
|
13
|
-
3: 'unpack_items.svg', //3
|
|
14
|
-
4: 'packaging_removal.svg', //4
|
|
15
|
-
5: 'collect_disposal.svg', //5
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const getSubPath = (input: number): string => {
|
|
19
|
-
const result = paths[input];
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const getIcon = (input: number): string => {
|
|
24
|
-
const subPath = getSubPath(input);
|
|
25
|
-
return `${baseURL}${subPath}`;
|
|
26
|
-
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import DeliveryPoint from './DeliveryPoint';
|
|
5
|
-
import OrderServices from './OrderServices';
|
|
6
|
-
import Notes from './Notes';
|
|
7
|
-
import {
|
|
8
|
-
useCurrentAction,
|
|
9
|
-
useCustomerInfo,
|
|
10
|
-
useOrderDetails,
|
|
11
|
-
} from '../../../store';
|
|
12
|
-
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
13
|
-
import { ApiResponse } from '../../../types';
|
|
14
|
-
import { notification } from 'antd';
|
|
15
|
-
|
|
16
|
-
function LogServiceRefusal(props: any) {
|
|
17
|
-
const [, setCurrentAction] = useCurrentAction();
|
|
18
|
-
// Local States for handling service refusal
|
|
19
|
-
const [refusedReason, setRefusedReason] = useState<string>('');
|
|
20
|
-
const [refusedServices, setRefusedServices] = useState<string[]>([]);
|
|
21
|
-
const [refusedDelPointService, setRefusedDelPointService] = useState<any>('');
|
|
22
|
-
const [customerInfo] = useCustomerInfo();
|
|
23
|
-
const [orderDetails] = useOrderDetails();
|
|
24
|
-
const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
|
|
25
|
-
|
|
26
|
-
const { fetchData: callLogRefusalApi } = useAxios<{
|
|
27
|
-
data: ApiResponse[];
|
|
28
|
-
}>({
|
|
29
|
-
endpoint: `/v1/orders/log-refusal/`,
|
|
30
|
-
method: 'POST',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const onClose = () => {
|
|
34
|
-
setCurrentAction(undefined);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const onSubmit = async () => {
|
|
38
|
-
const allServices =
|
|
39
|
-
refusedDelPointService?.length > 0
|
|
40
|
-
? [...refusedServices, refusedDelPointService]
|
|
41
|
-
: refusedServices;
|
|
42
|
-
const finalPayload = {
|
|
43
|
-
order_id: orderDetails?.id,
|
|
44
|
-
route_id: orderDetails?.order_routes?.route_id,
|
|
45
|
-
refused_reason: refusedReason,
|
|
46
|
-
service_name: allServices,
|
|
47
|
-
};
|
|
48
|
-
try {
|
|
49
|
-
let response = (await callLogRefusalApi({
|
|
50
|
-
payload: finalPayload,
|
|
51
|
-
})) as {
|
|
52
|
-
code: number | null;
|
|
53
|
-
error?: string | null | undefined;
|
|
54
|
-
[key: string]: any;
|
|
55
|
-
};
|
|
56
|
-
if (response.code == 200) {
|
|
57
|
-
notification.success({
|
|
58
|
-
message: 'Success',
|
|
59
|
-
description: `${response?.message}`,
|
|
60
|
-
});
|
|
61
|
-
props?.callOrdersApi();
|
|
62
|
-
} else {
|
|
63
|
-
notification.error({
|
|
64
|
-
message: 'Error',
|
|
65
|
-
description: `${response?.error}`,
|
|
66
|
-
});
|
|
67
|
-
onClose();
|
|
68
|
-
}
|
|
69
|
-
} catch (error) {}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const disableSubmitBtn =
|
|
73
|
-
refusedReason?.length === 0 ||
|
|
74
|
-
(refusedServices?.length === 0 && refusedDelPointService?.length === 0);
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<OrderActionModal
|
|
78
|
-
headerTitle="Service Refusal"
|
|
79
|
-
showAdditionalInfo
|
|
80
|
-
infoText={infoText}
|
|
81
|
-
submitBtnTitle="Log Refusal"
|
|
82
|
-
onCloseHeader={onClose}
|
|
83
|
-
onSubmit={onSubmit}
|
|
84
|
-
isSubmitDisabled={disableSubmitBtn}
|
|
85
|
-
>
|
|
86
|
-
<ContentContainer>
|
|
87
|
-
<Left>
|
|
88
|
-
<DeliveryPoint
|
|
89
|
-
refusedDelPointService={refusedDelPointService}
|
|
90
|
-
setRefusedDelPointService={setRefusedDelPointService}
|
|
91
|
-
/>
|
|
92
|
-
<OrderServices
|
|
93
|
-
refusedServices={refusedServices}
|
|
94
|
-
setRefusedServices={setRefusedServices}
|
|
95
|
-
/>
|
|
96
|
-
</Left>
|
|
97
|
-
<Right>
|
|
98
|
-
<Notes
|
|
99
|
-
refusedReason={refusedReason}
|
|
100
|
-
setRefusedReason={setRefusedReason}
|
|
101
|
-
/>
|
|
102
|
-
</Right>
|
|
103
|
-
</ContentContainer>
|
|
104
|
-
</OrderActionModal>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const ContentContainer = styled.div`
|
|
109
|
-
display: flex;
|
|
110
|
-
padding: 0px 15px;
|
|
111
|
-
align-items: flex-start;
|
|
112
|
-
gap: 10px;
|
|
113
|
-
align-self: stretch;
|
|
114
|
-
`;
|
|
115
|
-
|
|
116
|
-
const Left = styled.div`
|
|
117
|
-
display: flex;
|
|
118
|
-
padding: 15px 12px;
|
|
119
|
-
flex-direction: column;
|
|
120
|
-
justify-content: center;
|
|
121
|
-
align-items: flex-start;
|
|
122
|
-
gap: 15px;
|
|
123
|
-
flex: 1 0 0;
|
|
124
|
-
border-radius: 15px;
|
|
125
|
-
background: #f8fafc;
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
|
-
const Right = styled(Left)``;
|
|
129
|
-
|
|
130
|
-
export default LogServiceRefusal;
|