npm-pkg-hook 1.5.1 → 1.5.3

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
@@ -43,5 +43,5 @@
43
43
  "rm": "rm -rf node_modules package-lock.json && npm i",
44
44
  "test": "echo \"Error: no test specified\" && exit 1"
45
45
  },
46
- "version": "1.5.1"
46
+ "version": "1.5.3"
47
47
  }
@@ -1,10 +1,10 @@
1
- export async function handleLogin(body) {
2
- const response = await fetch(`${process.env.URL_BASE}/api/auth/login`, {
3
- method: 'POST',
4
- headers: { 'Content-Type': 'application/json' },
5
- body: JSON.stringify(body),
6
- credentials: 'include'
7
- })
1
+ export async function handleLogin (body) {
2
+ const response = await fetch(`${process.env.URL_BASE}/api/auth/login`, {
3
+ method: 'POST',
4
+ headers: { 'Content-Type': 'application/json' },
5
+ body: JSON.stringify(body),
6
+ credentials: 'include'
7
+ })
8
8
 
9
- return response.json()
10
- }
9
+ return response.json()
10
+ }
@@ -9,6 +9,7 @@ import { useCart, useGetCart } from '../useCart'
9
9
  import { useManageQueryParams } from '../useManageQueryParams'
10
10
  import { calculateTotalPrice } from './helpers'
11
11
  export * from './helpers'
12
+
12
13
  /**
13
14
  * Custom hook for managing the shopping cart functionality.
14
15
  * @param {Object} props - Props to control various UI elements.
@@ -19,18 +20,23 @@ export * from './helpers'
19
20
  */
20
21
  export const useAsideCart = ({
21
22
  openModalProduct = false,
23
+ location = {},
22
24
  setCountItemProduct = () => { },
23
25
  setAlertBox = () => { },
24
26
  setOpenModalProduct = () => { },
25
27
  handleMenu = () => { }
26
28
  } = {}) => {
29
+
27
30
  const { getOneProduct } = useCart({
28
31
  handleMenu,
29
32
  openModalProduct,
33
+ location,
30
34
  setOpenModalProduct
31
35
  })
32
36
 
33
- const { handleQuery } = useManageQueryParams()
37
+ const { handleQuery } = useManageQueryParams({
38
+ location
39
+ })
34
40
 
35
41
  const [totalProductPrice, setTotalProductPrice] = useState(0)
36
42
 
@@ -5,7 +5,6 @@ import { RandomCode, updateCacheMod, numberFormat } from '../../../utils'
5
5
  import { useExtProductFoodsAll, useGetOneProductsFood } from '../../useProductsFood'
6
6
  import { useGetExtProductFoodsSubOptionalAll } from '../../useGetExtProductFoodsSubOptionalAll'
7
7
  import { useGetCart } from '../useGetCart'
8
- import { useRouter } from 'next/router'
9
8
  import {
10
9
  filterDataOptional,
11
10
  filterExtra,
@@ -29,19 +28,21 @@ import { useManageQueryParams } from '../../useManageQueryParams'
29
28
  * @returns The `useCart` function returns an object with the following properties and methods:
30
29
  */
31
30
  export const useCart = ({
31
+ location = {},
32
32
  openModalProduct = false,
33
33
  handleMenu = () => { },
34
34
  setOpenModalProduct = () => { },
35
35
  setAlertBox = () => { }
36
36
  } = {}) => {
37
37
  // sub products
38
- const { handleCleanQuery } = useManageQueryParams()
38
+ const { handleCleanQuery } = useManageQueryParams({
39
+ location
40
+ })
39
41
 
40
42
  const [dataOptional, setDataOptional] = useState([])
41
43
  const [dataExtra, setDataExtra] = useState([])
42
44
  const [quantity, setQuantity] = useState(1)
43
45
  const [comments, setComments] = useState('')
44
- const location = useRouter()
45
46
  const queryParamProduct = location.query.plato
46
47
  const [registerShoppingCard] = useMutation(CREATE_SHOPPING_CARD, {
47
48
  onError: (error) => {
@@ -36,6 +36,12 @@ export const useLogout = ({ setAlertBox = () => {} } = {}) => {
36
36
  const onClickLogout = async () => {
37
37
  try {
38
38
  setLoading(true)
39
+ // Eliminar la cookie process.env.SESSION_NAME
40
+ await eliminarCookie(process.env.SESSION_NAME)
41
+ await Cookies.remove(process.env.LOCAL_SALES_STORE)
42
+ await Cookies.remove('restaurant')
43
+ await Cookies.remove('usuario')
44
+ await Cookies.remove('session')
39
45
 
40
46
  // Logout from the server
41
47
  const logoutResponse = await fetch(`${process.env.URL_BASE}/api/auth/logout/`, {
@@ -48,7 +54,6 @@ export const useLogout = ({ setAlertBox = () => {} } = {}) => {
48
54
 
49
55
  if (!logoutResponse.ok) {
50
56
  setLoading(false)
51
- // Handle unsuccessful logout request, e.g., show an error message
52
57
  return
53
58
  }
54
59
 
@@ -1,13 +1,17 @@
1
- import { useRouter } from 'next/router'
2
1
  // Hola mundo
3
- export const useManageQueryParams = () => {
4
- const router = useRouter()
5
-
2
+ export const useManageQueryParams = ({
3
+ location = {
4
+ query: {},
5
+ push: (props, state, { shallow }) => {
6
+ return { ...props, state, shallow }
7
+ }
8
+ }
9
+ } = {}) => {
6
10
  const handleQuery = (name, value = '') => {
7
- router.push(
11
+ location.push(
8
12
  {
9
13
  query: {
10
- ...router.query,
14
+ ...location.query,
11
15
  [name]: value
12
16
  }
13
17
  },
@@ -18,10 +22,10 @@ export const useManageQueryParams = () => {
18
22
 
19
23
  const handleCleanQuery = (name, value = '') => {
20
24
  const updatedQuery = {
21
- ...router.query,
25
+ ...location.query,
22
26
  [name]: value || ''
23
27
  }
24
- router.push(
28
+ location.push(
25
29
  {
26
30
  query: updatedQuery
27
31
  },
@@ -10,7 +10,9 @@ export const useRestaurant = ({
10
10
  }
11
11
  } = {}) => {
12
12
  const [loadingFilter, setLoadingFilter] = useState(false)
13
- const { handleQuery, handleCleanQuery } = useManageQueryParams()
13
+ const { handleQuery, handleCleanQuery } = useManageQueryParams({
14
+ location
15
+ })
14
16
 
15
17
  const [getAllStoreInStore, {
16
18
  data,
package/next.config.js DELETED
@@ -1,126 +0,0 @@
1
- /* eslint-disable consistent-return */
2
- /** @type {import('next').NextConfig} */
3
- const {
4
- PHASE_DEVELOPMENT_SERVER,
5
- PHASE_PRODUCTION_BUILD
6
- } = require('next/constants')
7
- const nextConfig = {
8
- reactStrictMode: true
9
- }
10
- module.exports = (phase) => {
11
- // npm run dev or next dev
12
- const isDev = phase === PHASE_DEVELOPMENT_SERVER
13
- // npm run build or next build
14
- const isProd = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
15
- // npm run build or next build
16
- const isStaging = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
17
- const env = {
18
- NAMEDB: (() => {
19
- if (isDev) return 'app'
20
- if (isProd) return 'railway'
21
- })(),
22
- USERDB: (() => {
23
- if (isDev) return 'root'
24
- if (isProd) return 'root'
25
- })(),
26
- PASSDB: (() => {
27
- if (isDev) return ''
28
- if (isProd) return '8jpgm70bhVjWIxEFbsrt'
29
- })(),
30
- HOSTDB: (() => {
31
- if (isDev) return 'localhost'
32
- if (isProd) return 'containers-us-west-65.railway.app'
33
- })(),
34
- DIALECTDB: 'mysql',
35
- SESSION_NAME: 'vp.client',
36
- SESSION_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXa',
37
- URL_BASE: (() => {
38
- if (isDev) return 'http://localhost:3001/'
39
- if (isProd) return 'http://localhost:3001/'
40
- // if (isStaging) return 'Title Stg'
41
- })(),
42
- MAIN_URL_BASE: (() => {
43
- if (isDev) return 'http://localhost:3000/'
44
- if (isProd) return 'http://localhost:3000/'
45
- if (isStaging) return 'Title Stg'
46
- })(),
47
- // URL_BASE_WS
48
- URL_ADMIN_SERVER: (() => {
49
- if (isDev) return 'http://localhost:4000/'
50
- // if (isDev) return 'https://server-image-food.herokuapp.com/'
51
- if (isProd) return 'http://localhost:4000/'
52
- })(),
53
- // BANCOLOMBIA
54
- BANCOLOMBIA_CLIENT_KEY: '55929729-85fe-4ffe-928d-0bd317817be4',
55
- BANCOLOMBIA_SECRET_KEY: 'E1aM2bV2lD7vS8cH1qJ8oN0nD7eN0eP0rM8gU0cG2lL6uY5sO7',
56
- JWT_EXPIRY: 333300,
57
- REFRESH_TOKEN_EXPIRY: '604800',
58
- AUTHO_USER_KEY: '12ba105efUaGjihGrh0LfJHTGIBGu6jXV',
59
- ACCESS_SID_TWILIO: 'AC7c9ccbdb50400c504faf629e35aea8e4',
60
- REACT_APP_API_KEY_GOOGLE_MAPS: 'AIzaSyAy0SY1G3OFqesWSTQRHJvzyJzNgURPoN8',
61
- ACCESS_TOKEN_AUTH_TWILIO: '22e090d4d776ace7bb596ca77cba6b18'
62
- }
63
-
64
- const resolveUniqueReactForHooks = {
65
- webpack: (config, options) => {
66
- if (options.isServer) {
67
- config.externals = ['react', ...config.externals]
68
- }
69
- // eslint-disable-next-line no-undef
70
- config.resolve.alias.react = reactPath
71
- return config
72
- },
73
- images: {
74
- domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com']
75
- }
76
- }
77
- const headers = () => {
78
- return [
79
- {
80
- source: '',
81
- headers: [
82
- {
83
- key: 'x-custom-header-1',
84
- value: 'my custom header 1'
85
- }
86
- ]
87
- }
88
- ]
89
- }
90
- const redirects = () => {
91
- return [
92
- {
93
- source: '/home',
94
- destination: '/',
95
- permanent: true
96
- }
97
- ]
98
- }
99
- // puedes sobre escribir la ruta
100
- const rewrites = () => {
101
- return [
102
- {
103
- source: '/ab',
104
- destination: '/about'
105
- }
106
- ]
107
- }
108
- const assetPrefix = isProd ? 'https://cdn.mydomain.com' : ''
109
- const images = {
110
- domains: ['http2.mlstatic.com', 'localhost', 'server-image-food.herokuapp.com', '*']
111
- }
112
- return {
113
- env,
114
- swcMinify: false,
115
- images,
116
- headers,
117
- optimizeFonts: false,
118
- nextConfig,
119
- // basePath,
120
- rewrites,
121
- redirects,
122
- assetPrefix,
123
- resolveUniqueReactForHooks
124
- }
125
- }
126
- // module.exports = nextConfig