@bjsdistribution/dms-client-return 0.0.94-prod → 0.0.95-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/assets/icons/ArrowDownIcon.d.ts +6 -0
- package/dist/assets/icons/DeliverProductIcon.d.ts +3 -0
- package/dist/assets/icons/ReturnProductIcon.d.ts +3 -0
- package/dist/common/checkbox/index.d.ts +2 -0
- package/dist/common/modals/order-action-modal/OrderActionModal.d.ts +3 -1
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.d.ts +1 -0
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.d.ts +2 -2
- package/dist/components/order-view/flags-action-modal/Actions.d.ts +6 -2
- package/dist/components/order-view/flags-action-modal/Dropdowns.d.ts +1 -0
- package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
- package/dist/components/order-view/notification/FlagTemplate.d.ts +1 -1
- package/dist/components/order-view/notification/OrderTemplate.d.ts +1 -1
- package/dist/components/order-view/notification/Tabs.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.d.ts +5 -0
- package/dist/components/order-view/order-actions/actions/cancel-order/index.d.ts +7 -1
- package/dist/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/charge-log/index.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.d.ts +1 -13
- package/dist/components/order-view/order-actions/actions/create-task-reminder/TaskModal.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/create-task-reminder/index.d.ts +6 -2
- package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +6 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +5 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +7 -1
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.d.ts +5 -0
- package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +6 -1
- package/dist/components/order-view/order-actions/store.d.ts +10 -8
- package/dist/components/order-view/order-actions/types.d.ts +38 -60
- package/dist/components/order-view/order-actions/utils.d.ts +2 -1
- package/dist/components/order-view/store.d.ts +48 -3
- package/dist/components/order-view/types.d.ts +11 -0
- package/dist/components/order-view/utils.d.ts +1 -0
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +5 -1
- package/dist/components/order-view/view-reminder/reminder-styles.d.ts +3 -1
- package/dist/components/store.d.ts +2 -1
- package/dist/dms-client-return.cjs.development.js +4812 -3095
- 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 +4815 -3098
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/ArrowDownIcon.tsx +28 -0
- package/src/assets/icons/DeliverProductIcon.tsx +42 -0
- package/src/assets/icons/ReturnProductIcon.tsx +23 -0
- package/src/common/checkbox/index.tsx +60 -17
- package/src/common/modals/order-action-modal/OrderActionModal.tsx +13 -7
- package/src/common/radio-group/RadioButtonGroup.tsx +3 -4
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +29 -26
- package/src/components/order-daily-overview/header-filters/filterStore.ts +6 -8
- package/src/components/order-daily-overview/index.tsx +20 -7
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +2 -2
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +19 -19
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +11 -9
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +19 -4
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +41 -59
- package/src/components/order-daily-overview/table/ReturnTable.tsx +1 -30
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +52 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +37 -43
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +75 -44
- package/src/components/order-view/fakedata.ts +7 -6
- package/src/components/order-view/flags-action-modal/Actions.tsx +51 -25
- package/src/components/order-view/flags-action-modal/DetailSection.tsx +5 -5
- package/src/components/order-view/flags-action-modal/Dropdowns.tsx +75 -89
- package/src/components/order-view/flags-action-modal/Header.tsx +32 -23
- package/src/components/order-view/flags-action-modal/TextSection.tsx +9 -6
- package/src/components/order-view/flags-action-modal/index.tsx +54 -67
- package/src/components/order-view/general-information/dropdowns/Print.tsx +136 -70
- package/src/components/order-view/generic-table/AuditLogs.tsx +5 -4
- package/src/components/order-view/index.tsx +9 -42
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +20 -18
- package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -10
- package/src/components/order-view/notes/logs/index.tsx +1 -1
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +5 -7
- package/src/components/order-view/notification/FlagTemplate.tsx +8 -8
- package/src/components/order-view/notification/OrderTemplate.tsx +169 -175
- package/src/components/order-view/notification/ReminderTemplate.tsx +23 -14
- package/src/components/order-view/notification/Tabs.tsx +15 -14
- package/src/components/order-view/notification/index.tsx +164 -92
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +19 -29
- package/src/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.tsx +345 -0
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -71
- package/src/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.tsx +95 -32
- package/src/components/order-view/order-actions/actions/charge-log/index.tsx +395 -0
- package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +34 -17
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +39 -25
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +4 -2
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +254 -66
- package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +13 -9
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +1 -1
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +213 -117
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +97 -152
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +30 -87
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +77 -83
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +57 -65
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +10 -16
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +21 -4
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +39 -11
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +79 -8
- package/src/components/order-view/order-actions/actions/send-email/SendEmailModal.tsx +114 -17
- package/src/components/order-view/order-actions/actions/send-sms/SendSmsModal.tsx +115 -7
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +14 -4
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +176 -87
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.tsx +352 -0
- package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +35 -59
- package/src/components/order-view/order-actions/index.tsx +237 -22
- package/src/components/order-view/order-actions/store.ts +50 -48
- package/src/components/order-view/order-actions/types.ts +40 -65
- package/src/components/order-view/order-actions/utils.ts +15 -8
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +80 -39
- package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +10 -14
- package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +10 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +2 -1
- package/src/components/order-view/products-info/expanded-content/index.tsx +3 -2
- package/src/components/order-view/products-info/index.tsx +14 -11
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +26 -24
- package/src/components/order-view/store.ts +59 -2
- package/src/components/order-view/system-event-logs/columns/Date.tsx +4 -2
- package/src/components/order-view/system-event-logs/columns/Event.tsx +9 -9
- package/src/components/order-view/system-event-logs/columns/Note.tsx +1 -1
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +25 -25
- package/src/components/order-view/types.ts +13 -0
- package/src/components/order-view/utils.ts +4 -0
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +183 -12
- package/src/components/order-view/view-reminder/ViewReminder.tsx +234 -143
- package/src/components/order-view/view-reminder/reminder-styles.tsx +14 -8
- package/src/components/store.ts +6 -0
- package/src/index.tsx +28 -18
package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
useCategoryData,
|
|
4
|
-
useCreateTaskPayload,
|
|
5
|
-
useNotiifcationLabel,
|
|
6
|
-
useTaskTypeData,
|
|
7
|
-
useTaskTypeExtended,
|
|
8
|
-
} from '../../store';
|
|
9
|
-
import { priorityData, transformOption } from '../../utils';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useCreateTaskPayload, useStaticData } from '../../store';
|
|
10
3
|
import {
|
|
11
4
|
FormRow,
|
|
12
5
|
SplitContainer,
|
|
@@ -17,188 +10,106 @@ import RadioButtonGroup from '../../../../../common/radio-group/RadioButtonGroup
|
|
|
17
10
|
import styled from 'styled-components';
|
|
18
11
|
import { isValid } from 'date-fns';
|
|
19
12
|
import { TextArea } from '@bjsdistribution/dms-component-library';
|
|
20
|
-
import { StandardOptionsType } from '../../../../../common/radio-group/types';
|
|
21
13
|
import { DatePicker } from 'antd';
|
|
22
14
|
import dayjs from 'dayjs';
|
|
23
15
|
import { DatePickerWrap } from '../modalstyle';
|
|
16
|
+
import { priorityData } from '../../utils';
|
|
24
17
|
|
|
25
18
|
function CreateTaskModal() {
|
|
26
|
-
const [
|
|
27
|
-
const [
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(option: any) => ({
|
|
40
|
-
label: option.name,
|
|
41
|
-
value: option.id,
|
|
42
|
-
color: option.color,
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// Options for task types
|
|
47
|
-
const selectTaskTypeOptions = taskTypes.map((option: any) =>
|
|
48
|
-
transformOption(option, 'type')
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
// Options for category types
|
|
52
|
-
const categoryOptions = CategoryData.map((option: any) =>
|
|
53
|
-
transformOption(option, 'category')
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
//handlePriority change
|
|
57
|
-
const handlePriorityChange = (event: any) => {
|
|
58
|
-
const newValue = event.target.value;
|
|
59
|
-
setPriority(newValue);
|
|
60
|
-
setPayload(prevState => ({
|
|
61
|
-
...prevState,
|
|
62
|
-
task_priority_id: newValue,
|
|
19
|
+
const [staticData] = useStaticData();
|
|
20
|
+
const [apiPayload, setApiPayload] = useCreateTaskPayload();
|
|
21
|
+
const taskTypeOptions = getTaskTypeOptions(staticData);
|
|
22
|
+
const priorityOptions = getPriorityOptions(staticData);
|
|
23
|
+
|
|
24
|
+
const handleTaskTypeChange = (value: any) => {
|
|
25
|
+
const selectedType = staticData?.[0]?.order_flag_types?.find(
|
|
26
|
+
(type: any) => type.id === value
|
|
27
|
+
)?.type;
|
|
28
|
+
|
|
29
|
+
setApiPayload(prev => ({
|
|
30
|
+
...prev,
|
|
31
|
+
flag_type: selectedType || '',
|
|
63
32
|
}));
|
|
64
33
|
};
|
|
65
34
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
task_categories_id: value,
|
|
35
|
+
const handlePriorityChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
36
|
+
const value = parseInt(e.target.value, 10);
|
|
37
|
+
setApiPayload((prev: any) => ({
|
|
38
|
+
...prev,
|
|
39
|
+
priority: value,
|
|
72
40
|
}));
|
|
73
|
-
const filteredSubCategories = subCategory
|
|
74
|
-
.filter((subCat: any) => subCat.category_id == value)
|
|
75
|
-
.map((subCat: any) => ({
|
|
76
|
-
label: subCat.sub_category,
|
|
77
|
-
value: subCat.id,
|
|
78
|
-
}));
|
|
79
|
-
setSubCategoryOptions(filteredSubCategories);
|
|
80
41
|
};
|
|
81
42
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
43
|
+
const handleDescriptionChange = (
|
|
44
|
+
e: React.ChangeEvent<HTMLTextAreaElement>
|
|
45
|
+
) => {
|
|
46
|
+
const val = e.target.value;
|
|
47
|
+
setApiPayload(prev => ({
|
|
48
|
+
...prev,
|
|
49
|
+
description: val,
|
|
87
50
|
}));
|
|
88
51
|
};
|
|
89
52
|
|
|
90
|
-
//task type change
|
|
91
|
-
const handleTaskType = (event: any) => {
|
|
92
|
-
const selectedOption = selectTaskTypeOptions.find(
|
|
93
|
-
(option: any) => option.value === event
|
|
94
|
-
);
|
|
95
|
-
const label = selectedOption ? selectedOption.label : '';
|
|
96
|
-
|
|
97
|
-
setLabel(label);
|
|
98
|
-
setPayload(prevState => ({
|
|
99
|
-
...prevState,
|
|
100
|
-
task_type_id: event,
|
|
101
|
-
}));
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
//description change
|
|
105
|
-
const handleChange = (event: any) => {
|
|
106
|
-
const desc = event.target.value;
|
|
107
|
-
setPayload(prevState => ({
|
|
108
|
-
...prevState,
|
|
109
|
-
description: desc,
|
|
110
|
-
}));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// date change here
|
|
114
53
|
const handleDateChange = (date: any | null) => {
|
|
115
|
-
if (date && isValid(date
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
due_datetime: formattedDateTime,
|
|
54
|
+
if (date && isValid(date.$d)) {
|
|
55
|
+
const formatted = date.$d.toISOString();
|
|
56
|
+
setApiPayload(prev => ({
|
|
57
|
+
...prev,
|
|
58
|
+
due_datetime: formatted,
|
|
121
59
|
}));
|
|
122
60
|
} else {
|
|
123
|
-
|
|
124
|
-
...
|
|
125
|
-
due_datetime:
|
|
61
|
+
setApiPayload(prev => ({
|
|
62
|
+
...prev,
|
|
63
|
+
due_datetime: '',
|
|
126
64
|
}));
|
|
127
65
|
}
|
|
128
66
|
};
|
|
129
|
-
|
|
130
67
|
return (
|
|
131
68
|
<Wrapper>
|
|
132
69
|
<SplitContainer>
|
|
133
70
|
<FormRow label="Task Type" required>
|
|
134
71
|
<StyledAntSelect
|
|
135
|
-
options={
|
|
72
|
+
options={taskTypeOptions}
|
|
136
73
|
placeholder="Select Type"
|
|
137
|
-
onChange={
|
|
138
|
-
value={
|
|
74
|
+
onChange={handleTaskTypeChange}
|
|
75
|
+
value={apiPayload?.flag_type || null}
|
|
139
76
|
/>
|
|
140
77
|
</FormRow>
|
|
141
78
|
|
|
142
|
-
<FormRow label="
|
|
143
|
-
<StyledAntSelect
|
|
144
|
-
options={[]}
|
|
145
|
-
placeholder="Select User"
|
|
146
|
-
onChange={handleSelectChange}
|
|
147
|
-
style={{ minWidth: '20vw' }}
|
|
148
|
-
/>
|
|
149
|
-
<StyledLink>Assign to me</StyledLink>
|
|
150
|
-
</FormRow>
|
|
151
|
-
<FormRow label="Priority">
|
|
79
|
+
<FormRow label="Priority" required>
|
|
152
80
|
<RadioButtonGroup
|
|
153
81
|
heading=""
|
|
154
|
-
options={priorityOptions}
|
|
82
|
+
options={priorityOptions || []}
|
|
155
83
|
onChange={handlePriorityChange}
|
|
156
84
|
direction="horizontal"
|
|
157
|
-
selectedValue={
|
|
85
|
+
selectedValue={apiPayload?.priority || 3}
|
|
158
86
|
required={false}
|
|
159
87
|
/>
|
|
160
88
|
</FormRow>
|
|
89
|
+
|
|
161
90
|
<FormRow label="Due Date & Time" required>
|
|
162
91
|
<StyleContainer>
|
|
163
92
|
<DatePickerWrap>
|
|
164
93
|
<DatePicker
|
|
165
|
-
format="DD/MM/YYYY HH:mm"
|
|
94
|
+
format="DD/MM/YYYY HH:mm A"
|
|
166
95
|
value={
|
|
167
|
-
|
|
168
|
-
? dayjs(
|
|
96
|
+
apiPayload?.due_datetime
|
|
97
|
+
? dayjs(apiPayload?.due_datetime)
|
|
169
98
|
: null
|
|
170
99
|
}
|
|
171
100
|
onChange={handleDateChange}
|
|
172
101
|
placeholder="Select Date & Time"
|
|
173
102
|
showTime={{ defaultValue: dayjs('00:00', 'HH:mm') }}
|
|
103
|
+
disabledDate={current =>
|
|
104
|
+
current && current < dayjs().startOf('day')
|
|
105
|
+
}
|
|
106
|
+
disabledTime={date => getDisabledTime(date)}
|
|
174
107
|
/>
|
|
175
108
|
</DatePickerWrap>
|
|
176
109
|
</StyleContainer>
|
|
177
110
|
</FormRow>
|
|
178
|
-
|
|
179
|
-
{createTask?.task_type_id !== 11 && (
|
|
180
|
-
<>
|
|
181
|
-
<FormRow label="Category">
|
|
182
|
-
<StyledAntSelect
|
|
183
|
-
style={{ minWidth: '20vw' }}
|
|
184
|
-
options={categoryOptions}
|
|
185
|
-
placeholder="Select Category"
|
|
186
|
-
onChange={handleCategoryChange}
|
|
187
|
-
value={createTask?.task_categories_id}
|
|
188
|
-
/>
|
|
189
|
-
</FormRow>
|
|
190
|
-
<FormRow label="Type">
|
|
191
|
-
<StyledAntSelect
|
|
192
|
-
options={subCategoryOptions}
|
|
193
|
-
placeholder="Select Type"
|
|
194
|
-
onChange={handleTypeChange}
|
|
195
|
-
style={{ minWidth: '20vw' }}
|
|
196
|
-
value={createTask?.task_subcategories_id}
|
|
197
|
-
/>
|
|
198
|
-
</FormRow>
|
|
199
|
-
</>
|
|
200
|
-
)}
|
|
201
111
|
</SplitContainer>
|
|
112
|
+
|
|
202
113
|
<SplitContainer>
|
|
203
114
|
<Label>
|
|
204
115
|
Description
|
|
@@ -207,25 +118,59 @@ function CreateTaskModal() {
|
|
|
207
118
|
<StyledTextArea
|
|
208
119
|
placeholder="Add Description"
|
|
209
120
|
required
|
|
210
|
-
onChange={
|
|
211
|
-
value={
|
|
121
|
+
onChange={handleDescriptionChange}
|
|
122
|
+
value={apiPayload?.description || ''}
|
|
212
123
|
/>
|
|
213
124
|
</SplitContainer>
|
|
214
125
|
</Wrapper>
|
|
215
126
|
);
|
|
216
127
|
}
|
|
128
|
+
|
|
129
|
+
const getTaskTypeOptions = (staticData: any) => {
|
|
130
|
+
return (
|
|
131
|
+
staticData?.[0]?.order_flag_types?.map((item: any) => ({
|
|
132
|
+
label: item?.type,
|
|
133
|
+
value: item?.id,
|
|
134
|
+
})) || []
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const getPriorityOptions = (staticData: any) => {
|
|
139
|
+
return staticData?.[0]?.priorities?.map((option: any) => {
|
|
140
|
+
const colorMatch = priorityData?.find(p => p.id === option.id);
|
|
141
|
+
return {
|
|
142
|
+
label: option.name,
|
|
143
|
+
value: option.id,
|
|
144
|
+
color: colorMatch?.color || '#ccc',
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const getDisabledTime = (date: any) => {
|
|
150
|
+
if (date && date.isSame(dayjs(), 'day')) {
|
|
151
|
+
const currentHour = dayjs().hour();
|
|
152
|
+
const currentMinute = dayjs().minute();
|
|
153
|
+
return {
|
|
154
|
+
disabledHours: () =>
|
|
155
|
+
Array.from({ length: 24 }, (_, i) => i).filter(
|
|
156
|
+
hour => hour < currentHour
|
|
157
|
+
),
|
|
158
|
+
disabledMinutes: (selectedHour: number) => {
|
|
159
|
+
if (selectedHour === currentHour) {
|
|
160
|
+
return Array.from({ length: 60 }, (_, i) => i).filter(
|
|
161
|
+
minute => minute < currentMinute
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
return [];
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {};
|
|
169
|
+
};
|
|
170
|
+
|
|
217
171
|
const StyleContainer = styled.div`
|
|
218
172
|
border-radius: 20px;
|
|
219
|
-
background:
|
|
220
|
-
`;
|
|
221
|
-
const StyledLink = styled.div`
|
|
222
|
-
color: var(--contextual-blue, #6396e5);
|
|
223
|
-
font-family: Lato;
|
|
224
|
-
font-size: 13px;
|
|
225
|
-
font-style: normal;
|
|
226
|
-
font-weight: 400;
|
|
227
|
-
line-height: 16px;
|
|
228
|
-
cursor: pointer;
|
|
173
|
+
background: #fff;
|
|
229
174
|
`;
|
|
230
175
|
|
|
231
176
|
const Label = styled.label`
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import {
|
|
3
4
|
RadioButtonGroup,
|
|
4
5
|
useApiHook,
|
|
5
6
|
useAxios,
|
|
6
7
|
} from '@bjsdistribution/dms-component-library';
|
|
7
8
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
9
|
+
import { CustomOptions } from '../../../../fakeData';
|
|
8
10
|
import {
|
|
9
11
|
initialPayload,
|
|
10
|
-
|
|
11
|
-
useCategoryData,
|
|
12
|
+
useStaticData,
|
|
12
13
|
useCreateTaskPayload,
|
|
13
|
-
useDepartmentData,
|
|
14
|
-
useNotificationData,
|
|
15
14
|
useNotiifcationLabel,
|
|
16
|
-
useTaskPriority,
|
|
17
|
-
useTaskTypeData,
|
|
18
|
-
useTaskTypeExtended,
|
|
19
15
|
} from '../../store';
|
|
20
16
|
import { allTypes } from '../../types';
|
|
21
|
-
import {
|
|
22
|
-
import { useCurrentAction, useOrderDetails } from '../../../store';
|
|
17
|
+
import { useCurrentAction } from '../../../store';
|
|
23
18
|
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
24
19
|
import styled from 'styled-components';
|
|
25
|
-
import CreateTaskModal from './CreateTaskModal';
|
|
26
|
-
import { CustomOptions } from '../../../../fakeData';
|
|
27
20
|
import { notification } from 'antd';
|
|
21
|
+
import { ContentContainer } from '../modalstyle';
|
|
22
|
+
import CreateTaskModal from './CreateTaskModal';
|
|
28
23
|
|
|
29
24
|
interface ApiResponse {
|
|
30
25
|
message: string;
|
|
@@ -33,98 +28,65 @@ interface ApiResponse {
|
|
|
33
28
|
error_traceback: string | null;
|
|
34
29
|
data: allTypes[];
|
|
35
30
|
}
|
|
31
|
+
interface IProps {
|
|
32
|
+
callReminderApi: any;
|
|
33
|
+
callUnresolvedTaskApi: any;
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
function TaskModal() {
|
|
36
|
+
function TaskModal(props: IProps) {
|
|
38
37
|
const [, setCurrentAction] = useCurrentAction();
|
|
39
|
-
const [
|
|
40
|
-
const [staticData, setStaticData] = useAllStaticData();
|
|
41
|
-
const [, setPriority] = useTaskPriority();
|
|
42
|
-
const [, setTaskCategory] = useCategoryData();
|
|
43
|
-
const [, setTaskTypes] = useTaskTypeData();
|
|
44
|
-
const [, setTaskTypeExtended] = useTaskTypeExtended();
|
|
45
|
-
const [, setDepartmentData] = useDepartmentData();
|
|
46
|
-
const [, setNotififcationData] = useNotificationData();
|
|
38
|
+
const [taskPayload, setTaskPayload] = useCreateTaskPayload();
|
|
47
39
|
const [, setLabel] = useNotiifcationLabel();
|
|
48
|
-
const [
|
|
49
|
-
|
|
50
|
-
// API Call
|
|
51
|
-
const { data: fetchedStaticData } = useApiHook<ApiResponse>({
|
|
52
|
-
endpoint: `/tasks/getStaticData/all/`,
|
|
53
|
-
method: 'GET',
|
|
54
|
-
});
|
|
40
|
+
const [, setStaticData] = useStaticData();
|
|
55
41
|
|
|
56
|
-
//create task API
|
|
57
42
|
const { fetchData: createFlagAPI } = useAxios<{
|
|
58
43
|
data: ApiResponse[];
|
|
59
44
|
}>({
|
|
60
|
-
endpoint: `/
|
|
45
|
+
endpoint: `/v1/task/`,
|
|
61
46
|
method: 'POST',
|
|
62
47
|
});
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fetchData: callUnresolvedTaskApi,
|
|
67
|
-
data: fetchedUnresolvedData,
|
|
68
|
-
loading: unresolvedLoading,
|
|
69
|
-
} = useAxios<{
|
|
70
|
-
data: ApiResponse[];
|
|
71
|
-
}>({
|
|
72
|
-
endpoint: `/tasks/`,
|
|
49
|
+
const { data: fetchedStaticData } = useApiHook<ApiResponse>({
|
|
50
|
+
endpoint: `/v1/task/getStaticData/all/`,
|
|
73
51
|
method: 'GET',
|
|
74
|
-
pagination: { is_pagination: false },
|
|
75
|
-
filters: [{ field: 'order_id', op: '=', value: orderDetails?.id }],
|
|
76
52
|
});
|
|
77
53
|
|
|
78
54
|
useEffect(() => {
|
|
79
55
|
if (fetchedStaticData) {
|
|
80
|
-
setStaticData(fetchedStaticData
|
|
56
|
+
setStaticData(fetchedStaticData?.data);
|
|
81
57
|
}
|
|
82
58
|
}, [fetchedStaticData]);
|
|
83
59
|
|
|
84
|
-
//extracted types from whole static data
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (staticData) {
|
|
87
|
-
setPriority(staticData?.map(data => data.tasks_priority).flat());
|
|
88
|
-
setTaskTypes(staticData?.map(data => data.tasks_types).flat());
|
|
89
|
-
setTaskCategory(staticData?.map(data => data.task_categories).flat());
|
|
90
|
-
setTaskTypeExtended(
|
|
91
|
-
staticData?.map(data => data.task_sub_categories).flat()
|
|
92
|
-
);
|
|
93
|
-
setDepartmentData(staticData?.map(data => data.department).flat());
|
|
94
|
-
}
|
|
95
|
-
}, [staticData]);
|
|
96
|
-
|
|
97
60
|
const handleRadioButtonChange = (event: any) => {
|
|
98
61
|
const selectedValue = event.target.value;
|
|
99
62
|
const isPrivateValue = selectedValue === 'private';
|
|
100
|
-
|
|
63
|
+
setTaskPayload(prevState => ({
|
|
101
64
|
...prevState,
|
|
102
65
|
is_private: isPrivateValue,
|
|
103
66
|
}));
|
|
104
67
|
};
|
|
68
|
+
|
|
105
69
|
const closeModal = () => {
|
|
106
70
|
setCurrentAction(undefined);
|
|
107
|
-
|
|
71
|
+
setTaskPayload(initialPayload);
|
|
108
72
|
setLabel('');
|
|
109
73
|
};
|
|
110
74
|
|
|
111
75
|
const handleTaskSubmit = async () => {
|
|
112
|
-
let response = (await createFlagAPI({
|
|
113
|
-
payload: { flags: [createTask] },
|
|
114
|
-
})) as {
|
|
76
|
+
let response = (await createFlagAPI({ payload: [taskPayload] })) as {
|
|
115
77
|
code: number | null;
|
|
116
78
|
error?: string | null | undefined;
|
|
117
79
|
[key: string]: any;
|
|
118
80
|
};
|
|
119
|
-
if (response
|
|
81
|
+
if (response.code == 200 && response?.data) {
|
|
82
|
+
closeModal();
|
|
120
83
|
notification.success({
|
|
121
84
|
message: 'Success',
|
|
122
85
|
description: `${response.message}`,
|
|
123
86
|
});
|
|
124
|
-
callUnresolvedTaskApi();
|
|
125
|
-
closeModal();
|
|
87
|
+
await props?.callUnresolvedTaskApi();
|
|
126
88
|
}
|
|
127
|
-
if (response?.code == null && response
|
|
89
|
+
if (response?.code == null && response?.error) {
|
|
128
90
|
return notification.error({
|
|
129
91
|
message: 'Failure',
|
|
130
92
|
description: `${response.error}`,
|
|
@@ -132,42 +94,23 @@ function TaskModal() {
|
|
|
132
94
|
}
|
|
133
95
|
};
|
|
134
96
|
|
|
135
|
-
//flags data set
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
if (fetchedUnresolvedData && fetchedUnresolvedData.data) {
|
|
138
|
-
setNotififcationData(fetchedUnresolvedData?.data);
|
|
139
|
-
}
|
|
140
|
-
}, [unresolvedLoading]);
|
|
141
|
-
|
|
142
97
|
const isSubmitDisabled = () => {
|
|
143
|
-
const { description, due_datetime,
|
|
144
|
-
return !description || !due_datetime || !
|
|
98
|
+
const { description, due_datetime, flag_type, priority } = taskPayload;
|
|
99
|
+
return !description || !due_datetime || !flag_type || !priority;
|
|
145
100
|
};
|
|
146
101
|
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
if (orderDetails && orderDetails?.id && orderDetails?.customer_id) {
|
|
149
|
-
setPayload((prevState: any) => ({
|
|
150
|
-
...prevState,
|
|
151
|
-
order_id: orderDetails?.id,
|
|
152
|
-
customer_id: orderDetails?.customer_id,
|
|
153
|
-
associated_object_id: 1,
|
|
154
|
-
associated_object_name: 'orders',
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
}, []);
|
|
158
|
-
|
|
159
102
|
return (
|
|
160
103
|
<>
|
|
161
104
|
<OrderModal
|
|
162
105
|
headerTitle={'CREATE TASK'}
|
|
163
106
|
onCloseHeader={closeModal}
|
|
164
107
|
onSubmit={handleTaskSubmit}
|
|
165
|
-
submitBtnTitle={'Save
|
|
108
|
+
submitBtnTitle={'Save Details'}
|
|
166
109
|
isSubmitDisabled={isSubmitDisabled()}
|
|
167
110
|
footerActions={
|
|
168
111
|
<RadioButtonGroup
|
|
169
112
|
selectedValue={
|
|
170
|
-
|
|
113
|
+
taskPayload?.is_private == true ? 'private' : 'public'
|
|
171
114
|
}
|
|
172
115
|
options={CustomOptions}
|
|
173
116
|
onChange={handleRadioButtonChange}
|