Browse Source

invalidate password query

amenpunk 2 years ago
parent
commit
1c58836733
2 changed files with 19 additions and 3 deletions
  1. 13 0
      src/Components/Modal/PasswordModal.jsx
  2. 6 3
      src/Components/Password/Steps/resume.jsx

+ 13 - 0
src/Components/Modal/PasswordModal.jsx

52
     };
52
     };
53
 
53
 
54
     const handleReset = () => {
54
     const handleReset = () => {
55
+        setPassword({
56
+            puesto: [],
57
+            pwd: "",
58
+            deadpwd: now.current,
59
+            dateToActived: now.current,
60
+            nombres:"",
61
+            apellidos:"",
62
+            mail:"",
63
+            sendmail:true,
64
+            nombrepuesto:null,
65
+            nombreEmpresa:null,
66
+        })
55
         setActiveStep(0);
67
         setActiveStep(0);
56
     };
68
     };
57
 
69
 
94
                     handleBack={handleBack}
106
                     handleBack={handleBack}
95
                     password={password}
107
                     password={password}
96
                     handleClose={handleClose}
108
                     handleClose={handleClose}
109
+                    handleReset={handleReset}
97
                 />
110
                 />
98
         },
111
         },
99
     ];
112
     ];

+ 6 - 3
src/Components/Password/Steps/resume.jsx

8
 
8
 
9
 import toast, { Toaster } from 'react-hot-toast';
9
 import toast, { Toaster } from 'react-hot-toast';
10
 
10
 
11
-import { useMutation } from 'react-query';
11
+import { useMutation, useQueryClient } from 'react-query';
12
 import { Service } from '../../../Utils/HTTP.js'
12
 import { Service } from '../../../Utils/HTTP.js'
13
 import useAuth from '../../../Auth/useAuth.js'
13
 import useAuth from '../../../Auth/useAuth.js'
14
 
14
 
30
 
30
 
31
 export function Resume(props) {
31
 export function Resume(props) {
32
 
32
 
33
-    let { handleBack, password: key, handleClose } = props
33
+    let { handleBack, password: key, handleClose,handleReset } = props
34
     const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
34
     const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
35
     const [pwdID, setPwdID] = React.useState(null);
35
     const [pwdID, setPwdID] = React.useState(null);
36
     const [loading, setLoading] = React.useState(false);
36
     const [loading, setLoading] = React.useState(false);
37
     const auth = useAuth();
37
     const auth = useAuth();
38
     const token = auth.getToken();
38
     const token = auth.getToken();
39
+    const queryClient = useQueryClient();
39
 
40
 
40
     const savePassword = async (body) => {
41
     const savePassword = async (body) => {
41
         let rest = new Service('/contrasenia/create')
42
         let rest = new Service('/contrasenia/create')
90
                 candiMutation.mutate(candidatoBody, {
91
                 candiMutation.mutate(candidatoBody, {
91
                     onSuccess: (data) => {
92
                     onSuccess: (data) => {
92
 
93
 
94
+                        queryClient.invalidateQueries('passwords')
93
                         toast.success("Contraseña agregada exitosamente!!")
95
                         toast.success("Contraseña agregada exitosamente!!")
94
                         setTimeout(() => {
96
                         setTimeout(() => {
95
                             console.log("OK LETS GO >> ", data,pwdID)
97
                             console.log("OK LETS GO >> ", data,pwdID)
96
                             setLoading(false);
98
                             setLoading(false);
97
                             handleClose();
99
                             handleClose();
98
-                        }, 2000)
100
+                            handleReset();
101
+                        }, 1000)
99
 
102
 
100
                     },
103
                     },
101
                     onError: () => {
104
                     onError: () => {