npm-pkg-hook 1.8.8 → 1.8.9
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 +1 -1
- package/src/hooks/handleLogin/index.js +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useAmountInput/index.ts +0 -1
- package/src/hooks/useEmployee/index.js +12 -8
- package/src/hooks/useEmployee/queries.js +28 -10
- package/src/hooks/useGetCookies/index.js +18 -2
- package/src/hooks/useLoginEmployeeInStore/index.js +38 -0
- package/src/hooks/useUser/index.js +8 -2
- package/src/hooks/useUser/queries.js +3 -3
package/package.json
CHANGED
package/src/hooks/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from './statusOpenStores'
|
|
|
16
16
|
export * from './completeSchedules'
|
|
17
17
|
export * from './useLogout/helpers/BroadcastChannel'
|
|
18
18
|
export * from './getCardType'
|
|
19
|
+
export * from './useLoginEmployeeInStore'
|
|
19
20
|
export * from './useUploadProducts'
|
|
20
21
|
export * from './useAmountInput'
|
|
21
22
|
export * from './newMessageSubscription'
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
2
|
import { GET_EMPLOYEES } from './queries'
|
|
4
3
|
|
|
5
4
|
export const useEmployee = () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return [
|
|
5
|
+
const {
|
|
6
|
+
data,
|
|
7
|
+
loading,
|
|
8
|
+
error,
|
|
9
|
+
fetchMore
|
|
10
|
+
} = useQuery(GET_EMPLOYEES)
|
|
11
|
+
return [data?.employees?.data ?? [], {
|
|
12
|
+
loading,
|
|
13
|
+
error,
|
|
14
|
+
fetchMore,
|
|
15
|
+
pagination: data?.employees?.pagination
|
|
16
|
+
}]
|
|
13
17
|
}
|
|
@@ -3,15 +3,33 @@ import { gql } from '@apollo/client'
|
|
|
3
3
|
export const GET_EMPLOYEES = gql`
|
|
4
4
|
query employees {
|
|
5
5
|
employees {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
data {
|
|
7
|
+
eId
|
|
8
|
+
idStore
|
|
9
|
+
idRole
|
|
10
|
+
eEmail
|
|
11
|
+
eState
|
|
12
|
+
status
|
|
13
|
+
}
|
|
14
|
+
success
|
|
15
|
+
message
|
|
16
|
+
pagination {
|
|
17
|
+
totalRecords
|
|
18
|
+
totalPages
|
|
19
|
+
currentPage
|
|
20
|
+
}
|
|
21
|
+
errors {
|
|
22
|
+
path
|
|
23
|
+
message
|
|
24
|
+
type
|
|
25
|
+
context {
|
|
26
|
+
limit
|
|
27
|
+
value
|
|
28
|
+
label
|
|
29
|
+
key
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
}
|
|
16
34
|
}
|
|
17
|
-
`
|
|
35
|
+
`
|
|
@@ -11,7 +11,6 @@ export const useGetCookies = () => {
|
|
|
11
11
|
|
|
12
12
|
for (const cookieName of cookieNames) {
|
|
13
13
|
const cookieValue = Cookies.get(cookieName)
|
|
14
|
-
console.log({ cookieValue })
|
|
15
14
|
if (cookieValue) {
|
|
16
15
|
cookiesData.push({ name: cookieName, value: cookieValue })
|
|
17
16
|
}
|
|
@@ -23,5 +22,22 @@ export const useGetCookies = () => {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
const getCookie = (cookieName) => {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof cookieName !== 'string') {
|
|
28
|
+
throw new Error('Input cookie name should be a string.')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const cookieValue = Cookies.get(cookieName)
|
|
32
|
+
if (cookieValue) {
|
|
33
|
+
return { name: cookieName, value: cookieValue }
|
|
34
|
+
}
|
|
35
|
+
return null
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error al traer la cookie:', error)
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { getCookies, getCookie }
|
|
27
43
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { gql, useMutation } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
const LOGIN_EMPLOYEE_IN_STORE = gql`
|
|
4
|
+
mutation loginEmployeeInStore($eId: ID, $tenantId: String, $idStore: ID, $idUser: ID, $eEmail: String) {
|
|
5
|
+
loginEmployeeInStore(eId: $eId, tenantId: $tenantId, idStore: $idStore, idUser: $idUser, eEmail: $eEmail) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
token
|
|
9
|
+
idStore
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export const useLoginEmployeeInStore = () => {
|
|
15
|
+
const [loginEmployeeInStore, { data, loading, error }] = useMutation(LOGIN_EMPLOYEE_IN_STORE)
|
|
16
|
+
|
|
17
|
+
const loginEmployee = async (idStore, eEmail) => {
|
|
18
|
+
try {
|
|
19
|
+
const response = await loginEmployeeInStore({
|
|
20
|
+
variables: {
|
|
21
|
+
idStore,
|
|
22
|
+
eEmail
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
return response.data.loginEmployeeInStore
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.error('Error during loginEmployeeInStore mutation:', err)
|
|
28
|
+
throw err
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
loginEmployee,
|
|
34
|
+
data,
|
|
35
|
+
loading,
|
|
36
|
+
error
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@apollo/client'
|
|
2
2
|
import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
|
|
3
3
|
|
|
4
|
-
export const useUser = () => {
|
|
5
|
-
const { data, loading, error } = useQuery(GET_USER
|
|
4
|
+
export const useUser = (email) => {
|
|
5
|
+
const { data, loading, error } = useQuery(GET_USER, email !== ''
|
|
6
|
+
? {
|
|
7
|
+
variables: {
|
|
8
|
+
email
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
: {})
|
|
6
12
|
return [data?.getUser, { loading, error }]
|
|
7
13
|
}
|
|
8
14
|
|
|
@@ -48,8 +48,8 @@ query getOneUserProfile($id: ID) {
|
|
|
48
48
|
`
|
|
49
49
|
|
|
50
50
|
export const GET_USER = gql`
|
|
51
|
-
query getUser($id: ID){
|
|
52
|
-
getUser(id: $id ){
|
|
51
|
+
query getUser($id: ID, $email: String){
|
|
52
|
+
getUser(id: $id email: $email){
|
|
53
53
|
id
|
|
54
54
|
name
|
|
55
55
|
username
|
|
@@ -65,9 +65,9 @@ upLon
|
|
|
65
65
|
upIdeDoc
|
|
66
66
|
siteWeb
|
|
67
67
|
description
|
|
68
|
+
associateStore
|
|
68
69
|
createAt
|
|
69
70
|
role {
|
|
70
|
-
id
|
|
71
71
|
name
|
|
72
72
|
}
|
|
73
73
|
}
|