From 1410364feef714b0f64bbaaee6391b604d31555b Mon Sep 17 00:00:00 2001 From: IO Date: Thu, 13 Jun 2024 14:29:51 -0600 Subject: [PATCH] fixed login --- .env | 3 ++- package-lock.json | 19 ------------------- src/App.css | 1 + src/App.js | 3 +-- src/{ => components}/LoginForm.js | 10 +++++++--- src/components/header.js | 0 src/components/style.css | 4 ++++ 7 files changed, 15 insertions(+), 25 deletions(-) rename src/{ => components}/LoginForm.js (87%) create mode 100644 src/components/header.js create mode 100644 src/components/style.css diff --git a/.env b/.env index b695eaa..dcfc0b4 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ -API_URL = localhost 3000 +API_URL = http://localhost:3000 + PORT = 3001 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 39ff197..0213649 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", - "cross-env": "^7.0.3", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", @@ -6876,24 +6875,6 @@ "node": ">=10" } }, - "node_modules/cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "bin": { - "cross-env": "src/bin/cross-env.js", - "cross-env-shell": "src/bin/cross-env-shell.js" - }, - "engines": { - "node": ">=10.14", - "npm": ">=6", - "yarn": ">=1" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/src/App.css b/src/App.css index 5884d3b..399fe76 100644 --- a/src/App.css +++ b/src/App.css @@ -46,6 +46,7 @@ form { } div { + margin-bottom: 1em; } diff --git a/src/App.js b/src/App.js index 579580e..7c5b601 100644 --- a/src/App.js +++ b/src/App.js @@ -1,11 +1,10 @@ import React from 'react'; import './App.css'; -import LoginForm from './LoginForm'; +import LoginForm from './components/LoginForm'; const App = () => { return (
-

Página de Login

); diff --git a/src/LoginForm.js b/src/components/LoginForm.js similarity index 87% rename from src/LoginForm.js rename to src/components/LoginForm.js index 0568f5e..d18f676 100644 --- a/src/LoginForm.js +++ b/src/components/LoginForm.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import "./style.css" const LoginForm = () => { const [username, setUsername] = useState(''); @@ -13,14 +14,17 @@ const LoginForm = () => { setError(null); try { - const response = await fetch(`${process.env.API_URL}/login`, { + const response = await fetch(`${process.env.API_URL}/auth/login`, { method: 'POST', - body: JSON.stringify({ username, password, rememberMe }), + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ username, password}), }); console.log(response) console.log(process.env.API_URL) if (!response.ok) { - throw new Error('Error en la solicitud'); + throw new Error('Error in the log'); } const data = await response.json(); diff --git a/src/components/header.js b/src/components/header.js new file mode 100644 index 0000000..e69de29 diff --git a/src/components/style.css b/src/components/style.css new file mode 100644 index 0000000..1e6aed6 --- /dev/null +++ b/src/components/style.css @@ -0,0 +1,4 @@ +.submit{ + width: 200px; + height: auto; +} \ No newline at end of file