npm-pkg-hook 1.4.9 → 1.5.1
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/.eslintrc.js +38 -38
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +8 -0
- package/package.json +1 -1
- package/src/hooks/getCategoriesWithProduct/index.js +1 -1
- package/src/hooks/getTodayTimestamps/index.js +64 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useAsideCart/queries.js +1 -1
- package/src/hooks/useCart/index.js +1 -1
- package/src/hooks/useCart/useCart/helpers/index.js +2 -2
- package/src/hooks/useCatWithProductClient/queries.js +1 -1
- package/src/hooks/useCategoryInStore/queries.js +1 -1
- package/src/hooks/useChartData/index.js +21 -21
- package/src/hooks/useFavoriteStores/queries.js +1 -1
- package/src/hooks/useFetchJson/index.js +1 -1
- package/src/hooks/useGetOneStoreRating/queries.js +1 -1
- package/src/hooks/useGoogleLogin/loadScript.js +15 -15
- package/src/hooks/useGoogleLogin/removeScript.js +7 -7
- package/src/hooks/useKeypress/index.js +1 -1
- package/src/hooks/useLogout/index.js +1 -1
- package/src/hooks/useOrderClient/index.js +1 -1
- package/src/hooks/useOrders/queries.js +1 -1
- package/src/hooks/useReport/index.js +4 -4
- package/src/hooks/useReport/queries.js +3 -3
- package/src/hooks/useRestaurant/helpers/index.js +29 -0
- package/src/hooks/useRestaurant/index.js +48 -6
- package/src/hooks/useRestaurant/queries.js +0 -1
- package/src/hooks/useSales/index.js +8 -15
- package/src/hooks/useSales/queries.js +4 -2
package/.eslintrc.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
settings: {
|
|
3
|
-
react: {
|
|
4
|
-
version: 'detect'
|
|
5
|
-
}
|
|
6
|
-
},
|
|
7
|
-
env: {
|
|
8
|
-
browser: true,
|
|
9
|
-
es2021: true,
|
|
10
|
-
node: true
|
|
11
|
-
},
|
|
12
|
-
extends: [
|
|
13
|
-
'standard',
|
|
14
|
-
'plugin:react/recommended'
|
|
15
|
-
],
|
|
16
|
-
overrides: [
|
|
17
|
-
{
|
|
18
|
-
env: {
|
|
19
|
-
node: true
|
|
20
|
-
},
|
|
21
|
-
files: [
|
|
22
|
-
'.eslintrc.{js,cjs}'
|
|
23
|
-
],
|
|
24
|
-
parserOptions: {
|
|
25
|
-
sourceType: 'script'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
parserOptions: {
|
|
30
|
-
ecmaVersion: 'latest',
|
|
31
|
-
sourceType: 'module'
|
|
32
|
-
},
|
|
33
|
-
plugins: [
|
|
34
|
-
'react'
|
|
35
|
-
],
|
|
36
|
-
rules: {
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
settings: {
|
|
3
|
+
react: {
|
|
4
|
+
version: 'detect'
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
env: {
|
|
8
|
+
browser: true,
|
|
9
|
+
es2021: true,
|
|
10
|
+
node: true
|
|
11
|
+
},
|
|
12
|
+
extends: [
|
|
13
|
+
'standard',
|
|
14
|
+
'plugin:react/recommended'
|
|
15
|
+
],
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
env: {
|
|
19
|
+
node: true
|
|
20
|
+
},
|
|
21
|
+
files: [
|
|
22
|
+
'.eslintrc.{js,cjs}'
|
|
23
|
+
],
|
|
24
|
+
parserOptions: {
|
|
25
|
+
sourceType: 'script'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
parserOptions: {
|
|
30
|
+
ecmaVersion: 'latest',
|
|
31
|
+
sourceType: 'module'
|
|
32
|
+
},
|
|
33
|
+
plugins: [
|
|
34
|
+
'react'
|
|
35
|
+
],
|
|
36
|
+
rules: {
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the start timestamp for the current day.
|
|
3
|
+
* @returns {string} The start timestamp for the current day.
|
|
4
|
+
*/
|
|
5
|
+
export const getStartOfDayTimestamp = () => {
|
|
6
|
+
const start = new Date()
|
|
7
|
+
start.setHours(0, 0, 0, 0)
|
|
8
|
+
return start.toISOString()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get the end timestamp for the current day.
|
|
13
|
+
* @returns {string} The end timestamp for the current day.
|
|
14
|
+
*/
|
|
15
|
+
export const getEndOfDayTimestamp = () => {
|
|
16
|
+
const end = new Date()
|
|
17
|
+
end.setHours(23, 59, 59, 999)
|
|
18
|
+
return end.toISOString()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get start and end timestamps for the current day.
|
|
23
|
+
* @returns {Object} An object containing start and end timestamps.
|
|
24
|
+
*/
|
|
25
|
+
export const getTodayTimestamps = () => {
|
|
26
|
+
return {
|
|
27
|
+
startTimestamp: getStartOfDayTimestamp(),
|
|
28
|
+
endTimestamp: getEndOfDayTimestamp()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get start timestamp for a specific number of days ago.
|
|
34
|
+
* @param {number} daysAgo - The number of days ago.
|
|
35
|
+
* @returns {string} The start timestamp for the specified number of days ago.
|
|
36
|
+
*/
|
|
37
|
+
export const getStartTimestampDaysAgo = (daysAgo) => {
|
|
38
|
+
if (isNaN(daysAgo) || daysAgo < 0) {
|
|
39
|
+
throw new Error('Invalid input. Provide a valid number of days.')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const start = new Date()
|
|
43
|
+
start.setDate(start.getDate() - daysAgo)
|
|
44
|
+
start.setHours(0, 0, 0, 0)
|
|
45
|
+
|
|
46
|
+
return start.toISOString()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function convertDateFormat ({ dateString, start }) {
|
|
50
|
+
const parsedDate = new Date(dateString)
|
|
51
|
+
const year = parsedDate.getFullYear()
|
|
52
|
+
const month = `0${parsedDate.getMonth() + 1}`.slice(-2)
|
|
53
|
+
const day = `0${parsedDate.getDate()}`.slice(-2)
|
|
54
|
+
|
|
55
|
+
if (start) {
|
|
56
|
+
// Inicio del día (00:00:00)
|
|
57
|
+
return `${year}-${month}-${day}T00:00:00.000Z`
|
|
58
|
+
} else {
|
|
59
|
+
// Final del día (23:59:59.999)
|
|
60
|
+
const endOfDay = new Date(parsedDate)
|
|
61
|
+
endOfDay.setHours(23, 59, 59, 999)
|
|
62
|
+
return endOfDay.toISOString()
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/hooks/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export * from './useDrag'
|
|
|
46
46
|
export * from './useEvent'
|
|
47
47
|
export * from './useFetchJson'
|
|
48
48
|
export * from './useFormatDate'
|
|
49
|
+
export * from './getTodayTimestamps'
|
|
49
50
|
export * from './useFormatNumberPhone'
|
|
50
51
|
export * from './useFormTools/index'
|
|
51
52
|
export * from './useHover'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './useCart'
|
|
2
|
-
export * from './useGetCart'
|
|
2
|
+
export * from './useGetCart'
|
|
@@ -2,7 +2,7 @@ import { filterKeyObject } from '../../../../utils'
|
|
|
2
2
|
|
|
3
3
|
const filters = ['__typename']
|
|
4
4
|
|
|
5
|
-
export const filterDataOptional = (dataOptional) => {
|
|
5
|
+
export const filterDataOptional = (dataOptional) => {
|
|
6
6
|
if (!Array.isArray(dataOptional)) {
|
|
7
7
|
throw new Error('Input data is not an array')
|
|
8
8
|
}
|
|
@@ -72,4 +72,4 @@ export const filterExtra = (dataExtra) => {
|
|
|
72
72
|
} catch (error) {
|
|
73
73
|
return []
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|
|
@@ -11,30 +11,29 @@ export const useChartData = ({ year }) => {
|
|
|
11
11
|
const [asFilter, setFilter] = useState(false)
|
|
12
12
|
const [newResult, setNewResult] = useState([])
|
|
13
13
|
const result = []
|
|
14
|
-
|
|
15
|
-
// Creamos la posición del array para cada mes
|
|
16
|
-
const mes = new Date(value.pDatCre).getMonth()
|
|
17
|
-
const Year = new Date(value.pDatCre).getFullYear()
|
|
18
|
-
if (!res[mes]) {
|
|
19
|
-
res[mes] = { Mes: mes, Year }
|
|
20
|
-
// Inicializamos a 0 el valor de cada key
|
|
21
|
-
Object.keys(value).forEach((key) => {
|
|
22
|
-
if (key !== 'pDatCre') {
|
|
23
|
-
res[mes][key] = 0
|
|
24
|
-
}
|
|
25
|
-
})
|
|
14
|
+
const sumByMonth = {}
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
data?.getAllSalesStore?.forEach(function (value) {
|
|
17
|
+
const month = new Date(value.pDatCre).getMonth()
|
|
18
|
+
const year = new Date(value.pDatCre).getFullYear()
|
|
19
|
+
const key = `${month}-${year}`
|
|
20
|
+
|
|
21
|
+
if (!sumByMonth[key]) {
|
|
22
|
+
sumByMonth[key] = {
|
|
23
|
+
Mes: month,
|
|
24
|
+
Year: year,
|
|
25
|
+
totalProductsPrice: 0
|
|
33
26
|
}
|
|
34
|
-
})
|
|
35
|
-
return res
|
|
36
|
-
}, {})
|
|
37
27
|
|
|
28
|
+
result.push(sumByMonth[key])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
sumByMonth[key].totalProductsPrice += value.totalProductsPrice
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
console.log(result)
|
|
35
|
+
|
|
36
|
+
console.log(data?.getAllSalesStore)
|
|
38
37
|
const allMonths = Array.from({ length: 12 }, (_, i) => { return i })
|
|
39
38
|
const missingMonths = allMonths.filter(month => { return !result.some(data => { return data.Mes === month }) })
|
|
40
39
|
|
|
@@ -89,6 +88,7 @@ export const useChartData = ({ year }) => {
|
|
|
89
88
|
}
|
|
90
89
|
]
|
|
91
90
|
}
|
|
91
|
+
console.log(result)
|
|
92
92
|
const options = {
|
|
93
93
|
interaction: {
|
|
94
94
|
mode: 'index',
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export default (d, s, id, jsSrc, cb, onError) => {
|
|
2
|
-
const element = d.getElementsByTagName(s)[0]
|
|
3
|
-
const fjs = element
|
|
4
|
-
let js = element
|
|
5
|
-
js = d.createElement(s)
|
|
6
|
-
js.id = id
|
|
7
|
-
js.src = jsSrc
|
|
8
|
-
if (fjs && fjs.parentNode) {
|
|
9
|
-
fjs.parentNode.insertBefore(js, fjs)
|
|
10
|
-
} else {
|
|
11
|
-
d.head.appendChild(js)
|
|
12
|
-
}
|
|
13
|
-
js.onerror = onError
|
|
14
|
-
js.onload = cb
|
|
15
|
-
}
|
|
1
|
+
export default (d, s, id, jsSrc, cb, onError) => {
|
|
2
|
+
const element = d.getElementsByTagName(s)[0]
|
|
3
|
+
const fjs = element
|
|
4
|
+
let js = element
|
|
5
|
+
js = d.createElement(s)
|
|
6
|
+
js.id = id
|
|
7
|
+
js.src = jsSrc
|
|
8
|
+
if (fjs && fjs.parentNode) {
|
|
9
|
+
fjs.parentNode.insertBefore(js, fjs)
|
|
10
|
+
} else {
|
|
11
|
+
d.head.appendChild(js)
|
|
12
|
+
}
|
|
13
|
+
js.onerror = onError
|
|
14
|
+
js.onload = cb
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export default (d, id) => {
|
|
2
|
-
const element = d.getElementById(id)
|
|
3
|
-
|
|
4
|
-
if (element) {
|
|
5
|
-
element.parentNode.removeChild(element)
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
export default (d, id) => {
|
|
2
|
+
const element = d.getElementById(id)
|
|
3
|
+
|
|
4
|
+
if (element) {
|
|
5
|
+
element.parentNode.removeChild(element)
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -29,7 +29,7 @@ export const useLogout = ({ setAlertBox = () => {} } = {}) => {
|
|
|
29
29
|
console.log('Cookie eliminada correctamente.')
|
|
30
30
|
} catch (error) {
|
|
31
31
|
console.error('Error al eliminar la cookie:', error)
|
|
32
|
-
throw new Error('Error al eliminar la cookie.
|
|
32
|
+
throw new Error('Error al eliminar la cookie. ')
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -30,15 +30,15 @@ export const useReport = ({
|
|
|
30
30
|
variables: {
|
|
31
31
|
fromDate,
|
|
32
32
|
toDate
|
|
33
|
-
}
|
|
34
|
-
skip: !data || data?.getAllSalesStore?.length === 0 // Skip if main query hasn't loaded or has no data
|
|
33
|
+
}
|
|
35
34
|
})
|
|
36
|
-
|
|
35
|
+
console.log(fromDate,
|
|
36
|
+
toDate)
|
|
37
37
|
const totalSales = totalSalesData?.getAllSalesStoreTotal ?? {}
|
|
38
38
|
|
|
39
39
|
return {
|
|
40
40
|
getAllSalesStore: lazyQuery ? getAllSalesStore : () => { }, // Return function only if in lazy mode
|
|
41
|
-
data: lazyQuery ?
|
|
41
|
+
data: lazyQuery ? lazyDataSales : data, // Use data from lazy query if available
|
|
42
42
|
loading: lazyQuery ? lazyLoading || loading : loading,
|
|
43
43
|
totalSales: totalSales.TOTAL || 0,
|
|
44
44
|
restaurant: totalSales.restaurant || 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
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:
|
|
4
|
+
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: String, $toDate: String ) {
|
|
5
5
|
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
6
6
|
totalProductsPrice
|
|
7
7
|
channel
|
|
@@ -12,7 +12,7 @@ query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromD
|
|
|
12
12
|
`
|
|
13
13
|
|
|
14
14
|
export const GET_ALL_TOTAL_SALES = gql`
|
|
15
|
-
query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $fromDate:
|
|
15
|
+
query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: String, $toDate: String) {
|
|
16
16
|
getAllSalesStoreTotal(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
17
17
|
restaurant
|
|
18
18
|
delivery
|
|
@@ -120,4 +120,4 @@ query getOneSalesStore($pCodeRef: String) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
`
|
|
123
|
+
`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function filterAndSortByDate (array = []) {
|
|
2
|
+
const isError = !Array.isArray(array) || !array.length
|
|
3
|
+
try {
|
|
4
|
+
if (isError) return []
|
|
5
|
+
|
|
6
|
+
const currentDate = new Date()
|
|
7
|
+
const sevenDaysAgo = currentDate.getTime() - 7 * 24 * 60 * 60 * 1000 // Calculating timestamp for 7 days ago
|
|
8
|
+
|
|
9
|
+
const filteredAndSorted = array.map(item => {
|
|
10
|
+
const createdAtDate = new Date(item.createdAt)
|
|
11
|
+
const isNew = createdAtDate.getTime() >= sevenDaysAgo
|
|
12
|
+
return { ...item, isNew }
|
|
13
|
+
}).sort((a, b) => {
|
|
14
|
+
// Ordenar primero por 'open' en 1 y luego por 'createdAt'
|
|
15
|
+
if (a.open !== b.open) {
|
|
16
|
+
return b.open - a.open // Orden descendente para 'open' en 1 primero
|
|
17
|
+
} else {
|
|
18
|
+
const dateA = new Date(a.createdAt).getTime()
|
|
19
|
+
const dateB = new Date(b.createdAt).getTime()
|
|
20
|
+
return dateA - dateB
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return filteredAndSorted
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (isError) return []
|
|
27
|
+
if (Array.isArray(array)) return array
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,19 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { useLazyQuery } from '@apollo/client'
|
|
2
3
|
import { GET_ALL_RESTAURANT } from './queries'
|
|
4
|
+
import { filterAndSortByDate } from './helpers'
|
|
5
|
+
import { useManageQueryParams } from '../useManageQueryParams'
|
|
3
6
|
|
|
4
|
-
export const useRestaurant = (
|
|
5
|
-
|
|
7
|
+
export const useRestaurant = ({
|
|
8
|
+
location = {
|
|
9
|
+
pathname: ''
|
|
10
|
+
}
|
|
11
|
+
} = {}) => {
|
|
12
|
+
const [loadingFilter, setLoadingFilter] = useState(false)
|
|
13
|
+
const { handleQuery, handleCleanQuery } = useManageQueryParams()
|
|
14
|
+
|
|
15
|
+
const [getAllStoreInStore, {
|
|
6
16
|
data,
|
|
7
17
|
loading,
|
|
8
18
|
error,
|
|
9
19
|
fetchMore
|
|
10
|
-
} =
|
|
20
|
+
}] = useLazyQuery(GET_ALL_RESTAURANT, {
|
|
11
21
|
fetchPolicy: 'cache-and-network',
|
|
12
22
|
notifyOnNetworkStatusChange: true,
|
|
13
23
|
nextFetchPolicy: 'cache-first',
|
|
14
24
|
refetchWritePolicy: 'merge',
|
|
15
25
|
context: { clientName: 'admin-store' }
|
|
16
26
|
})
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
getAllStoreInStore({})
|
|
30
|
+
}, [location])
|
|
31
|
+
const handleSendQueries = (name, value) => {
|
|
32
|
+
if (value) handleQuery(name, value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const handleCleanQueries = (name) => {
|
|
36
|
+
handleCleanQuery(name)
|
|
37
|
+
}
|
|
38
|
+
const handleFilterStore = async () => {
|
|
39
|
+
setLoadingFilter(true)
|
|
40
|
+
try {
|
|
41
|
+
getAllStoreInStore({
|
|
42
|
+
|
|
43
|
+
}).then(() => {
|
|
44
|
+
setLoadingFilter(false)
|
|
45
|
+
})
|
|
46
|
+
} catch (error) {
|
|
47
|
+
setLoadingFilter(false)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const dataRestaurant = data?.getAllStoreInStore || []
|
|
51
|
+
const dataSort = filterAndSortByDate(dataRestaurant)
|
|
52
|
+
return [dataSort, {
|
|
53
|
+
loading,
|
|
54
|
+
loadingFilter,
|
|
55
|
+
error,
|
|
56
|
+
fetchMore,
|
|
57
|
+
handleSendQueries,
|
|
58
|
+
handleFilterStore,
|
|
59
|
+
handleCleanQueries
|
|
60
|
+
}]
|
|
19
61
|
}
|
|
@@ -54,10 +54,10 @@ const initializer = (initialValue = initialState) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export const useSales = ({
|
|
57
|
-
disabled,
|
|
58
|
-
sendNotification,
|
|
57
|
+
disabled = false,
|
|
59
58
|
router,
|
|
60
|
-
|
|
59
|
+
sendNotification = () => { return },
|
|
60
|
+
setAlertBox = () => { return }
|
|
61
61
|
}) => {
|
|
62
62
|
const domain = getCurrentDomain()
|
|
63
63
|
const [loadingSale, setLoadingSale] = useState(false)
|
|
@@ -330,14 +330,6 @@ export const useSales = ({
|
|
|
330
330
|
case 'DECREMENT':
|
|
331
331
|
return {
|
|
332
332
|
...state
|
|
333
|
-
// counter: state.counter - 1,
|
|
334
|
-
// PRODUCT: state?.PRODUCT?.map((items) => {
|
|
335
|
-
// return items.pId === action.id ? {
|
|
336
|
-
// ...items,
|
|
337
|
-
// ProQuantity: items.ProQuantity - 1,
|
|
338
|
-
// // ProPrice: ((productExist.ProQuantity + 1) * OurProduct?.ProPrice),
|
|
339
|
-
// } : items
|
|
340
|
-
// })
|
|
341
333
|
}
|
|
342
334
|
case 'PAYMENT_METHOD_TRANSACTION':
|
|
343
335
|
return {
|
|
@@ -826,6 +818,7 @@ export const useSales = ({
|
|
|
826
818
|
const totalProductsPrice = totalProductPrice
|
|
827
819
|
const client = useApolloClient()
|
|
828
820
|
const { getOnePedidoStore } = useGetSale()
|
|
821
|
+
|
|
829
822
|
const handleSubmit = () => {
|
|
830
823
|
if (errors?.change || errors?.valueDelivery) {
|
|
831
824
|
return sendNotification({
|
|
@@ -837,7 +830,7 @@ export const useSales = ({
|
|
|
837
830
|
setLoadingSale(true)
|
|
838
831
|
const code = RandomCode(10)
|
|
839
832
|
setCode(code)
|
|
840
|
-
function
|
|
833
|
+
function convertInteger (cadena) {
|
|
841
834
|
if (typeof cadena === 'string') {
|
|
842
835
|
const numeroEntero = parseInt(cadena?.replace('.', ''))
|
|
843
836
|
return numeroEntero
|
|
@@ -849,12 +842,12 @@ export const useSales = ({
|
|
|
849
842
|
input: finalArrayProduct || [],
|
|
850
843
|
id: values?.cliId,
|
|
851
844
|
pCodeRef: code,
|
|
852
|
-
change:
|
|
853
|
-
valueDelivery:
|
|
845
|
+
change: convertInteger(values.change),
|
|
846
|
+
valueDelivery: convertInteger(values.valueDelivery),
|
|
854
847
|
payMethodPState: data.payMethodPState,
|
|
855
848
|
pickUp: 1,
|
|
856
849
|
discount: discount.discount || 0,
|
|
857
|
-
totalProductsPrice:
|
|
850
|
+
totalProductsPrice: convertInteger(totalProductsPrice) || 0
|
|
858
851
|
}
|
|
859
852
|
})
|
|
860
853
|
.then((responseRegisterR) => {
|
|
@@ -6,8 +6,8 @@ export const GET_ALL_SALES = gql`
|
|
|
6
6
|
$search: String
|
|
7
7
|
$min: Int
|
|
8
8
|
$max: Int
|
|
9
|
-
$fromDate:
|
|
10
|
-
$toDate:
|
|
9
|
+
$fromDate: String
|
|
10
|
+
$toDate: String
|
|
11
11
|
) {
|
|
12
12
|
getAllSalesStore(
|
|
13
13
|
idStore: $idStore
|
|
@@ -275,6 +275,7 @@ export const GET_ONE_SALE = gql`
|
|
|
275
275
|
getAllShoppingCard {
|
|
276
276
|
ShoppingCard
|
|
277
277
|
cantProducts
|
|
278
|
+
priceProduct
|
|
278
279
|
refCodePid
|
|
279
280
|
subProductsId
|
|
280
281
|
comments
|
|
@@ -416,6 +417,7 @@ query getAllPedidoStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int
|
|
|
416
417
|
pDatMod
|
|
417
418
|
getAllShoppingCard {
|
|
418
419
|
ShoppingCard
|
|
420
|
+
priceProduct
|
|
419
421
|
comments
|
|
420
422
|
cantProducts
|
|
421
423
|
pId
|