added loading and new npm

This commit is contained in:
2025-11-12 16:35:22 -06:00
parent c04fb22d07
commit b581b6d22e
5 changed files with 992 additions and 384 deletions
-1
View File
@@ -1 +0,0 @@
NEXT_PUBLIC_API_URL=
+958 -370
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -11,22 +11,22 @@
"dependencies": { "dependencies": {
"@ericblade/quagga2": "^1.8.4", "@ericblade/quagga2": "^1.8.4",
"@zxing/library": "^0.21.3", "@zxing/library": "^0.21.3",
"axios": "^1.13.1", "axios": "^1.13.2",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"next": "15.5.6", "next": "16.0.2",
"react": "19.1.0", "react": "19.2.0",
"react-dom": "19.1.0", "react-dom": "19.2.0",
"react-hot-toast": "^2.6.0" "react-hot-toast": "^2.6.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3", "@eslint/eslintrc": "^3",
"@types/js-cookie": "^3.0.6", "@types/js-cookie": "^3.0.6",
"@types/node": "^20", "@types/node": "^24",
"@types/react": "^19", "@types/react": "^19",
"@types/react-dom": "^19", "@types/react-dom": "^19",
"eslint": "^9", "eslint": "^9",
"eslint-config-next": "15.5.6", "eslint-config-next": "16.0.2",
"sass": "^1.93.2", "sass": "^1.94.0",
"typescript": "^5" "typescript": "^5"
} }
} }
+8 -1
View File
@@ -11,12 +11,15 @@ import toast from "react-hot-toast";
export default function Login() { export default function Login() {
const [nombre, setNombre] = useState(""); const [nombre, setNombre] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const router = useRouter(); const router = useRouter();
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => { const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); e.preventDefault();
setLoading(true);
try { try {
const response = await axios.post( const response = await axios.post(
`${process.env.NEXT_PUBLIC_API_URL}/auth/login`, `${process.env.NEXT_PUBLIC_API_URL}/auth/login`,
@@ -43,6 +46,8 @@ export default function Login() {
} else { } else {
toast.error("Ocurrió un error inesperado"); toast.error("Ocurrió un error inesperado");
} }
} finally {
setLoading(false);
} }
}; };
@@ -71,7 +76,9 @@ export default function Login() {
required required
/> />
</div> </div>
<button type="submit">Iniciar sesión</button> <button type="submit" disabled={loading}>
{loading ? "Buscando..." : "Iniciar sesión"}
</button>
{/* <Link href={"/forgotPassword"}>Olvidaste Contraseña?</Link> */} {/* <Link href={"/forgotPassword"}>Olvidaste Contraseña?</Link> */}
{/* <Link href={"/crearCuenta"}>Crear Cuenta</Link> */} {/* <Link href={"/crearCuenta"}>Crear Cuenta</Link> */}
+19 -5
View File
@@ -1,7 +1,11 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2017", "target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"], "lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
@@ -11,7 +15,7 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "react-jsx",
"incremental": true, "incremental": true,
"plugins": [ "plugins": [
{ {
@@ -19,9 +23,19 @@
} }
], ],
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": [
"./src/*"
]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "include": [
"exclude": ["node_modules"] "next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
} }