npm-pkg-hook 1.1.5 → 1.1.8

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 (140) hide show
  1. package/.eslintrc.js +19 -113
  2. package/.eslintrc.json +127 -108
  3. package/next.config.js +2 -5
  4. package/package.json +27 -24
  5. package/src/config/client/errors.js +14 -14
  6. package/src/config/client/index.js +1 -1
  7. package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
  8. package/src/hooks/getCategoriesWithProduct/index.js +62 -0
  9. package/src/hooks/getSession/index.js +18 -18
  10. package/src/hooks/index.js +13 -9
  11. package/src/hooks/useAcumulateDate/index.js +1 -1
  12. package/src/hooks/useAnimationFrame/index.js +45 -45
  13. package/src/hooks/useAsideCart/helpers/index.js +22 -0
  14. package/src/hooks/useAsideCart/index.js +156 -0
  15. package/src/hooks/useAsideCart/queries.js +10 -0
  16. package/src/hooks/useBanner/index.js +11 -11
  17. package/src/hooks/useCart/index.js +2 -0
  18. package/src/hooks/useCart/queries.js +164 -0
  19. package/src/hooks/useCart/useCart/helpers/index.js +75 -0
  20. package/src/hooks/useCart/useCart/index.js +411 -0
  21. package/src/hooks/useCart/useGetCart/index.js +31 -0
  22. package/src/hooks/useCatWithProduct/index.js +15 -15
  23. package/src/hooks/useCatWithProduct/queries.js +1 -1
  24. package/src/hooks/useCatWithProductClient/index.js +48 -0
  25. package/src/hooks/useCatWithProductClient/queries.js +55 -0
  26. package/src/hooks/useCategoriesProduct/index.js +12 -12
  27. package/src/hooks/useCategoriesProduct/queries.js +16 -16
  28. package/src/hooks/useCategoryInStore/index.js +39 -36
  29. package/src/hooks/useCategoryInStore/queries.js +78 -78
  30. package/src/hooks/useCategoryStore/index.js +2 -2
  31. package/src/hooks/useChartData/index.js +159 -156
  32. package/src/hooks/useChartData/useChartData/index.js +199 -197
  33. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
  34. package/src/hooks/useCheckbox/index.js +115 -115
  35. package/src/hooks/useClients/index.js +12 -14
  36. package/src/hooks/useClients/queries.js +1 -1
  37. package/src/hooks/useConnection/index.js +20 -21
  38. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
  39. package/src/hooks/useCreateProduct/index.js +22 -19
  40. package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
  41. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
  42. package/src/hooks/useDessert/helpers/index.js +51 -51
  43. package/src/hooks/useDessert/index.js +56 -65
  44. package/src/hooks/useDevices/index.js +35 -36
  45. package/src/hooks/useDevices/queries.js +19 -19
  46. package/src/hooks/useDropzone/index.js +94 -79
  47. package/src/hooks/useDynamicAuth/index.js +13 -13
  48. package/src/hooks/useDynamicAuth/queries.js +24 -24
  49. package/src/hooks/useEmployee/queries.js +1 -1
  50. package/src/hooks/useEvent/index.js +33 -33
  51. package/src/hooks/useFavoriteStores/index.js +19 -0
  52. package/src/hooks/useFavoriteStores/queries.js +47 -0
  53. package/src/hooks/useFetchJson/index.js +25 -25
  54. package/src/hooks/useFingerprintjs/index.js +172 -176
  55. package/src/hooks/useFormTools/index.js +12 -11
  56. package/src/hooks/useFormatDate/index.js +20 -21
  57. package/src/hooks/useFormatNumberPhone/index.js +9 -9
  58. package/src/hooks/useFullScreenMode/index.js +65 -65
  59. package/src/hooks/useGenerateNumberArray/index.js +17 -17
  60. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
  61. package/src/hooks/useGetFoodRecomended/index.js +33 -0
  62. package/src/hooks/useGetFoodRecomended/queries.js +47 -0
  63. package/src/hooks/useGetMinPrice/index.js +8 -0
  64. package/src/hooks/useGetMinPrice/queries.js +7 -0
  65. package/src/hooks/useGetOneStoreRating/index.js +40 -0
  66. package/src/hooks/useGetOneStoreRating/queries.js +18 -0
  67. package/src/hooks/useGoogleLogin/index.js +160 -161
  68. package/src/hooks/useHover/index.js +29 -29
  69. package/src/hooks/useImageOptimization/index.js +15 -15
  70. package/src/hooks/useImageWeight/index.js +18 -19
  71. package/src/hooks/useImagesStore/index.js +139 -140
  72. package/src/hooks/useImagesStore/queries.js +19 -18
  73. package/src/hooks/useInnerHtml/index.js +39 -38
  74. package/src/hooks/useIntersection/index.js +4 -4
  75. package/src/hooks/useKeypress/index.js +28 -28
  76. package/src/hooks/useLazyScript/index.js +35 -36
  77. package/src/hooks/useLocalSorage/index.js +2 -2
  78. package/src/hooks/useLogout/index.js +23 -23
  79. package/src/hooks/useManageQueryParams/index.js +36 -37
  80. package/src/hooks/useMobile/index.js +39 -38
  81. package/src/hooks/useMutateHeight/index.js +15 -16
  82. package/src/hooks/useOrderClient/index.js +5 -0
  83. package/src/hooks/useOrders/index.js +10 -16
  84. package/src/hooks/useOrders/queries.js +1 -1
  85. package/src/hooks/useProductsFood/index.js +32 -32
  86. package/src/hooks/useProductsFood/queriesStore.js +49 -48
  87. package/src/hooks/useProductsFood/useEditProduct.js +2 -4
  88. package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
  89. package/src/hooks/useProviders/index.js +3 -3
  90. package/src/hooks/useProviders/queries.js +31 -31
  91. package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
  92. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
  93. package/src/hooks/useProvidersStore/index.js +24 -24
  94. package/src/hooks/useProvidersStore/queries.js +31 -31
  95. package/src/hooks/useRatingArrayData/index.js +54 -0
  96. package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
  97. package/src/hooks/useReactToPrint/index.js +1120 -1098
  98. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
  99. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
  100. package/src/hooks/useReport/index.js +9 -9
  101. package/src/hooks/useReport/queries.js +1 -1
  102. package/src/hooks/useRestaurant/index.js +19 -19
  103. package/src/hooks/useRestaurant/queries.js +80 -80
  104. package/src/hooks/useSales/index.js +476 -451
  105. package/src/hooks/useSales/queries.js +14 -15
  106. package/src/hooks/useSales/useGetAllSales/index.js +25 -25
  107. package/src/hooks/useSales/useTotalSales.js +18 -18
  108. package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
  109. package/src/hooks/useSaveAvailableProduct/index.js +16 -16
  110. package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
  111. package/src/hooks/useSchedule/index.js +33 -36
  112. package/src/hooks/useSchedule/index.jsx +22 -22
  113. package/src/hooks/useSchedule/queries.js +34 -35
  114. package/src/hooks/useScheduleData/index.js +123 -171
  115. package/src/hooks/useScroll/index.js +56 -57
  116. package/src/hooks/useScrollRotate/index.js +16 -14
  117. package/src/hooks/useSetSession/index.js +16 -16
  118. package/src/hooks/useSetState/index.js +3 -3
  119. package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
  120. package/src/hooks/useStatusOpenStore/index.js +172 -173
  121. package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
  122. package/src/hooks/useStatusOrdersClient/index.js +17 -0
  123. package/src/hooks/useStatusOrdersClient/queries.js +80 -0
  124. package/src/hooks/useStore/index.js +40 -25
  125. package/src/hooks/useStore/queries.js +162 -136
  126. package/src/hooks/useStoreCalendar/index.js +5 -7
  127. package/src/hooks/useStoreContacts/index.js +16 -16
  128. package/src/hooks/useStoreContacts/queries.js +1 -1
  129. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  130. package/src/hooks/useUpdateCart/index.js +34 -28
  131. package/src/hooks/useUpdateExistingOrders/index.js +35 -35
  132. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
  133. package/src/hooks/useUser/index.js +1 -1
  134. package/src/hooks/useUser/queries.js +1 -1
  135. package/src/hooks/useWindowSize/index.js +38 -38
  136. package/src/mock/dessert/index.js +16 -16
  137. package/src/mock/index.js +1 -2
  138. package/src/utils/index.js +42 -45
  139. package/src/hooks/useRatingData/index.js +0 -53
  140. package/src/hooks/useSalesClient/index.js +0 -1
@@ -1,23 +1,26 @@
1
- import { useMutation, useQuery } from '@apollo/client';
2
- import { useState } from 'react';
3
- import { DELETE_ONE_CAT_PRODUCTS, GET_ULTIMATE_CATEGORY_PRODUCTS } from '../useProductsFood/queriesStore';
4
- import { UPDATE_CAT_IN_PRODUCT } from './../useProductsFood/queriesStore';
5
- import { GET_ONE_STORE_IN_CATEGORY } from './queries';
1
+ import { useMutation, useQuery } from '@apollo/client'
2
+ import { useState } from 'react'
3
+ import {
4
+ DELETE_ONE_CAT_PRODUCTS,
5
+ GET_ULTIMATE_CATEGORY_PRODUCTS,
6
+ UPDATE_CAT_IN_PRODUCT
7
+ } from '../useProductsFood/queriesStore'
8
+ import { GET_ONE_STORE_IN_CATEGORY } from './queries'
6
9
 
7
- export const useCategoryInStore = ({ catStoreId }) => {
10
+ export const useCategoryInStore = ({ catStoreId, setAlertBox = () => {} } = {}) => {
8
11
  // STATES
9
12
  const [categories, setOneCategoryInStore] = useState([])
10
13
  const [deleteCatOfProducts] = useMutation(DELETE_ONE_CAT_PRODUCTS, {
11
14
  onError: (e) => {
12
15
  setAlertBox({
13
16
  message: e.graphQLErrors[0].message,
14
- color: WColor
17
+ color: 'error'
15
18
  })
16
19
  },
17
- update(cache) {
20
+ update (cache) {
18
21
  cache.modify({
19
22
  fields: {
20
- catProductsAll(dataOld = []) {
23
+ catProductsAll (dataOld = []) {
21
24
  return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
22
25
  }
23
26
  }
@@ -28,13 +31,13 @@ export const useCategoryInStore = ({ catStoreId }) => {
28
31
  onError: (e) => {
29
32
  console.log({
30
33
  message: e.graphQLErrors[0].message,
31
- color: WColor
34
+ color: 'error'
32
35
  })
33
36
  },
34
- update(cache) {
37
+ update (cache) {
35
38
  cache.modify({
36
39
  fields: {
37
- catProductsAll(dataOld = []) {
40
+ catProductsAll (dataOld = []) {
38
41
  return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
39
42
  }
40
43
  }
@@ -57,32 +60,33 @@ export const useCategoryInStore = ({ catStoreId }) => {
57
60
  setOneCategoryInStore(data.getOneCatStore)
58
61
  }
59
62
  })
60
- // HANDLESS
61
- const handlerDeleteCategoryInStore = (category) => {
62
- const { pState, idPc } = category || {}
63
- if (!idPc || !pState) return
64
- return deleteCatOfProducts({
65
- variables: { idPc, pState }, update(cache) {
66
- cache.modify({
67
- fields: {
68
- catProductsAll(dataOld = []) {
69
- return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
70
- }
63
+ // HANDLESS
64
+ const handlerDeleteCategoryInStore = (category) => {
65
+ const { pState, idPc } = category || {}
66
+ if (!idPc || !pState) return
67
+ return deleteCatOfProducts({
68
+ variables: { idPc, pState },
69
+ update (cache) {
70
+ cache.modify({
71
+ fields: {
72
+ catProductsAll (dataOld = []) {
73
+ return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
71
74
  }
72
- })
73
- }
74
- })
75
- }
76
- const handleUpdateCatInProduct = async ({ data }) => {
77
- await updatedCatWithProducts({
78
- variables: {
79
- input: {
80
- setData: data?.map(x => { return { idProduct: x.pId } }),
81
- idCat: idCat
82
75
  }
76
+ })
77
+ }
78
+ })
79
+ }
80
+ const handleUpdateCatInProduct = async ({ data }) => {
81
+ await updatedCatWithProducts({
82
+ variables: {
83
+ input: {
84
+ setData: data?.map(x => { return { idProduct: x.pId } }),
85
+ idCat: ''
83
86
  }
84
- })
85
- }
87
+ }
88
+ })
89
+ }
86
90
  return {
87
91
  categories,
88
92
  data: data?.catProductsAll || [],
@@ -92,4 +96,3 @@ export const useCategoryInStore = ({ catStoreId }) => {
92
96
  handleUpdateCatInProduct
93
97
  }
94
98
  }
95
-
@@ -1,78 +1,78 @@
1
- import { gql } from "@apollo/client";
2
-
3
- export const GET_ONE_STORE_IN_CATEGORY = gql`
4
- query getOneCatStore($catStore: ID){
5
- getOneCatStore(catStore: $catStore){
6
- catStore
7
- idUser
8
- cName
9
- cState
10
- cDatCre
11
- cPathImage
12
- cDatMod
13
- csDescription
14
- getAllStore {
15
- idStore
16
- cId
17
- id
18
- dId
19
- ctId
20
- catStore
21
- neighborhoodStore
22
- Viaprincipal
23
- storeOwner
24
- storeName
25
- emailStore
26
- storePhone
27
- socialRaz
28
- Image
29
- banner
30
- documentIdentifier
31
- uPhoNum
32
- ULocation
33
- upLat
34
- upLon
35
- uState
36
- siteWeb
37
- description
38
- NitStore
39
- typeRegiments
40
- typeContribute
41
- secVia
42
- addressStore
43
- createdAt
44
- pais {
45
- cId
46
- cName
47
- cCalCod
48
- cState
49
- cDatCre
50
- cDatMod
51
- }
52
- city {
53
- ctId
54
- dId
55
- cName
56
- cState
57
- cDatCre
58
- cDatMod
59
- }
60
- department {
61
- dId
62
- cId
63
- dName
64
- dState
65
- dDatCre
66
- dDatMod
67
- }
68
- getAllRatingStar {
69
- rSId
70
- rScore
71
- idStore
72
- createAt
73
-
74
- }
75
- }
76
- }
77
- }
78
- `
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const GET_ONE_STORE_IN_CATEGORY = gql`
4
+ query getOneCatStore($catStore: ID){
5
+ getOneCatStore(catStore: $catStore){
6
+ catStore
7
+ idUser
8
+ cName
9
+ cState
10
+ cDatCre
11
+ cPathImage
12
+ cDatMod
13
+ csDescription
14
+ getAllStore {
15
+ idStore
16
+ cId
17
+ id
18
+ dId
19
+ ctId
20
+ catStore
21
+ neighborhoodStore
22
+ Viaprincipal
23
+ storeOwner
24
+ storeName
25
+ emailStore
26
+ storePhone
27
+ socialRaz
28
+ Image
29
+ banner
30
+ documentIdentifier
31
+ uPhoNum
32
+ ULocation
33
+ upLat
34
+ upLon
35
+ uState
36
+ siteWeb
37
+ description
38
+ NitStore
39
+ typeRegiments
40
+ typeContribute
41
+ secVia
42
+ addressStore
43
+ createdAt
44
+ pais {
45
+ cId
46
+ cName
47
+ cCalCod
48
+ cState
49
+ cDatCre
50
+ cDatMod
51
+ }
52
+ city {
53
+ ctId
54
+ dId
55
+ cName
56
+ cState
57
+ cDatCre
58
+ cDatMod
59
+ }
60
+ department {
61
+ dId
62
+ cId
63
+ dName
64
+ dState
65
+ dDatCre
66
+ dDatMod
67
+ }
68
+ getAllRatingStar {
69
+ rSId
70
+ rScore
71
+ idStore
72
+ createAt
73
+
74
+ }
75
+ }
76
+ }
77
+ }
78
+ `
@@ -2,6 +2,6 @@ import { useQuery } from '@apollo/client'
2
2
  import { GET_ALL_CAT_STORE } from './queries'
3
3
 
4
4
  export const useCategoryStore = () => {
5
- const { data } = useQuery(GET_ALL_CAT_STORE)
6
- return [data]
5
+ const { data } = useQuery(GET_ALL_CAT_STORE)
6
+ return [data]
7
7
  }
@@ -1,171 +1,174 @@
1
- import { useQuery } from '@apollo/client';
2
- import { useState } from 'react';
3
- import { SPANISH_MONTHS } from "../../utils/index";
4
- import { GET_ALL_SALES } from "../useReport/queries";
5
- export * from './useChartData'
1
+ import { useQuery } from '@apollo/client'
2
+ import { useState } from 'react'
3
+ import { SPANISH_MONTHS } from '../../utils/index'
4
+ import { GET_ALL_SALES } from '../useReport/queries'
6
5
  export * from './useChartDataAllOrders'
7
6
 
8
7
  export const useChartData = ({ year }) => {
9
- // Construcción del nuevo array:
10
- const { data, loading } = useQuery(GET_ALL_SALES)
11
- const [chartType, setChartType] = useState('bar')
12
- const [chartTypeYear, setChartTypeYear] = useState(new Date().getFullYear())
13
- const [asFilter, setFilter] = useState(false)
14
- const [newResult, setNewResult] = useState([])
15
- let result = []
16
- data?.getAllSalesStore?.length > 0 && data?.getAllSalesStore.reduce(function (res, value) {
17
- // Creamos la posición del array para cada mes
18
- let mes = new Date(value.pDatCre).getMonth()
19
- let Year = new Date(value.pDatCre).getFullYear()
20
- if (!res[mes]) {
21
- res[mes] = { Mes: mes, Year }
22
- // Inicializamos a 0 el valor de cada key
23
- Object.keys(value).forEach((key) => {
24
- if (key != 'pDatCre') {
25
- res[mes][key] = 0
26
- }
27
- })
28
-
29
- result.push(res[mes])
8
+ // Construcción del nuevo array:
9
+ const { data, loading } = useQuery(GET_ALL_SALES)
10
+ const [chartType, setChartType] = useState('bar')
11
+ const [chartTypeYear, setChartTypeYear] = useState(new Date().getFullYear())
12
+ const [asFilter, setFilter] = useState(false)
13
+ const [newResult, setNewResult] = useState([])
14
+ const result = []
15
+ data?.getAllSalesStore?.length > 0 && data?.getAllSalesStore.reduce(function (res, value) {
16
+ // Creamos la posición del array para cada mes
17
+ const mes = new Date(value.pDatCre).getMonth()
18
+ const Year = new Date(value.pDatCre).getFullYear()
19
+ if (!res[mes]) {
20
+ res[mes] = { Mes: mes, Year }
21
+ // Inicializamos a 0 el valor de cada key
22
+ Object.keys(value).forEach((key) => {
23
+ if (key !== 'pDatCre') {
24
+ res[mes][key] = 0
30
25
  }
31
- // Sumamos el valor de cada clave dentro de un bucle
32
- Object.keys(value).forEach(function (key) {
33
- if (key != 'pDatCre') {
34
- res[mes]['totalProductsPrice'] += value['totalProductsPrice']
35
- }
36
- })
37
- return res
38
- }, {})
39
-
40
- let allMonths = Array.from({ length: 12 }, (_, i) => { return i })
41
- let missingMonths = allMonths.filter(month => { return !result.some(data => { return data.Mes === month }) })
26
+ })
42
27
 
43
- for (const element of missingMonths) {
44
- result.push({
45
- 'Mes': element,
46
- 'totalProductsPrice': 0,
47
- 'Year': ''
48
- })
28
+ result.push(res[mes])
49
29
  }
30
+ // Sumamos el valor de cada clave dentro de un bucle
31
+ Object.keys(value).forEach(function (key) {
32
+ if (key !== 'pDatCre') {
33
+ res[mes].totalProductsPrice += value.totalProductsPrice
34
+ }
35
+ })
36
+ return res
37
+ }, {})
50
38
 
51
- result.sort((a, b) => { return a.Mes - b.Mes })
39
+ const allMonths = Array.from({ length: 12 }, (_, i) => { return i })
40
+ const missingMonths = allMonths.filter(month => { return !result.some(data => { return data.Mes === month }) })
52
41
 
53
- const labelTitle = `Ventas por meses del año ${asFilter ? chartTypeYear : ''}`
54
- // Resultado:
55
- const dataChart = {
56
- labels: asFilter ? newResult.map(data => {
57
- return SPANISH_MONTHS[data.Mes]
58
- }) : result.map(data => {
59
- return SPANISH_MONTHS[data.Mes]
60
- }),
61
- datasets: [
62
- {
63
- label: labelTitle,
64
- data: asFilter ? newResult.map(data => { return data.totalProductsPrice }) : result.map(data => { return data.totalProductsPrice }),
65
- backgroundColor: [
66
- 'rgba(255, 99, 132, 0.2)',
67
- 'rgba(54, 162, 235, 0.2)',
68
- 'rgba(255, 206, 86, 0.2)',
69
- 'rgba(75, 192, 192, 0.2)',
70
- 'rgba(153, 102, 255, 0.2)',
71
- 'rgba(255, 159, 64, 0.2)'
72
- ],
73
- borderColor: chartType === 'bar' ? [
74
- 'rgba(255, 99, 132, 1)',
75
- 'rgba(54, 162, 235, 1)',
76
- 'rgba(255, 206, 86, 1)',
77
- 'rgba(75, 192, 192, 1)',
78
- 'rgba(153, 102, 255, 1)',
79
- 'rgba(255, 159, 64, 1)'
80
- ] : 'rgb(255 0 0)',
81
- tension: 0.6,
82
- fill: false,
83
- borderWidth: 1,
84
- barPercentage: 1,
85
- barThickness: 50,
86
- minBarLength: 3,
87
- }
88
- ]
89
- }
90
- const options = {
91
- interaction: {
92
- mode: 'index',
93
- intersect: false,
94
- },
95
- scales: {
96
- x: {
97
- stacked: true
98
- },
99
- y: {
100
- stacked: true
101
- }
102
- },
103
- plugins: {
104
- title: {
105
- display: true,
106
- text: labelTitle
107
- },
108
- }
42
+ for (const element of missingMonths) {
43
+ result.push({
44
+ Mes: element,
45
+ totalProductsPrice: 0,
46
+ Year: ''
47
+ })
48
+ }
49
+
50
+ result.sort((a, b) => { return a.Mes - b.Mes })
51
+
52
+ const labelTitle = `Ventas por meses del año ${asFilter ? chartTypeYear : ''}`
53
+ // Resultado:
54
+ const dataChart = {
55
+ labels: asFilter
56
+ ? newResult.map(data => {
57
+ return SPANISH_MONTHS[data.Mes]
58
+ })
59
+ : result.map(data => {
60
+ return SPANISH_MONTHS[data.Mes]
61
+ }),
62
+ datasets: [
63
+ {
64
+ label: labelTitle,
65
+ data: asFilter ? newResult.map(data => { return data.totalProductsPrice }) : result.map(data => { return data.totalProductsPrice }),
66
+ backgroundColor: [
67
+ 'rgba(255, 99, 132, 0.2)',
68
+ 'rgba(54, 162, 235, 0.2)',
69
+ 'rgba(255, 206, 86, 0.2)',
70
+ 'rgba(75, 192, 192, 0.2)',
71
+ 'rgba(153, 102, 255, 0.2)',
72
+ 'rgba(255, 159, 64, 0.2)'
73
+ ],
74
+ borderColor: chartType === 'bar'
75
+ ? [
76
+ 'rgba(255, 99, 132, 1)',
77
+ 'rgba(54, 162, 235, 1)',
78
+ 'rgba(255, 206, 86, 1)',
79
+ 'rgba(75, 192, 192, 1)',
80
+ 'rgba(153, 102, 255, 1)',
81
+ 'rgba(255, 159, 64, 1)'
82
+ ]
83
+ : 'rgb(255 0 0)',
84
+ tension: 0.6,
85
+ fill: false,
86
+ borderWidth: 1,
87
+ barPercentage: 1,
88
+ barThickness: 50,
89
+ minBarLength: 3
109
90
  }
110
- const groupedData = {}
91
+ ]
92
+ }
93
+ const options = {
94
+ interaction: {
95
+ mode: 'index',
96
+ intersect: false
97
+ },
98
+ scales: {
99
+ x: {
100
+ stacked: true
101
+ },
102
+ y: {
103
+ stacked: true
104
+ }
105
+ },
106
+ plugins: {
107
+ title: {
108
+ display: true,
109
+ text: labelTitle
110
+ }
111
+ }
112
+ }
113
+ const groupedData = {}
111
114
 
112
- data && data.getAllSalesStore.forEach((item) => {
113
- const year = new Date(item.pDatCre).getFullYear()
114
- if (!groupedData[year]) {
115
- groupedData[year] = []
116
- }
117
- groupedData[year].push(item)
118
- })
119
- const years = []
120
- data && data.getAllSalesStore.forEach((item) => {
121
- const y = new Date(item.pDatCre).getFullYear()
122
- if (!years.includes(y)) {
123
- years.push(y)
124
- }
125
- })
126
- const handleChangeYear = (value) => {
127
- setFilter(true)
128
- const currentYear = parseInt(value)
129
- setChartTypeYear(currentYear || '')
130
- if (result?.length > 0) {
131
- const filterToYear = result.filter((elem) => {
132
- return elem?.Year == currentYear
133
- })
134
- let missingNewMonths = allMonths.filter(month => { return !filterToYear.some(data => { return data.Mes === month }) })
135
- for (const element of missingNewMonths) {
136
- filterToYear.push({
137
- 'Mes': element,
138
- 'totalProductsPrice': 0,
139
- 'Year': ''
140
- })
141
- }
142
- filterToYear.sort((a, b) => { return a.Mes - b.Mes })
143
- setNewResult(filterToYear)
144
- return filterToYear
145
- }
115
+ data && data.getAllSalesStore.forEach((item) => {
116
+ const year = new Date(item.pDatCre).getFullYear()
117
+ if (!groupedData[year]) {
118
+ groupedData[year] = []
146
119
  }
147
- const cleanFilter = () => {
148
- setFilter(false)
149
- setChartTypeYear(new Date().getFullYear())
120
+ groupedData[year].push(item)
121
+ })
122
+ const years = []
123
+ data && data.getAllSalesStore.forEach((item) => {
124
+ const y = new Date(item.pDatCre).getFullYear()
125
+ if (!years.includes(y)) {
126
+ years.push(y)
150
127
  }
151
- const sortYear = () => {
152
- return years.sort((a, b) => { return b - a });
128
+ })
129
+ const handleChangeYear = (value) => {
130
+ setFilter(true)
131
+ const currentYear = parseInt(value)
132
+ setChartTypeYear(currentYear || '')
133
+ if (result?.length > 0) {
134
+ const filterToYear = result.filter((elem) => {
135
+ return elem?.Year === currentYear
136
+ })
137
+ const missingNewMonths = allMonths.filter(month => { return !filterToYear.some(data => { return data.Mes === month }) })
138
+ for (const element of missingNewMonths) {
139
+ filterToYear.push({
140
+ Mes: element,
141
+ totalProductsPrice: 0,
142
+ Year: ''
143
+ })
144
+ }
145
+ filterToYear.sort((a, b) => { return a.Mes - b.Mes })
146
+ setNewResult(filterToYear)
147
+ return filterToYear
153
148
  }
149
+ }
150
+ const cleanFilter = () => {
151
+ setFilter(false)
152
+ setChartTypeYear(new Date().getFullYear())
153
+ }
154
+ const sortYear = () => {
155
+ return years.sort((a, b) => { return b - a })
156
+ }
154
157
 
155
- const organiceYears = sortYear()
156
- return {
157
- handleChangeYear,
158
- setFilter,
159
- cleanFilter,
160
- setChartType,
161
- years: organiceYears,
162
- asFilter,
163
- chartTypeYear,
164
- options,
165
- chartType,
166
- labelTitle,
167
- result,
168
- dataChart,
169
- loading
170
- }
158
+ const organiceYears = sortYear()
159
+ return {
160
+ handleChangeYear,
161
+ setFilter,
162
+ cleanFilter,
163
+ setChartType,
164
+ years: organiceYears,
165
+ asFilter,
166
+ chartTypeYear,
167
+ options,
168
+ chartType,
169
+ labelTitle,
170
+ result,
171
+ dataChart,
172
+ loading
173
+ }
171
174
  }