npm-pkg-hook 1.8.0 → 1.8.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/package.json CHANGED
@@ -44,5 +44,5 @@
44
44
  "rm": "rm -rf node_modules package-lock.json && npm i",
45
45
  "test": "echo \"Error: no test specified\" && exit 1"
46
46
  },
47
- "version": "1.8.0"
47
+ "version": "1.8.1"
48
48
  }
@@ -0,0 +1,24 @@
1
+ export const getCardType = (cardNum) => {
2
+ let payCardType = ''
3
+
4
+ if (cardNum.startsWith('4')) {
5
+ payCardType = 'VISA'
6
+ } else if (cardNum.startsWith('5')) {
7
+ payCardType = 'MASTERCARD'
8
+ } else {
9
+ const regexMap = [
10
+ { regEx: /^4[0-9]{5}/gi, cardType: 'VISA' },
11
+ { regEx: /^5[1-5][0-9]{4}/gi, cardType: 'MASTERCARD' },
12
+ { regEx: /^(5[06-8]\d{4}|6\d{5})/gi, cardType: 'MAESTRO' }
13
+ ]
14
+
15
+ for (const { regEx, cardType } of regexMap) {
16
+ if (cardNum.match(regEx)) {
17
+ payCardType = cardType
18
+ break
19
+ }
20
+ }
21
+ }
22
+
23
+ return payCardType
24
+ }
@@ -12,7 +12,9 @@ export * from './convertToMilitaryTime'
12
12
  export * from './statusOpenStores'
13
13
  export * from './completeSchedules'
14
14
  export * from './useLogout/helpers/BroadcastChannel'
15
+ export * from './getCardType'
15
16
  export * from './newMessageSubscription'
17
+ export * from './useGetCookies'
16
18
  export * from './isTokenExpired'
17
19
  export * from './useCreateDeliveryTime'
18
20
  export * from './addTenMinutes'
@@ -0,0 +1,27 @@
1
+ import Cookies from 'js-cookie'
2
+
3
+ export const useGetCookies = () => {
4
+ const getCookies = (cookieNames) => {
5
+ try {
6
+ if (!Array.isArray(cookieNames)) {
7
+ throw new Error('Input cookie names should be an array.')
8
+ }
9
+
10
+ const cookiesData = []
11
+
12
+ for (const cookieName of cookieNames) {
13
+ const cookieValue = Cookies.get(cookieName)
14
+ console.log({ cookieValue })
15
+ if (cookieValue) {
16
+ cookiesData.push({ name: cookieName, value: cookieValue })
17
+ }
18
+ }
19
+ return cookiesData
20
+ } catch (error) {
21
+ console.error('Error al traer las cookies:', error)
22
+ return []
23
+ }
24
+ }
25
+
26
+ return { getCookies }
27
+ }
@@ -1,22 +1,21 @@
1
- import { useState, useEffect } from 'react';
2
- import Cookies from 'js-cookie';
1
+ import { useState, useEffect } from 'react'
2
+ import Cookies from 'js-cookie'
3
3
 
4
4
  export const useGetStoreCookie = () => {
5
- const [vpStoreCookie, setVpStoreCookie] = useState(null);
5
+ const [vpStoreCookie, setVpStoreCookie] = useState(null)
6
6
 
7
7
  useEffect(() => {
8
8
  const getCookieValue = () => {
9
- const cookieValue = Cookies.get(process.env.SESSION_NAME);
10
- console.log('Cookie Value:', cookieValue);
9
+ const cookieValue = Cookies.get(process.env.SESSION_NAME)
10
+ console.log('Cookie Value:', cookieValue)
11
11
 
12
12
  if (cookieValue) {
13
- setVpStoreCookie(cookieValue);
13
+ setVpStoreCookie(cookieValue)
14
14
  }
15
- };
15
+ }
16
16
 
17
- getCookieValue();
18
- }, []); // Empty dependency array, so this effect runs once
19
-
20
- return vpStoreCookie;
21
- };
17
+ getCookieValue()
18
+ }, []) // Empty dependency array, so this effect runs once
22
19
 
20
+ return vpStoreCookie
21
+ }