@bjsdistribution/dms-client-return 0.0.95-prod → 0.0.96-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.0.95-prod",
2
+ "version": "0.0.96-prod",
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.3.14-prod",
62
+ "@bjsdistribution/dms-component-library": "0.3.19-dev",
63
63
  "@size-limit/preset-small-lib": "^11.0.1",
64
64
  "@tippyjs/react": "^4.2.6",
65
65
  "@types/react": "^18.2.47",
@@ -34,3 +34,14 @@ export interface ApiResponse {
34
34
  error_traceback: string | null;
35
35
  data: any[];
36
36
  }
37
+
38
+ export interface ClientType {
39
+ id: number;
40
+ name: string;
41
+ client_id: number;
42
+ parent_client_id: number;
43
+ domain: string;
44
+ url: string;
45
+ master_key: string;
46
+ phoneline: string;
47
+ }
@@ -11,7 +11,6 @@ import {
11
11
  StyledTableWrapper,
12
12
  CustomDrop,
13
13
  } from '../../return-order-table/return-orders-filters/returnstyles';
14
- import LoadIcon from '../../../../assets/icons/LoadIcon';
15
14
  import { useLoading, usePrintOptionTOggle } from '../../store/store';
16
15
  import { NavLink } from 'react-router-dom';
17
16
  import { displayValueOrNA, formatDate } from '../../shared/utlis';
@@ -380,9 +379,6 @@ const OrderTable = () => {
380
379
  )}
381
380
  </li>
382
381
  </CustomDrop>
383
- <li className="downloadcontainer">
384
- <LoadIcon />
385
- </li>
386
382
  </ul>
387
383
  </td>
388
384
  </tr>
@@ -26,6 +26,7 @@ import {
26
26
  useLiveRecalling,
27
27
  useGlobalStateHitOrder,
28
28
  useAtom,
29
+ usegetClientData,
29
30
  } from './store';
30
31
  import { OrdersType } from './types';
31
32
  import { useLocation } from 'react-router-dom';
@@ -35,6 +36,7 @@ import { useSubContracterData } from '../store';
35
36
  import Notification from './notification';
36
37
  import Order from './order-resources/expanded-content';
37
38
  import { setResourcesCall, useAllOrderStatus } from './order-actions/store';
39
+ import { ClientType } from '../order-daily-overview/common/interface';
38
40
 
39
41
  interface ApiResponse {
40
42
  message: string;
@@ -69,6 +71,8 @@ function OrderView() {
69
71
  const [recallOrders] = useGlobalStateHitOrder();
70
72
  const [, setStatusVal] = useAllOrderStatus();
71
73
  const order_id = orderDetails?.id;
74
+ const [getResources] = useAtom(setResourcesCall);
75
+ const [, setClientData] = usegetClientData();
72
76
 
73
77
  useEffect(() => {
74
78
  setStatusVal(orderDetails?.status_value);
@@ -222,7 +226,29 @@ function OrderView() {
222
226
  }
223
227
  }, [statusDataLoading, fetchedStatusData]);
224
228
 
225
- const [getResources] = useAtom(setResourcesCall);
229
+ const {
230
+ fetchData: callCLientApi,
231
+ loading: clientLoading,
232
+ data: clientData,
233
+ } = useAxios<{
234
+ data: ClientType[];
235
+ }>({
236
+ endpoint: `/v1/client/list`,
237
+ method: 'GET',
238
+ });
239
+
240
+ useEffect(() => {
241
+ if (orderId) {
242
+ callCLientApi();
243
+ }
244
+ }, [orderId]);
245
+
246
+ useEffect(() => {
247
+ if (clientData && clientData?.data) {
248
+ const res = clientData?.data;
249
+ setClientData(res);
250
+ }
251
+ }, [clientLoading]);
226
252
 
227
253
  useEffect(() => {
228
254
  setLoading(depotDataLoading);
@@ -97,7 +97,10 @@ const NewReturnDropdown = () => {
97
97
  showSearch
98
98
  dropdownStyle={{ width: 'max-content' }}
99
99
  popupClassName={defaultPopupClassName}
100
- status={selectedOrderId ? '' : 'error'}
100
+ status={
101
+ dropdownOptions.length === 0 ? '' : selectedOrderId ? '' : 'error'
102
+ }
103
+ notFoundContent="No orders found with a similar postcode"
101
104
  />
102
105
  </Container>
103
106
  );
@@ -1,23 +1,51 @@
1
1
  import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
- import { useOrderDetails, useStatusDetails } from '../../../store';
5
- import { useSubContracterData } from '../../../../store';
4
+ import {
5
+ usegetClientData,
6
+ useOrderDetails,
7
+ useStatusDetails,
8
+ } from '../../../store';
9
+ import { useClientPortal, useSubContracterData } from '../../../../store';
6
10
 
7
11
  function Carrier() {
8
12
  const [orderDetails, setOrderDetails] = useOrderDetails();
9
13
  const [subContracterData] = useSubContracterData();
10
14
  const [orderStatus] = useStatusDetails();
15
+ const [isClientPortal] = useClientPortal();
16
+ const [clientData] = usegetClientData();
11
17
 
12
- const carrierOptions = subContracterData?.map((carrier: any) => ({
13
- label: carrier.name,
14
- value: carrier.id,
15
- }));
18
+ const localClientData = JSON.parse(
19
+ localStorage?.getItem('Client_iD') || '{}'
20
+ );
21
+ const clientId = Number(localClientData?.client_id);
22
+
23
+ // Build options from subContracterData
24
+ const carrierOptions =
25
+ subContracterData?.map((carrier: any) => ({
26
+ label: carrier?.name,
27
+ value: carrier?.id,
28
+ })) || [];
29
+
30
+ // find the value which is selected
31
+ const selectedCarrierOption = carrierOptions?.find(
32
+ (option: any) => option?.value === orderDetails?.carrier_id
33
+ );
34
+
35
+ // get client name when no carrierid found
36
+ const fallbackClientName = clientData?.find(
37
+ (client: any) => Number(client?.client_id) === clientId
38
+ )?.name;
39
+
40
+ // fall if no carrierid
41
+ const fallbackOption = fallbackClientName
42
+ ? { label: fallbackClientName, value: '' }
43
+ : null;
16
44
 
17
45
  const onChange = (selectedOption: any) => {
18
46
  setOrderDetails(prev => ({
19
47
  ...prev,
20
- carrier_id: selectedOption.value,
48
+ carrier_id: selectedOption?.value,
21
49
  }));
22
50
  };
23
51
 
@@ -28,15 +56,13 @@ function Carrier() {
28
56
  placeholder="Select Carrier"
29
57
  inputId="CarrierDropdown"
30
58
  openMenuOnFocus={false}
31
- value={
32
- carrierOptions.find(
33
- (option: any) => option.value === orderDetails?.carrier_id
34
- ) || null
35
- }
59
+ value={selectedCarrierOption || fallbackOption || null}
36
60
  options={carrierOptions}
37
61
  onChange={onChange}
38
62
  isDisabled={
39
- orderStatus?.length > 0 && orderStatus[0]?.confirmed === true
63
+ isClientPortal
64
+ ? true
65
+ : orderStatus?.length > 0 && orderStatus[0]?.confirmed === true
40
66
  }
41
67
  />
42
68
  </FormContainer>
@@ -8,7 +8,10 @@ import {
8
8
  UnRecieveOrderProduct,
9
9
  UpdateOrderProduct,
10
10
  } from './types';
11
- import { ClientData } from '../order-daily-overview/common/interface';
11
+ import {
12
+ ClientData,
13
+ ClientType,
14
+ } from '../order-daily-overview/common/interface';
12
15
  // OrderActionsType
13
16
  const activeTabAtom = atom<string>('active');
14
17
  const infoAtom = atom<boolean | undefined>(false);
@@ -403,11 +406,18 @@ const returnAfterOrderAtom = atom<any[]>([]);
403
406
  export function useReturnAfterOrderData() {
404
407
  return useAtom(returnAfterOrderAtom);
405
408
  }
409
+
406
410
  const clientDataAtom = atom<ClientData[]>([]);
407
411
  function useClientData() {
408
412
  return useAtom(clientDataAtom);
409
413
  }
410
414
 
415
+ const clientData = atom<ClientType[]>([]);
416
+
417
+ export function usegetClientData() {
418
+ return useAtom(clientData);
419
+ }
420
+
411
421
  export {
412
422
  useAtom,
413
423
  useOrderDetails,