npm-pkg-hook 1.8.8 → 1.9.0

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
@@ -47,5 +47,5 @@
47
47
  "rm": "rm -rf node_modules package-lock.json && npm i",
48
48
  "test": "echo \"Error: no test specified\" && exit 1"
49
49
  },
50
- "version": "1.8.8"
50
+ "version": "1.9.0"
51
51
  }
@@ -1,4 +1,5 @@
1
1
  export async function handleLogin (body) {
2
+ console.log("🚀 ~ handleLogin ~ body:", body)
2
3
  const response = await fetch(`${process.env.URL_BASE}/api/auth/login`, {
3
4
  method: 'POST',
4
5
  headers: { 'Content-Type': 'application/json' },
@@ -12,10 +12,12 @@ export * from './useUpdateMultipleProducts'
12
12
  export * from './useTokenCards'
13
13
  export * from './useSubscriptionValidation'
14
14
  export * from './convertToMilitaryTime'
15
+ export * from './useRoles'
15
16
  export * from './statusOpenStores'
16
17
  export * from './completeSchedules'
17
18
  export * from './useLogout/helpers/BroadcastChannel'
18
19
  export * from './getCardType'
20
+ export * from './useLoginEmployeeInStore'
19
21
  export * from './useUploadProducts'
20
22
  export * from './useAmountInput'
21
23
  export * from './newMessageSubscription'
@@ -102,7 +102,6 @@ export const useAmountInput = props => {
102
102
  decimalsLimit
103
103
  )
104
104
  }
105
- console.log(inputValue)
106
105
  setInputValue(inputValue)
107
106
 
108
107
  const callbackValue = isNaN(amountFloatValue) ? 0 : amountFloatValue
@@ -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 [clientes, setClients] = useState([])
7
- const [more, setMore] = useState(100)
8
- const { data, loading, error, fetchMore } = useQuery(GET_EMPLOYEES)
9
- useEffect(() => {
10
- setClients(data)
11
- }, [clientes, data])
12
- return [clientes?.employees, { loading, error, fetchMore, setMore, more }]
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
- eId
7
- idStore
8
- idEmployee
9
- eSalary
10
- typeContract
11
- tpEmail
12
- termContract
13
- eDatAdm
14
- eState
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
- return { getCookies }
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './useCreateRole'
2
+ export * from './useGetRoles'
@@ -0,0 +1,70 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const GET_ALL_ROLES = gql`
4
+ query getRoles($idStore: ID, $search: String, $min: Int, $max: Int, $fromDate: DateTime, $toDate: DateTime, $page: Int) {
5
+ getRoles(idStore: $idStore, search: $search, min: $min, max: $max, fromDate: $fromDate, toDate: $toDate, page: $page) {
6
+ success
7
+ message
8
+ errors {
9
+ path
10
+ message
11
+ type
12
+ context {
13
+ limit
14
+ value
15
+ label
16
+ key
17
+ }
18
+ __typename
19
+ }
20
+ pagination {
21
+ totalRecords
22
+ totalPages
23
+ currentPage
24
+ __typename
25
+ }
26
+ data {
27
+ idRole
28
+ name
29
+ priority
30
+ description
31
+ permissions
32
+ createdAt
33
+ updatedAt
34
+ }
35
+ }
36
+ }
37
+ `
38
+
39
+ /**
40
+ * Mutación para crear un nuevo rol
41
+ */
42
+ export const CREATE_ROLE_MUTATION = gql`
43
+ mutation createRoleMutation($input: IRole!) {
44
+ createRoleMutation(input: $input) {
45
+ success
46
+ message
47
+ errors {
48
+ path
49
+ message
50
+ type
51
+ context {
52
+ limit
53
+ value
54
+ label
55
+ key
56
+ }
57
+ __typename
58
+ }
59
+ data {
60
+ idRole
61
+ name
62
+ priority
63
+ description
64
+ permissions
65
+ createdAt
66
+ updatedAt
67
+ }
68
+ }
69
+ }
70
+ `
@@ -0,0 +1,15 @@
1
+ import { useMutation } from '@apollo/client'
2
+ import { CREATE_ROLE_MUTATION } from './queries'
3
+ /**
4
+ * Custom hook para crear un nuevo rol
5
+ * @returns {Object} - Estado de la mutación, incluyendo loading, error, data y la función createRoleMutation
6
+ */
7
+ export const useCreateRole = () => {
8
+ const [createRoleMutation, { loading, error, data }] = useMutation(CREATE_ROLE_MUTATION)
9
+
10
+ return [createRoleMutation, {
11
+ loading,
12
+ error,
13
+ data: data?.createRoleMutation ?? null
14
+ }]
15
+ }
@@ -0,0 +1,36 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { GET_ALL_ROLES } from './queries'
3
+
4
+ export const useGetRoles = ({
5
+ max,
6
+ order = 'DESC',
7
+ search,
8
+ sendNotification = () => { }
9
+ } = {}) => {
10
+ const {
11
+ loading,
12
+ error,
13
+ called,
14
+ data,
15
+ refetch
16
+ } = useQuery(GET_ALL_ROLES, {
17
+ onError: () => {
18
+ sendNotification({
19
+ title: 'Error',
20
+ description: 'Algo salió mal',
21
+ backgroundColor: 'error'
22
+ })
23
+ },
24
+ variables: {
25
+ search,
26
+ max: max || 100,
27
+ order
28
+ }
29
+ })
30
+ return [data?.getRoles, {
31
+ loading: called ? false : loading,
32
+ buttonLoading: loading,
33
+ error,
34
+ refetch
35
+ }]
36
+ }
@@ -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
  }