@bjsdistribution/dms-client-return 0.0.82 → 0.0.83

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.82",
2
+ "version": "0.0.83",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -528,7 +528,7 @@ export const StyledTable = styled.table`
528
528
  export const StyledTableWrapper = styled.div`
529
529
  max-height: 60vh;
530
530
  overflow-x: auto;
531
- min-height: 50vh;
531
+ // min-height: 50vh;
532
532
 
533
533
  .fortables {
534
534
  max-height: 60vh;
@@ -34,6 +34,7 @@ import { notification } from 'antd';
34
34
  // import { useAssignData } from '../store';
35
35
  import DetailsFilters from './details-filters/DetailsFilters';
36
36
  import { useVisibilityData } from '../store';
37
+ import Notification from './notification';
37
38
 
38
39
  interface ApiResponse {
39
40
  message: string;
@@ -354,7 +355,9 @@ function OrderView() {
354
355
  return (
355
356
  <MainContainer>
356
357
  <GeneralHeader />
358
+
357
359
  <DetailsFilters />
360
+ <Notification />
358
361
  <OrderDetails />
359
362
  <ProductsInfo />
360
363
  <SplitLayout>
@@ -4,7 +4,7 @@ import { useApiHook } from '@bjsdistribution/dms-component-library';
4
4
  import { ApiResponse } from '../../types';
5
5
  import { useOrderDetails, useOrderId, useProductDetails } from '../../store';
6
6
  import { Select } from 'antd';
7
- import { useSelectedProducts } from '../../../store';
7
+ import { useNewReturnOrderData, useSelectedProducts } from '../../../store';
8
8
  import { atom, useAtom } from 'jotai';
9
9
 
10
10
  export const payloadAtom = atom<any>(null);
@@ -12,7 +12,7 @@ export const payloadAtom = atom<any>(null);
12
12
  const NewReturnDropdown = () => {
13
13
  const defaultSelectStyle = { width: '100%' };
14
14
  const defaultPopupClassName = 'dropDownStyle';
15
- const [returnOrderData, setReturnOrderData] = useState<any>([]);
15
+ const [returnOrderData, setReturnOrderData] = useNewReturnOrderData();
16
16
  const [selectedOrderId, setSelectedOrderId] = useState<string | null>(null);
17
17
  const [selectedProducts] = useSelectedProducts();
18
18
  const [orderData] = useOrderDetails();
@@ -89,20 +89,33 @@ const NewReturnDropdown = () => {
89
89
  return (
90
90
  <Container>
91
91
  <Text>New Return Order:</Text>
92
- <Select
92
+ <StyledAntSelect
93
93
  options={dropdownOptions}
94
+ value={selectedOrderId}
94
95
  placeholder="Select"
96
+ // @ts-ignore
95
97
  onChange={handleDropdownChange}
96
98
  style={defaultSelectStyle}
97
- disabled={false}
98
99
  showSearch
99
100
  dropdownStyle={{ width: 'max-content' }}
100
101
  popupClassName={defaultPopupClassName}
102
+ status={selectedOrderId ? '' : 'error'}
101
103
  />
102
104
  </Container>
103
105
  );
104
106
  };
105
107
 
108
+ const StyledAntSelect = styled(Select)`
109
+ .ant-select-selector {
110
+ /* width: 22vw; */
111
+ border-radius: 22px;
112
+ }
113
+ .ant-select-clear {
114
+ top: 40% !important;
115
+ font-size: 18px !important;
116
+ }
117
+ `;
118
+
106
119
  const Container = styled.div`
107
120
  display: flex;
108
121
  align-items: center;
@@ -5,7 +5,7 @@ import styled from 'styled-components';
5
5
  import { useReminderRefId } from '../order-actions/store';
6
6
  import { formatDate } from '../order-actions/utils';
7
7
 
8
- function ReminderTemplate({ data }: any) {
8
+ function ReminderTemplate({ data, dismissReminder }: any) {
9
9
  const [, setCurrentAction] = useCurrentAction();
10
10
  const [, setReminderRefId] = useReminderRefId();
11
11
  const openModal = () => {
@@ -15,7 +15,7 @@ function ReminderTemplate({ data }: any) {
15
15
  //getting particular reminder data
16
16
  const handleClick = (Id: number) => {
17
17
  setReminderRefId(Id);
18
- openModal()
18
+ openModal();
19
19
  };
20
20
 
21
21
  const type =
@@ -25,13 +25,12 @@ function ReminderTemplate({ data }: any) {
25
25
  ? 'warn'
26
26
  : 'success';
27
27
 
28
- const titleColor =
29
- data?.reminder_status?.name === 'SD'
30
- ? '#36A053'
31
- : data?.reminder_status?.name === 'pending'
32
- ? '#FEBA30'
33
- : '#3A3630';
34
-
28
+ const titleColor =
29
+ data?.reminder_status?.name === 'SD'
30
+ ? '#36A053'
31
+ : data?.reminder_status?.name === 'pending'
32
+ ? '#FEBA30'
33
+ : '#3A3630';
35
34
 
36
35
  return (
37
36
  <div>
@@ -46,13 +45,13 @@ function ReminderTemplate({ data }: any) {
46
45
  {' '}
47
46
  {data?.reference || 'NA'}{' '}
48
47
  </StyledLink>
49
- {formatDate(data?.due)}, Assigned to : {' '}
48
+ {formatDate(data?.due)}, Assigned to :{' '}
50
49
  </StyledTitle>
51
50
  </>
52
51
  }
53
52
  description={`${data?.details}`}
54
53
  showOkButton={false}
55
- onClose={() => {}}
54
+ onClose={() => dismissReminder(data.id)}
56
55
  />
57
56
  </StyledAlert>
58
57
  </div>
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { useTabType } from '../store';
4
- import OrderTemplate from './OrderTemplate';
4
+ // import OrderTemplate from './OrderTemplate';
5
5
  import FlagTemplate from './FlagTemplate';
6
6
  import ReminderTemplate from './ReminderTemplate';
7
7
 
@@ -10,6 +10,8 @@ function Tabs({
10
10
  closedNotifications,
11
11
  activeReminders,
12
12
  closedReminders,
13
+ dismissReminder,
14
+ dismissFlags,
13
15
  }: any) {
14
16
  const [activeTab] = useTabType();
15
17
 
@@ -25,24 +27,34 @@ function Tabs({
25
27
  <Container className="tab-content">
26
28
  {activeTab === 'active' && (
27
29
  <>
28
- <OrderTemplate />
30
+ {/* <OrderTemplate /> */}
29
31
  {initialReminders.map((item: any, index: any) => (
30
- <ReminderTemplate key={index} data={item} />
32
+ <ReminderTemplate
33
+ key={index}
34
+ data={item}
35
+ dismissReminder={dismissReminder}
36
+ />
31
37
  ))}
32
38
  {initialNotifications.map((item: any, index: any) => (
33
- <FlagTemplate key={index} data={item} />
39
+ <FlagTemplate
40
+ key={index}
41
+ data={item}
42
+ dismissFlags={dismissFlags}
43
+ />
34
44
  ))}
35
45
  <>
36
46
  {additionalReminders.map((item: any, index: any) => (
37
47
  <ReminderTemplate
38
48
  key={index + initialReminders.length}
39
49
  data={item}
50
+ dismissReminder={dismissReminder}
40
51
  />
41
52
  ))}
42
53
  {additionalNotifications.map((item: any, index: any) => (
43
54
  <FlagTemplate
44
55
  key={index + initialNotifications.length}
45
56
  data={item}
57
+ dismissFlags={dismissFlags}
46
58
  />
47
59
  ))}
48
60
  </>
@@ -51,10 +63,18 @@ function Tabs({
51
63
  {activeTab === 'closed' && (
52
64
  <>
53
65
  {closedReminders.map((item: any, index: any) => (
54
- <ReminderTemplate key={index} data={item} />
66
+ <ReminderTemplate
67
+ key={index}
68
+ data={item}
69
+ dismissReminder={dismissReminder}
70
+ />
55
71
  ))}
56
72
  {closedNotifications.map((item: any, index: any) => (
57
- <FlagTemplate key={index} data={item} />
73
+ <FlagTemplate
74
+ key={index}
75
+ data={item}
76
+ dismissFlags={dismissFlags}
77
+ />
58
78
  ))}
59
79
  </>
60
80
  )}
@@ -2,7 +2,7 @@ import {
2
2
  SectionHeader,
3
3
  useApiHook,
4
4
  } from '@bjsdistribution/dms-component-library';
5
- import React, { useEffect } from 'react';
5
+ import React, { useEffect, useState } from 'react';
6
6
  import Tabs from './Tabs';
7
7
  import styled from 'styled-components';
8
8
  import { useInfoType, useOrderDetails, useTabType } from '../store';
@@ -38,6 +38,10 @@ function Notification() {
38
38
  const routeId = OrderData?.order_routes?.route_id;
39
39
  const [, setRouteData] = useRouteDetails();
40
40
  const [orderCount] = useOrderNotify();
41
+ const [activeNotifications, setActiveNotifications] = useState([]);
42
+ const [closedNotifications, setCloseNotifications] = useState([]);
43
+ const [activeReminders, setActiveReminders] = useState([]);
44
+ const [closedReminders, setCloseReminders] = useState([]);
41
45
 
42
46
  const handleTabChange = (tab: string) => {
43
47
  setActiveTab(tab);
@@ -79,19 +83,47 @@ function Notification() {
79
83
  }
80
84
  });
81
85
 
82
- const activeNotifications = notificationData.filter(
83
- (item: any) => item.task_status_id !== 2
84
- );
85
- const closedNotifications = notificationData.filter(
86
- (item: any) => item?.task_status_id === 2
87
- );
86
+ useEffect(() => {
87
+ if (notificationData?.length > 0) {
88
+ setActiveNotifications(
89
+ notificationData?.filter((item: any) => item.task_status_id !== 2)
90
+ );
91
+ setCloseNotifications(
92
+ notificationData?.filter((item: any) => item?.task_status_id === 2)
93
+ );
94
+ }
95
+ }, [notificationData]);
88
96
 
89
- const activeReminders = reminderData.filter(
90
- (item: any) => item.status_id == 1 || item.status_id == 3
91
- );
92
- const closedReminders = reminderData.filter(
93
- (item: any) => item?.status_id === 2
94
- );
97
+ useEffect(() => {
98
+ if (reminderData?.length > 0) {
99
+ setActiveReminders(
100
+ reminderData?.filter(
101
+ (item: any) => item.status_id === 1 || item.status_id === 3
102
+ )
103
+ );
104
+ setCloseReminders(
105
+ reminderData?.filter((item: any) => item?.status_id === 2)
106
+ );
107
+ }
108
+ }, [reminderData]);
109
+
110
+ //dismiss notifcations
111
+ const dismissFlags = (id: any) => {
112
+ setActiveNotifications(prevFlags =>
113
+ prevFlags.filter((flags: any) => flags.id !== id)
114
+ );
115
+ setCloseNotifications(prevFlags =>
116
+ prevFlags.filter((flags: any) => flags.id !== id)
117
+ );
118
+ };
119
+ const dismissReminder = (id: any) => {
120
+ setActiveReminders(prevReminders =>
121
+ prevReminders.filter((reminder: any) => reminder.id !== id)
122
+ );
123
+ setCloseReminders(prevReminders =>
124
+ prevReminders.filter((reminder: any) => reminder.id !== id)
125
+ );
126
+ };
95
127
 
96
128
  const totalActiveCount =
97
129
  activeNotifications.length + activeReminders.length + orderCount;
@@ -136,6 +168,8 @@ function Notification() {
136
168
  closedNotifications={closedNotifications}
137
169
  activeReminders={activeReminders}
138
170
  closedReminders={closedReminders}
171
+ dismissReminder={dismissReminder}
172
+ dismissFlags={dismissFlags}
139
173
  />
140
174
  </TabsWrapper>
141
175
  ) : (
@@ -21,6 +21,7 @@ import { StandardOptionsType } from '../../../../../common/radio-group/types';
21
21
  import dayjs from 'dayjs';
22
22
  import { isValid } from 'date-fns';
23
23
  import utc from 'dayjs/plugin/utc';
24
+ import { useOrderId } from '../../../store';
24
25
  dayjs.extend(utc);
25
26
  dayjs.extend(isValid);
26
27
 
@@ -33,6 +34,7 @@ function CreateReminderModal() {
33
34
  const [subCategory] = useTaskTypeExtended();
34
35
  const [createReminder, setPayload] = useCreateReminderPayload();
35
36
  const [displayDate, setDisplayDate] = useState<any | null>();
37
+ const [orderId] = useOrderId();
36
38
 
37
39
  const handleSelectChange = () => console.log('testing log');
38
40
 
@@ -96,6 +98,7 @@ function CreateReminderModal() {
96
98
  setPayload(prevState => ({
97
99
  ...prevState,
98
100
  details: desc,
101
+ order_id: +orderId,
99
102
  }));
100
103
  };
101
104
 
@@ -107,7 +107,7 @@ const resolvedModalPayload = atom<SingleResolvedPayload>(resolvedValue);
107
107
 
108
108
  const routeDetails = atom<any>({});
109
109
 
110
- const orderNotifyCount = atom<number>(2);
110
+ const orderNotifyCount = atom<number>(0);
111
111
 
112
112
  //errors
113
113
  const errorMessage = atom<any>({
@@ -178,7 +178,6 @@ export function useSelectedSplit() {
178
178
  return useAtom(selectedSplitList);
179
179
  }
180
180
 
181
-
182
181
  export function useLoadingText() {
183
182
  return useAtom(loadingText);
184
183
  }
@@ -10,7 +10,8 @@ import { useOrderId, useOrderStaticData, useProductDetails } from '../../store';
10
10
  import { ApiResponse } from '../../types';
11
11
  import Loader from '../../../order-daily-overview/header/loader/Loader';
12
12
  import { notification } from 'antd';
13
- import { useSelectedProducts } from '../../../store';
13
+ import { useNewReturnOrderData, useSelectedProducts } from '../../../store';
14
+ import styled from 'styled-components';
14
15
 
15
16
  const ReturnProductTable = () => {
16
17
  const [selectedProducts, setSelectedProducts] = useSelectedProducts();
@@ -18,6 +19,7 @@ const ReturnProductTable = () => {
18
19
  const [productData, setProductData] = useProductDetails();
19
20
  const [selectedRowId, setSelectedRowId] = useState<number | null>(null);
20
21
  const [orderId] = useOrderId();
22
+ const [returnOrderData] = useNewReturnOrderData();
21
23
 
22
24
  const handleActionClick = (id: number) => {
23
25
  setSelectedRowId(id);
@@ -93,7 +95,8 @@ const ReturnProductTable = () => {
93
95
  return matchedReason ? matchedReason.label : 'N/A';
94
96
  };
95
97
 
96
- const disableCheckbox = productData?.length == 0;
98
+ const disableCheckbox =
99
+ productData?.length == 0 || returnOrderData?.length == 0;
97
100
 
98
101
  return (
99
102
  <div>
@@ -103,7 +106,7 @@ const ReturnProductTable = () => {
103
106
  <thead>
104
107
  <tr>
105
108
  <th className="emailproductsCheckbox">
106
- <Checkbox
109
+ <StyleCheckbox
107
110
  disabled={disableCheckbox}
108
111
  checked={selectAll}
109
112
  onChange={handleSelectAll}
@@ -123,9 +126,10 @@ const ReturnProductTable = () => {
123
126
  productData?.map((product: any) => (
124
127
  <tr key={product.id}>
125
128
  <td>
126
- <Checkbox
129
+ <StyleCheckbox
127
130
  checked={selectedProducts?.includes(product?.id)}
128
131
  onChange={() => handleSelectProduct(product?.id)}
132
+ disabled={disableCheckbox}
129
133
  />
130
134
  </td>
131
135
  <td>{product?.orders_products_stock?.location || 'N/A'}</td>
@@ -164,4 +168,12 @@ const ReturnProductTable = () => {
164
168
  );
165
169
  };
166
170
 
171
+ const StyleCheckbox = styled(Checkbox)`
172
+ &:disabled {
173
+ background-color: gray;
174
+ cursor: not-allowed;
175
+ opacity: -0.4;
176
+ }
177
+ `;
178
+
167
179
  export default ReturnProductTable;
@@ -10,6 +10,7 @@ export const ReferenceContainer = styled.div`
10
10
  border-radius: 40px;
11
11
  border: 1px solid rgba(0, 0, 0, 0.1);
12
12
  background: #fff;
13
+ margin-top: 15px;
13
14
  `;
14
15
  export const InnerContainer = styled.div`
15
16
  display: flex;
@@ -76,6 +76,8 @@ const locationOptions = atom<any[]>([]);
76
76
 
77
77
  const selectedProductsMove = atom<any>([]);
78
78
 
79
+ const newReturnOrderData = atom<any>([]);
80
+
79
81
  function useReminderData() {
80
82
  return useAtom(reminderTableData);
81
83
  }
@@ -197,6 +199,10 @@ export function useSelectedData() {
197
199
  return useAtom(selectedAssignee);
198
200
  }
199
201
 
202
+ export function useNewReturnOrderData() {
203
+ return useAtom(newReturnOrderData);
204
+ }
205
+
200
206
  export {
201
207
  useAtom,
202
208
  useFilter,
@@ -226,5 +232,5 @@ export {
226
232
  useActionTypeOptions,
227
233
  useLocationOptions,
228
234
  useSelectedProducts,
229
- useVisibilityData
235
+ useVisibilityData,
230
236
  };