npm-pkg-hook 1.9.2 → 1.9.4

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.9.2"
50
+ "version": "1.9.4"
51
51
  }
@@ -10,6 +10,34 @@ query employees {
10
10
  eEmail
11
11
  eState
12
12
  status
13
+ user {
14
+ id
15
+ name
16
+ username
17
+ lastName
18
+ email
19
+ avatar
20
+ uToken
21
+ uPhoNum
22
+ ULocation
23
+ upLat
24
+ uState
25
+ upLon
26
+ upIdeDoc
27
+ siteWeb
28
+ description
29
+ createAt
30
+ associateStore
31
+ }
32
+ roles {
33
+ idRole
34
+ name
35
+ priority
36
+ description
37
+ permissions
38
+ createdAt
39
+ updatedAt
40
+ }
13
41
  }
14
42
  success
15
43
  message
@@ -12,8 +12,34 @@ import { CREATE_ONE_EMPLOYEE_STORE_AND_USER } from './queries'
12
12
  * data: Object | null
13
13
  * }} An object containing the mutation function, loading status, error, and data.
14
14
  */
15
- export const useCreateEmployeeStoreAndUser = () => {
16
- const [createEmployeeStoreAndUserMutation, { loading, error, data }] = useMutation(CREATE_ONE_EMPLOYEE_STORE_AND_USER)
15
+ export const useCreateEmployeeStoreAndUser = ({
16
+ sendNotification = () => {
17
+ return {
18
+ description: '',
19
+ title: '',
20
+ backgroundColor: ''
21
+ }
22
+ },
23
+ onCompleted = () => {
24
+ return {
25
+ }
26
+ }
27
+ } = {}) => {
28
+ const [createEmployeeStoreAndUserMutation, { loading, error, data }] = useMutation(CREATE_ONE_EMPLOYEE_STORE_AND_USER, {
29
+ onCompleted: (response) => {
30
+ console.log(response)
31
+ const { createOneEmployeeStoreAndUser } = response ?? {}
32
+ const { message, success } = createOneEmployeeStoreAndUser ?? {}
33
+ if (success) {
34
+ onCompleted()
35
+ }
36
+ sendNotification({
37
+ description: message,
38
+ title: success ? 'Exito' : 'Error',
39
+ backgroundColor: success ? 'success' : 'error'
40
+ })
41
+ }
42
+ })
17
43
  const [errors, setErrors] = useState([])
18
44
 
19
45
  /**
@@ -81,17 +81,25 @@ export const useFormTools = ({
81
81
  if (errSub) return setErrorSubmit(errSub)
82
82
 
83
83
  // Ejecuta la accion si es válido
84
- if (!errSub && action) {
85
- action().then(res => {
86
- if (res) {
84
+ if (!errSub && typeof action === 'function') {
85
+ const result = action()
86
+ if (result && typeof result.then === 'function') {
87
+ result.then((res) => {
88
+ if (res) {
89
+ sendNotification({
90
+ message: msgSuccess ?? 'Operación exitosa',
91
+ description: 'Operación exitosa',
92
+ backgroundColor: 'success'
93
+ })
94
+ if (actionAfterSuccess) actionAfterSuccess()
95
+ }
96
+ }).catch((e) => {
87
97
  sendNotification({
88
- message: msgSuccess ?? 'Operación exitosa',
89
- description: 'Operación exitosa',
90
- backgroundColor: 'success'
98
+ title: msgError || e?.message || 'Ha ocurrido un error',
99
+ backgroundColor: 'error'
91
100
  })
92
- !!actionAfterSuccess && actionAfterSuccess()
93
- }
94
- }).catch(e => { return sendNotification({ title: msgError || e?.message || 'Ha ocurrido un error', backgroundColor: 'error' }) })
101
+ })
102
+ }
95
103
  }
96
104
 
97
105
  setErrorSubmit(errSub)
@@ -4,8 +4,30 @@ import { CREATE_ROLE_MUTATION } from './queries'
4
4
  * Custom hook para crear un nuevo rol
5
5
  * @returns {Object} - Estado de la mutación, incluyendo loading, error, data y la función createRoleMutation
6
6
  */
7
- export const useCreateRole = () => {
8
- const [createRoleMutation, { loading, error, data }] = useMutation(CREATE_ROLE_MUTATION)
7
+ export const useCreateRole = ({
8
+ sendNotification = () => {
9
+ return {
10
+ title: '',
11
+ description: '',
12
+ backgroundColor: ''
13
+ }
14
+ }
15
+ } = {
16
+ sendNotification: () => {
17
+ }
18
+ }) => {
19
+ const [createRoleMutation, { loading, error, data }] = useMutation(CREATE_ROLE_MUTATION, {
20
+ onError: () => {
21
+ sendNotification({
22
+ title: 'Error',
23
+ description: 'Ocurrió un error inesperado',
24
+ backgroundColor: 'error'
25
+ })
26
+ },
27
+ onCompleted: () => {
28
+ return null
29
+ }
30
+ })
9
31
 
10
32
  return [createRoleMutation, {
11
33
  loading,
@@ -23,7 +23,7 @@ export const useGetRoles = ({
23
23
  },
24
24
  variables: {
25
25
  search,
26
- max: max || 100,
26
+ max: max || 25,
27
27
  order
28
28
  }
29
29
  })