npm-pkg-hook 1.8.1 → 1.8.2
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
package/src/hooks/index.js
CHANGED
|
@@ -7,7 +7,8 @@ export * from './useCatWithProduct'
|
|
|
7
7
|
export * from './useManageQueryParams'
|
|
8
8
|
export * from './useDeliveryTime'
|
|
9
9
|
export * from './getTotalHours'
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './useTokenCards'
|
|
11
|
+
export * from './useSubscriptionValidation'
|
|
11
12
|
export * from './convertToMilitaryTime'
|
|
12
13
|
export * from './statusOpenStores'
|
|
13
14
|
export * from './completeSchedules'
|
|
@@ -13,7 +13,7 @@ const VALIDATE_SUBSCRIPTION_QUERY = gql`
|
|
|
13
13
|
}
|
|
14
14
|
`
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const useSubscriptionValidation = (idStore) => {
|
|
17
17
|
const { loading, error, data } = useQuery(VALIDATE_SUBSCRIPTION_QUERY, {
|
|
18
18
|
variables: { idStore }
|
|
19
19
|
})
|
|
@@ -21,6 +21,7 @@ export const useFreeSubscriptionValidation = (idStore) => {
|
|
|
21
21
|
const [daysElapsed, setDaysElapsed] = useState(null)
|
|
22
22
|
|
|
23
23
|
useEffect(() => {
|
|
24
|
+
console.log(data)
|
|
24
25
|
if (data && data.validateFreeSubscription) {
|
|
25
26
|
const { currentPeriodEnd, currentPeriodStart } = data.validateFreeSubscription
|
|
26
27
|
const currentDate = new Date()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useTokenCards = () => {
|
|
4
|
+
const [loading, setLoading] = useState(false)
|
|
5
|
+
const [error, setError] = useState(null)
|
|
6
|
+
const [responseData, setResponseData] = useState(null)
|
|
7
|
+
|
|
8
|
+
const handleTokenCardsSubmit = async (postData) => {
|
|
9
|
+
setLoading(true)
|
|
10
|
+
setError(null)
|
|
11
|
+
try {
|
|
12
|
+
const headers = {
|
|
13
|
+
'Content-Type': 'application/json'
|
|
14
|
+
}
|
|
15
|
+
const url = 'http://localhost:3000/api/v1/wompi/transaction/tokens/cards'
|
|
16
|
+
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers,
|
|
20
|
+
body: JSON.stringify(postData)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const responseData = await response.json()
|
|
24
|
+
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(responseData.message || 'Something went wrong')
|
|
27
|
+
}
|
|
28
|
+
setResponseData(responseData)
|
|
29
|
+
return responseData
|
|
30
|
+
} catch (error) {
|
|
31
|
+
setError(error.message)
|
|
32
|
+
return {
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
setLoading(false)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { loading, error, responseData, handleTokenCardsSubmit }
|
|
41
|
+
}
|
package/src/utils/index.js
CHANGED
|
@@ -197,3 +197,14 @@ export const SERVICES = Object.freeze({
|
|
|
197
197
|
ADMIN_STORE: 'admin-store',
|
|
198
198
|
MAIN: 'main'
|
|
199
199
|
})
|
|
200
|
+
|
|
201
|
+
export const paymentMethodCards = [
|
|
202
|
+
{
|
|
203
|
+
name: 'Visa',
|
|
204
|
+
icon: 'IconVisa'
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'MasterCard',
|
|
208
|
+
icon: 'IconMasterCard'
|
|
209
|
+
}
|
|
210
|
+
]
|