@omniumretail/shared-resources 0.1.68 → 0.1.70

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.
@@ -0,0 +1,13 @@
1
+ import { UseQueryOptions } from "@tanstack/react-query";
2
+ import { Store, ResponseList } from "../../interfaces";
3
+ interface LocationsByUserQueryProps extends UseQueryOptions<Store> {
4
+ records: number | string;
5
+ sortBy: string;
6
+ sortDirection: string;
7
+ page: number;
8
+ tags?: string;
9
+ advancedTags?: string;
10
+ filter?: any;
11
+ }
12
+ export declare const getLocationsByUserQuery: ({ records, sortBy, sortDirection, tags, advancedTags, filter, page, ...options }: LocationsByUserQueryProps, userId: string) => import("@tanstack/react-query").UseQueryResult<ResponseList<"UserLocations", Store>, unknown>;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { UseQueryOptions } from "@tanstack/react-query";
2
+ import { Store, ResponseList } from "../../interfaces";
3
+ interface StoreQueryProps extends UseQueryOptions<Store> {
4
+ records: number | string;
5
+ sortBy: string;
6
+ sortDirection: string;
7
+ page: number;
8
+ tags?: string;
9
+ advancedTags?: string;
10
+ filter?: any;
11
+ }
12
+ export declare const useAllStoreQuery: ({ records, sortBy, sortDirection, tags, advancedTags, filter, page, ...options }: StoreQueryProps) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Locations", Store>, unknown>;
13
+ export {};
@@ -1,5 +1,7 @@
1
1
  export * from './Store/useStoreQuery';
2
2
  export * from './Store/useStoreByCodeQuery.hook';
3
+ export * from './Store/useAllStoreQuery.hook';
4
+ export * from './Store/getLocationsByUser.hook';
3
5
  export * from './EvaluationCycle/get/useEvaluationCycleIdQuery.hook';
4
6
  export * from './EvaluationCycle/mutate/useEvaluationCycleMutateQuery.hook';
5
7
  export * from './EvaluationCycle/others/activateEvaluationCycleQuery.hook';
@@ -39,7 +41,6 @@ export * from './AprProduct/get/useProductsQuery.hook';
39
41
  export * from './AprProduct/get/useProductHierarchies.hook';
40
42
  export * from './AprProduct/get/useProductRecommendations.hook';
41
43
  export * from './AprProduct/get/useProductsByRefQuery.hook';
42
- export * from './Roles/get/useAllStoreQuery.hook';
43
44
  export * from './Roles/get/useAllRolesQuery.hook';
44
45
  export * from './AsvProduct/get/getProductsByRefQuery.hook';
45
46
  export * from './AsvProduct/get/getProductsByStoreQuery.hook';
@@ -1,7 +1,31 @@
1
1
  export interface Store {
2
2
  Id: string;
3
3
  Name: string;
4
- Address: string;
5
4
  City: string;
6
5
  ZipCode: string;
6
+ Code: string;
7
+ CompanyId: string;
8
+ ParentLocationId: string;
9
+ Type: StoreType;
10
+ Address: StoreAdress;
11
+ Phone: string;
12
+ Email: string;
13
+ AdditionalFields: StoreAdditionalFields[];
14
+ Status: string;
15
+ IsSelected: boolean;
16
+ }
17
+ export interface StoreType {
18
+ Id: string;
19
+ Name: string;
20
+ Type: string;
21
+ }
22
+ export interface StoreAdress {
23
+ Street: string;
24
+ CountryISO2: string;
25
+ ZipCode: string;
26
+ City: string;
27
+ }
28
+ export interface StoreAdditionalFields {
29
+ Name: string;
30
+ Value: string;
7
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/shared-resources",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "private": false,
5
5
  "description": "Shared Components and services or utils to the frontend versions",
6
6
  "main": "dist/bundle.js",
@@ -0,0 +1,39 @@
1
+ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
2
+ import { Store, ResponseList } from "../../interfaces";
3
+ import { getAuth0 } from "../../services";
4
+
5
+ interface LocationsByUserQueryProps extends UseQueryOptions<Store> {
6
+ records: number | string;
7
+ sortBy: string;
8
+ sortDirection: string;
9
+ page: number;
10
+ tags?: string;
11
+ advancedTags?: string;
12
+ filter?: any;
13
+ }
14
+
15
+ export const getLocationsByUserQuery = ({ records, sortBy, sortDirection, tags, advancedTags, filter, page, ...options }: LocationsByUserQueryProps, userId: string) => {
16
+ const pQueryValue = advancedTags && filter
17
+ ? `${advancedTags} and ${filter}`
18
+ : advancedTags
19
+ ? advancedTags
20
+ : filter
21
+ ? filter
22
+ : null;
23
+
24
+ return useQuery(['LOCATIONS_BY_USER_QUERY', records, sortBy, sortDirection, tags, advancedTags, filter, page, userId],
25
+ () => getAuth0<ResponseList<"UserLocations", Store>>(`/AACP/Users/${userId}/Locations`, {
26
+ pPage: page || 1,
27
+ pRecords: records || 50,
28
+ pSortBy: sortBy,
29
+ pSortDirection: sortDirection,
30
+ pTerms: tags,
31
+ ...(pQueryValue ? { pQuery: pQueryValue } : {}),
32
+ }),
33
+ {
34
+ keepPreviousData: true,
35
+ }
36
+ );
37
+ }
38
+
39
+
@@ -1,6 +1,6 @@
1
1
  import { useQuery, UseQueryOptions } from "@tanstack/react-query";
2
- import { Store, ResponseList } from "../../../interfaces";
3
- import { get } from "../../../services";
2
+ import { Store, ResponseList } from "../../interfaces";
3
+ import { get } from "../../services";
4
4
 
5
5
  interface StoreQueryProps extends UseQueryOptions<Store> {
6
6
  records: number | string;
@@ -1,6 +1,8 @@
1
1
  //Stores
2
2
  export * from './Store/useStoreQuery';
3
3
  export * from './Store/useStoreByCodeQuery.hook'
4
+ export * from './Store/useAllStoreQuery.hook';
5
+ export * from './Store/getLocationsByUser.hook';
4
6
 
5
7
  //EvaluationCycle
6
8
  export * from './EvaluationCycle/get/useEvaluationCycleIdQuery.hook';
@@ -54,7 +56,6 @@ export * from './AprProduct/get/useProductRecommendations.hook';
54
56
  export * from './AprProduct/get/useProductsByRefQuery.hook';
55
57
 
56
58
  //Roles
57
- export * from './Roles/get/useAllStoreQuery.hook';
58
59
  export * from './Roles/get/useAllRolesQuery.hook';
59
60
 
60
61
  //AsvProduct
@@ -2,7 +2,34 @@
2
2
  export interface Store {
3
3
  Id: string;
4
4
  Name: string;
5
- Address: string;
6
5
  City: string;
7
6
  ZipCode: string;
7
+ Code: string;
8
+ CompanyId: string;
9
+ ParentLocationId: string;
10
+ Type: StoreType;
11
+ Address: StoreAdress;
12
+ Phone: string;
13
+ Email: string;
14
+ AdditionalFields: StoreAdditionalFields[];
15
+ Status: string;
16
+ IsSelected: boolean;
8
17
  }
18
+
19
+ export interface StoreType {
20
+ Id: string;
21
+ Name: string;
22
+ Type: string;
23
+ }
24
+
25
+ export interface StoreAdress {
26
+ Street: string;
27
+ CountryISO2: string;
28
+ ZipCode: string;
29
+ City: string;
30
+ }
31
+
32
+ export interface StoreAdditionalFields {
33
+ Name: string;
34
+ Value: string;
35
+ }