Bladeren bron

invalidate password query

amenpunk 3 jaren geleden
bovenliggende
commit
1c58836733
2 gewijzigde bestanden met toevoegingen van 19 en 3 verwijderingen
  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,6 +52,18 @@ export function HelpModal(props) {
     };
 
     const handleReset = () => {
+        setPassword({
+            puesto: [],
+            pwd: "",
+            deadpwd: now.current,
+            dateToActived: now.current,
+            nombres:"",
+            apellidos:"",
+            mail:"",
+            sendmail:true,
+            nombrepuesto:null,
+            nombreEmpresa:null,
+        })
         setActiveStep(0);
     };
 
@@ -94,6 +106,7 @@ export function HelpModal(props) {
                     handleBack={handleBack}
                     password={password}
                     handleClose={handleClose}
+                    handleReset={handleReset}
                 />
         },
     ];

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

@@ -8,7 +8,7 @@ import {
 
 import toast, { Toaster } from 'react-hot-toast';
 
-import { useMutation } from 'react-query';
+import { useMutation, useQueryClient } from 'react-query';
 import { Service } from '../../../Utils/HTTP.js'
 import useAuth from '../../../Auth/useAuth.js'
 
@@ -30,12 +30,13 @@ let theme = createTheme({
 
 export function Resume(props) {
 
-    let { handleBack, password: key, handleClose } = props
+    let { handleBack, password: key, handleClose,handleReset } = props
     const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
     const [pwdID, setPwdID] = React.useState(null);
     const [loading, setLoading] = React.useState(false);
     const auth = useAuth();
     const token = auth.getToken();
+    const queryClient = useQueryClient();
 
     const savePassword = async (body) => {
         let rest = new Service('/contrasenia/create')
@@ -90,12 +91,14 @@ export function Resume(props) {
                 candiMutation.mutate(candidatoBody, {
                     onSuccess: (data) => {
 
+                        queryClient.invalidateQueries('passwords')
                         toast.success("Contraseña agregada exitosamente!!")
                         setTimeout(() => {
                             console.log("OK LETS GO >> ", data,pwdID)
                             setLoading(false);
                             handleClose();
-                        }, 2000)
+                            handleReset();
+                        }, 1000)
 
                     },
                     onError: () => {