Skip to content

Commit

Permalink
fix request index
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianA01702752 committed May 1, 2023
1 parent d4a693b commit b211930
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
16 changes: 1 addition & 15 deletions GomezMorinFrontEnd/src/pages/Login/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React from "react";
import InputForm from "../../components/InputForm";
import Button from "../../components/Button";
import IconTitle from "../../components/IconTitle";
Expand All @@ -8,7 +8,6 @@ import { useForm, FormProvider } from "react-hook-form";
import { loginUser } from "../../queries/queryAuth";
import { useNavigate } from "react-router-dom";
import { setAccessToken, setUser } from "../../states/authSlice";
import { useSelector } from "react-redux";
import jwt_decode from "jwt-decode";
import { useDispatch } from "react-redux";
/**
Expand All @@ -20,19 +19,8 @@ import { useDispatch } from "react-redux";
const Login = () => {
const methods = useForm();
const navigate = useNavigate();
const [userName, setUserName] = useState("");
const [password, setPassword] = useState("");
const dispatch = useDispatch();

const handleInputChange = (event) => {
const { name, value } = event.target;
if (name === "userName") {
setUserName(value);
} else {
setPassword(value);
}
};

const onSubmitUser = async (data) => {
try {
const response = await loginUser(data);
Expand Down Expand Up @@ -65,7 +53,6 @@ const Login = () => {
placeholder="Ingresa tu Usuario"
defaultValue=""
value={userName}
onChange={handleInputChange}
/>
</div>

Expand All @@ -77,7 +64,6 @@ const Login = () => {
placeholder="Ingresa tu Contraseña"
defaultValue=""
value={password}
onChange={handleInputChange}
/>
</div>

Expand Down
8 changes: 6 additions & 2 deletions GomezMorinFrontEnd/src/pages/RequestForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const RequestForm = () => {
*
* @param {Object} data - The data collected from the form.
*/
const onSubmit = (data) => {
const onSubmit = async (data) => {
if (formState === "UserForm") {
dispatch(showUserForm());
}
Expand All @@ -82,7 +82,11 @@ const RequestForm = () => {

if (formState === "SubmitForm") {
/* Submit Form Logic */
createRequest({ ...data, userId: userId });
try {
await createRequest({ ...data, userId: userId });
} catch (err) {
alert(err.response.data.message);
}
}
};

Expand Down

0 comments on commit b211930

Please sign in to comment.