npm-pkg-hook 1.1.2 → 1.1.4

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.
Files changed (42) hide show
  1. package/.eslintrc.js +132 -132
  2. package/.vscode/extensions.json +6 -0
  3. package/.vscode/settings.json +8 -0
  4. package/next.config.js +1 -0
  5. package/package.json +43 -46
  6. package/src/config/client/errors.js +1 -2
  7. package/src/hooks/index.js +20 -25
  8. package/src/hooks/useAnimationText/index.jsx +13 -11
  9. package/src/hooks/useCatWithProduct/index.js +4 -37
  10. package/src/hooks/useCatWithProduct/queries.js +16 -0
  11. package/src/hooks/useChartData/index.js +156 -182
  12. package/src/hooks/useChartData/useChartData/index.js +197 -0
  13. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -0
  14. package/src/hooks/useCheckbox/index.js +2 -5
  15. package/src/hooks/useClients/index.js +8 -17
  16. package/src/hooks/useCreateProduct/index.js +64 -94
  17. package/src/hooks/useDrag/index.js +1 -0
  18. package/src/hooks/useEmployee/index.js +8 -11
  19. package/src/hooks/useFormTools/index.js +1 -1
  20. package/src/hooks/useFullScreenMode/index.js +8 -8
  21. package/src/hooks/useGoogleLogin/index.js +161 -0
  22. package/src/hooks/useGoogleLogin/loadScript.js +15 -0
  23. package/src/hooks/useGoogleLogin/removeScript.js +7 -0
  24. package/src/hooks/useHover/index.js +1 -1
  25. package/src/hooks/useImagesStore/index.js +144 -176
  26. package/src/hooks/useImagesStore/queries.js +28 -1
  27. package/src/hooks/useKeypress/index.js +1 -7
  28. package/src/hooks/useLogout/index.js +27 -22
  29. package/src/hooks/useManageQueryParams/index.js +1 -1
  30. package/src/hooks/useProductsFood/queriesStore.js +16 -3
  31. package/src/hooks/useReport/index.js +30 -26
  32. package/src/hooks/useReport/queries.js +32 -47
  33. package/src/hooks/useSales/index.js +21 -52
  34. package/src/hooks/useSales/queries.js +38 -48
  35. package/src/hooks/useSales/useGetSale.js +2 -16
  36. package/src/hooks/useSchedule/index.jsx +23 -0
  37. package/src/hooks/useUpdateExistingOrders/index.js +8 -8
  38. package/src/hooks/useUser/index.js +2 -2
  39. package/src/hooks/useUser/queries.js +40 -40
  40. package/src/hooks/useWindowSize/index.js +1 -1
  41. package/src/index.jsx +1 -2
  42. package/src/security/index.js +0 -0
@@ -1,13 +1,12 @@
1
1
  import { gql } from '@apollo/client'
2
2
 
3
3
  export const GET_ALL_SALES = gql`
4
- query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime, $channel: Int) {
5
- getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate, channel: $channel) {
4
+ query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
5
+ getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
6
6
  totalProductsPrice
7
+ channel
7
8
  pDatCre
8
9
  pCodeRef
9
- change
10
- channel
11
10
  }
12
11
  }
13
12
  `
@@ -22,33 +21,19 @@ query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $
22
21
  }
23
22
  `
24
23
  export const GET_ALL_SALES_STATISTICS = gql`
25
- query getAllSalesStoreStatistic(
26
- $idStore: ID
27
- $search: String
28
- $min: Int
29
- $max: Int
30
- $fromDate: DateTime
31
- $toDate: DateTime
32
- ) {
33
- getAllSalesStoreStatistic(
34
- idStore: $idStore
35
- search: $search
36
- min: $min
37
- max: $max
38
- toDate: $toDate
39
- fromDate: $fromDate
40
- ) {
41
- pdpId
42
- idStore
43
- pCodeRef
44
- payMethodPState
45
- pPRecoger
46
- totalProductsPrice
47
- pSState
48
- pDatCre
49
- locationUser
50
- pDatMod
51
- getAllPedidoStore {
24
+ query getAllSalesStoreStatistic($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
25
+ getAllSalesStoreStatistic(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
26
+ pdpId
27
+ idStore
28
+ pCodeRef
29
+ payMethodPState
30
+ pPRecoger
31
+ totalProductsPrice
32
+ pSState
33
+ pDatCre
34
+ locationUser
35
+ pDatMod
36
+ getAllPedidoStore{
52
37
  pdpId
53
38
  pId
54
39
  idStore
@@ -64,26 +49,26 @@ export const GET_ALL_SALES_STATISTICS = gql`
64
49
  comments
65
50
  cantProducts
66
51
  pId
67
- productFood {
68
- pId
69
- carProId
70
- colorId
71
- idStore
72
- pName
73
- ProPrice
74
- ProDescuento
75
- ProDescription
76
- ValueDelivery
77
- ProImage
78
- ProStar
79
- pState
80
- pDatCre
81
- pDatMod
82
- }
52
+ productFood{
53
+ pId
54
+ carProId
55
+ colorId
56
+ idStore
57
+ pName
58
+ ProPrice
59
+ ProDescuento
60
+ ProDescription
61
+ ValueDelivery
62
+ ProImage
63
+ ProStar
64
+ pState
65
+ pDatCre
66
+ pDatMod
83
67
  }
84
68
  }
85
69
  }
86
70
  }
71
+ }
87
72
  `
88
73
 
89
74
  export const GET_ONE_SALES = gql`
@@ -1,4 +1,5 @@
1
1
  import {
2
+ from,
2
3
  useApolloClient,
3
4
  useLazyQuery,
4
5
  useMutation
@@ -20,11 +21,12 @@ import {
20
21
  GET_ONE_PRODUCTS_FOOD,
21
22
  } from "../useProductsFood/queriesStore";
22
23
  import { useStore } from "../useStore";
23
- import { CREATE_SHOPPING_CARD_TO_USER_STORE, GET_ALL_COUNT_SALES } from "./queries";
24
- import { useLogout } from "../useLogout";
25
- import { updateExistingOrders } from "../useUpdateExistingOrders";
26
- import { useGetSale } from "../useSales/useGetSale";
24
+ import {
25
+ CREATE_SHOPPING_CARD_TO_USER_STORE,
26
+ GET_ALL_COUNT_SALES
27
+ } from "./queries";
27
28
  export * from './useGetAllSales'
29
+ export { GET_ALL_COUNT_SALES } from './queries'
28
30
 
29
31
  const initialState = {
30
32
  PRODUCT: [],
@@ -49,10 +51,9 @@ const initializer = (initialValue = initialState) => {
49
51
 
50
52
  export const useSales = ({
51
53
  disabled,
54
+ sendNotification,
52
55
  router,
53
- sendNotification = () => { return },
54
- setAlertBox = () => { return },
55
- setSalesOpen = () => { return },
56
+ setAlertBox,
56
57
  }) => {
57
58
  const domain = getCurrentDomain();
58
59
  const [loadingSale, setLoadingSale] = useState(false);
@@ -83,31 +84,22 @@ export const useSales = ({
83
84
  const [loadingExtraProduct, setLoadingExtraProduct] = useState(false);
84
85
  const [dataOptional, setDataOptional] = useState([]);
85
86
  const [dataExtra, setDataExtra] = useState([]);
86
- const [onClickLogout] = useLogout({ setAlertBox })
87
87
 
88
88
  const [registerSalesStore, { loading: loadingRegisterSale }] = useMutation(
89
89
  CREATE_SHOPPING_CARD_TO_USER_STORE,
90
90
  {
91
91
  onCompleted: (data) => {
92
92
  const message = `${data?.registerSalesStore?.Response?.message}`;
93
- const isSuccess = data?.registerSalesStore?.Response.success === true
94
- const error = isSuccess
93
+ const error = data?.registerSalesStore?.Response.success
95
94
  ? "Éxito"
96
95
  : "Error";
97
- if (message === 'Token expired') {
98
- setSalesOpen(false)
99
- onClickLogout()
100
- }
101
96
  sendNotification({
102
- backgroundColor: isSuccess ? 'success' : 'error',
97
+ backgroundColor: error ? 'success' : 'error',
103
98
  title: error,
104
99
  description: message
105
100
  });
106
101
  setAlertBox({ message: message, type: "success" });
107
-
108
- if (isSuccess) {
109
- setOpenCurrentSale(isSuccess);
110
- }
102
+ setOpenCurrentSale(data?.registerSalesStore?.Response.success);
111
103
  },
112
104
  onError: (error) => {
113
105
  console.log(error)
@@ -762,7 +754,6 @@ export const useSales = ({
762
754
  }
763
755
  const totalProductsPrice = totalProductPrice;
764
756
  const client = useApolloClient()
765
- const { getOnePedidoStore, error: saleError } = useGetSale()
766
757
 
767
758
  const handleSubmit = () => {
768
759
  if (!values?.cliId)
@@ -786,15 +777,14 @@ export const useSales = ({
786
777
  discount: discount.discount || 0,
787
778
  totalProductsPrice: totalProductsPrice || 0,
788
779
  }
789
- }).then((responseRegisterR) => {
780
+ })
781
+ .then((responseRegisterR) => {
790
782
  if (responseRegisterR) {
791
783
  const { data } = responseRegisterR || {};
792
784
  const { registerSalesStore } = data || {};
793
785
  const { Response } = registerSalesStore || {};
794
- const success = Response?.success === true
795
- if (success) {
796
- console.log(responseRegisterR)
797
- if (!process.env.NODE_ENV === 'development') dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
786
+ if (Response && Response.success === true) {
787
+ // dispatch({ type: 'REMOVE_ALL_PRODUCTS' })
798
788
  client.query({
799
789
  query: GET_ALL_COUNT_SALES,
800
790
  fetchPolicy: 'network-only',
@@ -802,28 +792,6 @@ export const useSales = ({
802
792
  client.writeQuery({ query: GET_ALL_COUNT_SALES, data: { getTodaySales: data.countSales.todaySales } })
803
793
  }
804
794
  })
805
- getOnePedidoStore({
806
- variables: {
807
- pCodeRef: code || ''
808
- }
809
- }).then((res) => {
810
- console.log(res)
811
- const currentSale = res?.data?.getOnePedidoStore
812
- if (currentSale && !saleError) {
813
- client.cache.modify({
814
- fields: {
815
- getAllOrdersFromStore(existingOrders = []) {
816
- try {
817
- const cache = updateExistingOrders(existingOrders, code, 4, currentSale)
818
- return cache
819
- } catch (e) {
820
- return existingOrders
821
- }
822
- }
823
- }
824
- })
825
- }
826
- })
827
795
  router.push(
828
796
  {
829
797
  query: {
@@ -834,7 +802,7 @@ export const useSales = ({
834
802
  undefined,
835
803
  { shallow: true }
836
804
  );
837
- if (!process.env.NODE_ENV === 'development') setValues({})
805
+ // setValues({})
838
806
  }
839
807
  }
840
808
  setLoadingSale(false);
@@ -862,17 +830,18 @@ export const useSales = ({
862
830
  const optionalAll = await ExtProductFoodsSubOptionalAll({
863
831
  variables: { pId },
864
832
  });
865
- const optionalFetch = optionalAll?.data?.ExtProductFoodsOptionalAll || [];
833
+ const optionalFetch = optionalAll.data.ExtProductFoodsOptionalAll;
866
834
  setDataOptional(optionalFetch || []);
867
835
  const existOptionalCookies = originalArray?.dataOptional;
868
836
  const filteredDataOptional = existOptionalCookies?.length
869
837
  ? existOptionalCookies
870
838
  ?.map((obj) => {
871
- const filteredSubOptions = obj?.ExtProductFoodsSubOptionalAll?.filter(
872
- (subObj) => subObj?.check === true
839
+ const filteredSubOptions =
840
+ obj.ExtProductFoodsSubOptionalAll.filter(
841
+ (subObj) => subObj.check === true
873
842
  );
874
843
  // Excluya todo el objeto padre si filteredSubOptions está vacío
875
- if (filteredSubOptions?.length === 0) {
844
+ if (filteredSubOptions.length === 0) {
876
845
  return null;
877
846
  }
878
847
  return {
@@ -94,60 +94,52 @@ export const GET_ALL_SALES_STATISTICS = gql`
94
94
  `;
95
95
 
96
96
  export const GET_ONE_SALES = gql`
97
- query getOnePedidoStore($pCodeRef: String) {
98
- getOnePedidoStore(pCodeRef: $pCodeRef) {
99
- pdpId
100
- pCodeRef
101
- idStore
102
- pPDate
103
- channel
104
- change
105
- pSState
106
- pDatCre
107
- id
108
- pDatMod
109
- pPRecoger
110
- payMethodPState
111
- pdpId
112
- totalProductsPrice
113
- locationUser
114
- getUser {
115
- id
116
- email
117
- uPhoNum
118
- ULocation
119
- }
120
- getAllPedidoStore {
97
+ query getOnePedidoStore($pCodeRef: String) {
98
+ getOnePedidoStore(pCodeRef: $pCodeRef) {
121
99
  pdpId
122
- idStore
123
100
  pCodeRef
124
- ShoppingCard
125
- getAllShoppingCard {
101
+ idStore
102
+ pPDate
103
+ channel
104
+ pSState
105
+ pDatCre
106
+ pDatMod
107
+ pPRecoger
108
+ payMethodPState
109
+ pdpId
110
+ totalProductsPrice
111
+ locationUser
112
+ getAllPedidoStore {
113
+ pdpId
114
+ idStore
115
+ pCodeRef
126
116
  ShoppingCard
127
- cantProducts
128
- subProductsId
129
- comments
130
- pId
131
- productFood {
117
+ getAllShoppingCard {
118
+ ShoppingCard
119
+ cantProducts
120
+ subProductsId
121
+ comments
132
122
  pId
133
- carProId
134
- colorId
135
- idStore
136
- pName
137
- ProPrice
138
- ProDescuento
139
- ProDescription
140
- ValueDelivery
141
- ProImage
142
- ProStar
143
- pState
144
- pDatCre
145
- pDatMod
123
+ productFood {
124
+ pId
125
+ carProId
126
+ colorId
127
+ idStore
128
+ pName
129
+ ProPrice
130
+ ProDescuento
131
+ ProDescription
132
+ ValueDelivery
133
+ ProImage
134
+ ProStar
135
+ pState
136
+ pDatCre
137
+ pDatMod
138
+ }
146
139
  }
147
140
  }
148
141
  }
149
142
  }
150
- }
151
143
  `;
152
144
 
153
145
  export const CREATE_CLIENTS = gql`
@@ -266,9 +258,7 @@ export const GET_ONE_SALE = gql`
266
258
  pCodeRef
267
259
  idStore
268
260
  pPDate
269
- id
270
261
  channel
271
- change
272
262
  pSState
273
263
  pDatCre
274
264
  pDatMod
@@ -1,22 +1,8 @@
1
1
  import { useLazyQuery } from '@apollo/client'
2
2
  import { GET_ONE_SALE } from './queries'
3
3
 
4
- export const useGetSale = ({ callback = () => { return } } = {}) => {
5
- const [getOnePedidoStore, {
6
- loading,
7
- data,
8
- called,
9
- error
10
- }] = useLazyQuery(GET_ONE_SALE, {
11
- onCompleted: (res) => {
12
- if (res?.getOnePedidoStore) {
13
- return callback(res)
14
- }
15
- },
16
- onError: () => {
17
- return callback(null)
18
- }
19
- })
4
+ export const useGetSale = () => {
5
+ const [getOnePedidoStore, { loading, data, called, error }] = useLazyQuery(GET_ONE_SALE)
20
6
  return {
21
7
  data: data?.getOnePedidoStore, // actualizado aquí
22
8
  loading,
@@ -0,0 +1,23 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { GET_ONE_SCHEDULE_STORE, GET_SCHEDULE_STORE } from '../useProductsFood/queriesStore'
3
+
4
+ export const useSchedule = ({ day = null }) => {
5
+ const {
6
+ data,
7
+ loading,
8
+ error
9
+ } = useQuery(GET_ONE_SCHEDULE_STORE, { variables: { schDay: day } })
10
+
11
+ return [data?.getOneStoreSchedules, { loading, error }]
12
+ }
13
+
14
+ export const useSchedules = ({ schDay = 1 }) => {
15
+ const {
16
+ data,
17
+ loading,
18
+ error
19
+ } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay } })
20
+
21
+
22
+ return [data?.getStoreSchedules, { loading, error }]
23
+ }
@@ -1,5 +1,5 @@
1
1
  export const isValidCodeRef = (codeRef) => {
2
- return typeof codeRef === 'string' && codeRef.trim() !== '';
2
+ return typeof codeRef === "string" && codeRef.trim() !== "";
3
3
  };
4
4
 
5
5
  export const isValidState = (state) => {
@@ -13,11 +13,11 @@ export const updateExistingOrders = (
13
13
  pSState,
14
14
  objectToAdd
15
15
  ) => {
16
- if (typeof existingOrders !== 'object' || existingOrders === null) {
16
+ if (typeof existingOrders !== "object" || existingOrders === null) {
17
17
  // existingOrders no es un objeto válido
18
18
  return existingOrders;
19
19
  }
20
- if (typeof pCodeRef !== 'string' || typeof pSState !== 'number') {
20
+ if (typeof pCodeRef !== "string" || typeof pSState !== "number") {
21
21
  // Los tipos de datos de pCodeRef y pSState no son los esperados
22
22
  return existingOrders;
23
23
  }
@@ -29,11 +29,11 @@ export const updateExistingOrders = (
29
29
  const updatedExistingOrders = { ...existingOrders }; // Copiar el objeto existente
30
30
 
31
31
  const statusKeys = {
32
- 1: 'ACEPTA',
33
- 2: 'PROCESSING',
34
- 3: 'READY',
35
- 4: 'CONCLUDES',
36
- 5: 'RECHAZADOS',
32
+ 1: "ACEPTA",
33
+ 2: "PROCESSING",
34
+ 3: "READY",
35
+ 4: "CONCLUDES",
36
+ 5: "RECHAZADOS",
37
37
  };
38
38
  const targetArray = statusKeys[pSState];
39
39
 
@@ -1,4 +1,4 @@
1
- import { useQuery, useMutation } from '@apollo/client'
1
+ import { useMutation, useQuery } from '@apollo/client'
2
2
  import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
3
3
 
4
4
  export const useUser = () => {
@@ -8,7 +8,7 @@ export const useUser = () => {
8
8
 
9
9
  export const useUserProfile = () => {
10
10
  const { data, loading, error } = useQuery(GET_USER_PROFILE)
11
- return [data?.getOneUserProfile, { loading, error }]
11
+ return [data, { loading, error }]
12
12
  }
13
13
 
14
14
  export const useSetUserProfile = () => {
@@ -7,6 +7,46 @@ mutation login($input: LoginInput){
7
7
  }
8
8
  }
9
9
  `
10
+ export const GET_USER_PROFILE = gql`
11
+ query getOneUserProfile($id: ID) {
12
+ getOneUserProfile(id: $id){
13
+ upId
14
+ id
15
+ upPhone
16
+ upImage
17
+ upDateBir
18
+ upBloodG
19
+ upAddress
20
+ ctId
21
+ dId
22
+ upZipCode
23
+ cId
24
+ upLatitude
25
+ upLongitude
26
+ user {
27
+ id
28
+ name
29
+ username
30
+ lastName
31
+ email
32
+ avatar
33
+ uToken
34
+ uPhoNum
35
+ ULocation
36
+ upLat
37
+ uState
38
+ upLon
39
+ upIdeDoc
40
+ siteWeb
41
+ description
42
+ password
43
+ createAt
44
+
45
+ }
46
+ }
47
+ }
48
+ `
49
+
10
50
  export const GET_USER = gql`
11
51
  query getUser($id: ID){
12
52
  getUser(id: $id ){
@@ -84,44 +124,4 @@ export const SET_USER_PROFILE = gql`
84
124
  upZipCode
85
125
  }
86
126
  }
87
- `
88
-
89
- export const GET_USER_PROFILE = gql`
90
- query getOneUserProfile($id: ID) {
91
- getOneUserProfile(id: $id){
92
- upId
93
- id
94
- upPhone
95
- upImage
96
- upDateBir
97
- upBloodG
98
- upAddress
99
- ctId
100
- dId
101
- upZipCode
102
- cId
103
- upLatitude
104
- upLongitude
105
- user {
106
- id
107
- name
108
- username
109
- lastName
110
- email
111
- avatar
112
- uToken
113
- uPhoNum
114
- ULocation
115
- upLat
116
- uState
117
- upLon
118
- upIdeDoc
119
- siteWeb
120
- description
121
- password
122
- createAt
123
-
124
- }
125
- }
126
- }
127
127
  `
@@ -1,6 +1,6 @@
1
1
  import { useState, useEffect } from 'react';
2
2
 
3
- export default function useWindowSize() {
3
+ export function useWindowSize() {
4
4
  // Initialize state with undefined width/height so server and client renders match
5
5
  // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
6
6
  const [windowSize, setWindowSize] = useState({
package/src/index.jsx CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './hooks/index'
2
2
  export * from './utils'
3
- export * from './config/client'
4
- export * from './mock'
3
+ export * from './security'
File without changes