Procházet zdrojové kódy

invalidate password query

amenpunk před 2 roky
rodič
revize
1c58836733

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

@@ -52,6 +52,18 @@ export function HelpModal(props) {
52 52
     };
53 53
 
54 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 67
         setActiveStep(0);
56 68
     };
57 69
 
@@ -94,6 +106,7 @@ export function HelpModal(props) {
94 106
                     handleBack={handleBack}
95 107
                     password={password}
96 108
                     handleClose={handleClose}
109
+                    handleReset={handleReset}
97 110
                 />
98 111
         },
99 112
     ];

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

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