Commit d343af09 authored by Nicolás Alberto Puente Riquelme's avatar Nicolás Alberto Puente Riquelme
Browse files

login

parent 40c52636
......@@ -8,6 +8,7 @@
"name": "diu",
"version": "0.1.0",
"dependencies": {
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
......@@ -15,8 +16,10 @@
"react": "^17.0.2",
"react-bootstrap": "^2.0.3",
"react-dom": "^17.0.2",
"react-redux": "^7.2.2",
"react-router-dom": "^5.3.0",
"react-scripts": "^2.1.3",
"redux": "^4.1.2",
"web-vitals": "^2.1.2"
}
},
......@@ -1879,6 +1882,38 @@
"react": "^16.8.0 || ^17.0.0-rc.1"
}
},
"node_modules/@reduxjs/toolkit": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.7.1.tgz",
"integrity": "sha512-wXwXYjBVz/ItxB7SMzEAMmEE/FBiY1ze18N+VVVX7NtVbRUrdOGKhpQMHivIJfkbJvSdLUU923a/yAagJQzY0Q==",
"dependencies": {
"immer": "^9.0.7",
"redux": "^4.1.2",
"redux-thunk": "^2.4.1",
"reselect": "^4.1.5"
},
"peerDependencies": {
"react": "^16.9.0 || ^17.0.0 || 18.0.0-beta",
"react-redux": "^7.2.1 || ^8.0.0-beta"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-redux": {
"optional": true
}
}
},
"node_modules/@reduxjs/toolkit/node_modules/immer": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.7.tgz",
"integrity": "sha512-KGllzpbamZDvOIxnmJ0jI840g7Oikx58lBPWV0hUh7dtAyZpFqqrBZdKka5GlTwMTZ1Tjc/bKKW4VSFAt6BqMA==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/immer"
}
},
"node_modules/@restart/context": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@restart/context/-/context-2.1.4.tgz",
......@@ -15703,6 +15738,35 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"node_modules/react-redux": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.2.tgz",
"integrity": "sha512-8+CQ1EvIVFkYL/vu6Olo7JFLWop1qRUeb46sGtIMDCSpgwPQq8fPLpirIB0iTqFe9XYEFPHssdX8/UwN6pAkEA==",
"dependencies": {
"@babel/runtime": "^7.12.1",
"hoist-non-react-statics": "^3.3.2",
"loose-envify": "^1.4.0",
"prop-types": "^15.7.2",
"react-is": "^16.13.1"
},
"peerDependencies": {
"react": "^16.8.3 || ^17",
"redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
},
"react-native": {
"optional": true
}
}
},
"node_modules/react-redux/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/react-router": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.1.tgz",
......@@ -15986,6 +16050,22 @@
"node": ">=8"
}
},
"node_modules/redux": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.1.2.tgz",
"integrity": "sha512-SH8PglcebESbd/shgf6mii6EIoRM0zrQyjcuQ+ojmfxjTtE0z9Y8pa62iA/OJ58qjP6j27uyW4kUF4jl/jd6sw==",
"dependencies": {
"@babel/runtime": "^7.9.2"
}
},
"node_modules/redux-thunk": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==",
"peerDependencies": {
"redux": "^4"
}
},
"node_modules/regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
......@@ -16359,6 +16439,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"node_modules/reselect": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.5.tgz",
"integrity": "sha512-uVdlz8J7OO+ASpBYoz1Zypgx0KasCY20H+N8JD13oUMtPvSHQuscrHop4KbXrbsBcdB9Ds7lVK7eRkBIfO43vQ=="
},
"node_modules/resolve": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
......@@ -21237,6 +21322,24 @@
"@babel/runtime": "^7.6.2"
}
},
"@reduxjs/toolkit": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.7.1.tgz",
"integrity": "sha512-wXwXYjBVz/ItxB7SMzEAMmEE/FBiY1ze18N+VVVX7NtVbRUrdOGKhpQMHivIJfkbJvSdLUU923a/yAagJQzY0Q==",
"requires": {
"immer": "^9.0.7",
"redux": "^4.1.2",
"redux-thunk": "^2.4.1",
"reselect": "^4.1.5"
},
"dependencies": {
"immer": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.7.tgz",
"integrity": "sha512-KGllzpbamZDvOIxnmJ0jI840g7Oikx58lBPWV0hUh7dtAyZpFqqrBZdKka5GlTwMTZ1Tjc/bKKW4VSFAt6BqMA=="
}
}
},
"@restart/context": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@restart/context/-/context-2.1.4.tgz",
......@@ -32260,6 +32363,25 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"react-redux": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.2.tgz",
"integrity": "sha512-8+CQ1EvIVFkYL/vu6Olo7JFLWop1qRUeb46sGtIMDCSpgwPQq8fPLpirIB0iTqFe9XYEFPHssdX8/UwN6pAkEA==",
"requires": {
"@babel/runtime": "^7.12.1",
"hoist-non-react-statics": "^3.3.2",
"loose-envify": "^1.4.0",
"prop-types": "^15.7.2",
"react-is": "^16.13.1"
},
"dependencies": {
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
}
}
},
"react-router": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.1.tgz",
......@@ -32498,6 +32620,20 @@
"strip-indent": "^3.0.0"
}
},
"redux": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.1.2.tgz",
"integrity": "sha512-SH8PglcebESbd/shgf6mii6EIoRM0zrQyjcuQ+ojmfxjTtE0z9Y8pa62iA/OJ58qjP6j27uyW4kUF4jl/jd6sw==",
"requires": {
"@babel/runtime": "^7.9.2"
}
},
"redux-thunk": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==",
"requires": {}
},
"regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
......@@ -32788,6 +32924,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"reselect": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.5.tgz",
"integrity": "sha512-uVdlz8J7OO+ASpBYoz1Zypgx0KasCY20H+N8JD13oUMtPvSHQuscrHop4KbXrbsBcdB9Ds7lVK7eRkBIfO43vQ=="
},
"resolve": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
......@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
......@@ -10,8 +11,10 @@
"react": "^17.0.2",
"react-bootstrap": "^2.0.3",
"react-dom": "^17.0.2",
"react-redux": "^7.2.2",
"react-router-dom": "^5.3.0",
"react-scripts": "^2.1.3",
"redux": "^4.1.2",
"web-vitals": "^2.1.2"
},
"scripts": {
......
......@@ -5,7 +5,23 @@ import 'bootstrap/dist/css/bootstrap.min.css';
import Exposicion from "./components/Exposiciones.js"
import zoro from "./images/zoro.jpg";
import { BrowserRouter as Router, Route, Switch, Link } from 'react-router-dom';
import Login from "./components/login.js";
import {useSelector, useDispatch} from 'react-redux';
import { logout } from './redux/actions/autentication';
function App() {
const count= useSelector((store) =>store.autenticacion.logged);
const Name=useSelector((store) =>store.autenticacion.Nombre);
const dispatch = useDispatch();
if (count){
var xd = "xd"
}else{
var xd= "xd`nt"
}
const Logout=()=>{
dispatch(logout(Name))
}
return (
<Router>
<Navbar bg="light" expand="lg">
......@@ -16,27 +32,32 @@ function App() {
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="me-auto">
<Nav.Link href="#home">SEMINARIOS</Nav.Link>
<Nav.Link as={Link} to="/Sem">SEMINARIOS</Nav.Link>
<Nav.Link as={Link} to="/Expos">EXPOSICIONES</Nav.Link>
</Nav>
<Form inline>
<FormControl type="text" placeholder="Buscar" className="mr-sm-2" />
<Button variant="outline-success">Buscar</Button>
</Form>
{count==true&&(
<Button onClick={Logout} variant="danger">Cerrar Sesión</Button>
)}
{count==false&&(
<Button as={Link} to= "/Login" variant="outline-success">Iniciar Sesión</Button>
)}
</Navbar.Collapse>
</Container>
</Navbar>
<center>
<h1>Feria de Software</h1>
<br/>
<br/>
</center>
<Switch>
<Route path="/Expos">
<Container>
<center>
<h1>Feria de Software {Name}</h1>
<br/>
<br/>
</center>
<Row >
<Col className='col-md-4'>
<Exposicion title= "proyecto1" link="https://www3.animeflv.net/anime/ousama-ranking" img={zoro} />
......@@ -60,11 +81,10 @@ function App() {
<Exposicion title= "proyectoX" link="https://www3.animeflv.net/anime/ousama-ranking" img={zoro} />
</Col>
</Row>
</Container>
</Container>
</Route>
<Route path="/Login" exact render = {props=> ( <Login {...props} />)}></Route>
</Switch>
</Router>
......
......@@ -7,15 +7,15 @@ function Expos(props){
return (
<Container>
<Card style={{ width: '18rem'}}>
<Card.Img variant="top" src= {props.img} />
<Card.Body>
<Card.Title>{props.title}</Card.Title>
<Card.Text>
{props.description} </Card.Text>
<a href ={props.link}>Más Información</a>
</Card.Body>
</Card>
<Card style={{ width: '18rem'}}>
<Card.Img variant="top" src= {props.img} />
<Card.Body>
<Card.Title>{props.title}</Card.Title>
<Card.Text>
{props.description} </Card.Text>
<a href ={props.link}>Más Información</a>
</Card.Body>
</Card>
</Container>
......
.Login{
width: 368px;
text-align: center;
margin-top:100px;
}
\ No newline at end of file
import React, { useState } from 'react';
import {Container, Button, Form, Row} from 'react-bootstrap';
import {login} from '../redux/actions/autentication.js';
import {useDispatch} from 'react-redux';
import './login.css';
function Login(props){
const [Name, setName]=useState("");
const [Clave, setClave]=useState("");
const dispatch= useDispatch();
const handleName=(e) =>{
setName(e.target.value);
}
const handleClave=(e) =>{
setClave(e.target.value);
}
const Submit=(e)=>{
e.preventDefault();
dispatch(login(Name))
props.history.push("/Expos");
}
return (
<Container>
<center>
<Form className="Login" >
<h1>Login</h1>
<Form.Group controlId="formBasicEmail">
<Form.Label>Ingrese Usuario</Form.Label>
<Form.Control type="text" placeholder="user" onChange={handleName} />
</Form.Group>
<Form.Group controlId="formBasicPassword">
<Form.Label>Ingrese Contraseña</Form.Label>
<Form.Control type="password" placeholder="Contraseña" onChange={handleClave} />
</Form.Group>
<br/>
<Button variant="primary" type="submit" onClick={Submit}>
INGRESAR
</Button>
</Form>
</center>
</Container>
);
}
export default Login;
\ No newline at end of file
......@@ -3,10 +3,16 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {Provider} from 'react-redux';
import store from './redux/store.js';
ReactDOM.render(
<React.StrictMode>
<App />
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById('root')
);
......
export const LOGIN = 'LOGIN';
export const LOGOUT = 'LOGOUT';
export const login = (nombre) =>{
return{
type: LOGIN,
payload: {
logged: true,
Nombre: nombre,
},
}
}
export const logout = () =>{
return{
type: LOGOUT,
payload: {
logged: false,
Nombre:"",
},
}
}
\ No newline at end of file
import { LOGIN, LOGOUT } from '../actions/autentication.js';
const initialState ={
logged: false,
Nombre:"",
}
const autenticacion = (state=initialState, action) =>{
switch(action.type){
case LOGIN:
return{
...state,
...action.payload,
};
case LOGOUT:
return{
...state,
...action.payload,
};
default:
return state;
}
}
export default autenticacion;
\ No newline at end of file
import {createStore, combineReducers} from 'redux';
import autenticacion from './reducers/AutenReducer.js';
import PPDAReducer from './reducers/PPDAReducer.js';
import MedidaReducer from './reducers/MedidaReducer.js';
import autenticacion from './reducers/AutenReducers.js';
const appReducer = combineReducers({
autenticacion: autenticacion,
PPDAReducer: PPDAReducer,
MedidaReducer :MedidaReducer,
})
export default createStore(appReducer);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment