8000 Frontend terminado,corregir ciertos errores por las dependencias de r… · hall9zeha/JavaScript-Projects@5af5b7d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5af5b7d

Browse files
committed
Frontend terminado,corregir ciertos errores por las dependencias de react-router-dom, por el cambio de versiones
1 parent f2a74d9 commit 5af5b7d

25 files changed

+694
-18
lines changed

Project/.gitignore

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
API/node_modules
2-
API/package-lock.json
2+
API/package-lock.json
3+
frontend/node_modules
4+
frontend/package-lock.json
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
frontend/.DS_Store
14+
frontend/.env.local
15+
frontend/.env.development.local
16+
frontend/.env.test.local
17+
frontend/.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

Project/API/controllers/patientController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports.newClient = async (req,res,next) =>{
88

99
//creamos un objeto con los datos del paciente obtenidos en req.body
1010

11-
const patient = new Patient(re.body);
11+
const patient = new Patient(req.body);
1212

1313
try {
1414
await patient.save();

Project/API/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@ const mongoose = require('mongoose');
33
const routes = require('./routes'); // como contiene un index.js no hay necesidad de ponerlo, JS lo leera automáticamente
44
//creamos el servidor
55
const bodyParser = require('body-parser');
6+
const cors = require('cors');
67

78

89
const app = express();
910

11+
12+
//escondemos la visibilidad de nuestra api con cors
13+
const whitelist = ['http://localhost:3000'];
14+
const corsOptions = {
15+
origin:(origin, callback) => {
16+
const exist = whitelist.some(domain=> domain === origin);
17+
if(exist){
18+
callback(null,true)
19+
}
20+
else{
21+
callback(new Error('no permitido por CORS'))
22+
}
23+
}
24+
}
25+
26+
//app.use(cors(corsOptions));
27+
//
28+
//pero mientras lo mantendremos abierto
29+
app.use(cors());
1030
// conectar a mongoDB
1131

1232
mongoose.Promise = global.Promise;

Project/API/models/Patient.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const patientSchema = new Schema({
2121
signals:{
2222
type: String,
2323
trim: true
24+
},
25+
phone:{
26+
type: String,
27+
trim: true
2428
}
2529

2630

Project/API/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"author": "Barry Zea H.",
1010
"license": "ISC",
1111
"dependencies": {
12+
"cors": "^2.8.5",
1213
"express": "^4.18.1",
1314
"mongoose": "^6.5.2"
1415
},

Project/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@
55
- React
66
- Electron
77

8-
# Instalar
9-
8+
# Instalar Backend
9+
- Creamos una carpeta API dentro de esa carpeta crearemos todos los archivos de nuestro backend, e instalaremos las dependencias necesarias.
10+
- Inicializamos el proyecto con ```npm init ```
1011
- ``` npm install express mongoose ``` -> Para realizar consultas a mongo db de una manera más sencilla, y para crear un servidor local con express.
11-
- ``` npm install --save-dev nodemon ```
12+
- ``` npm install --save-dev nodemon ```
13+
- ``` npm install axios ``` para consumir nuestra api hecha en mongodb
14+
15+
# Frontend
16+
17+
- Creamos una carpeta "frontend" dentro de esa carpeta crearemos todos los archivos de nuestro backend, también las dependencias necesarias.
18+
- Salimos de la carpeta API y en la raíz del proyecto creamos la app 'frontend' con react
19+
``` npx create-react-app frontend ```
20+
21+
- ``` npm install react-router-dom ```
22+
- ``` npm install cors ```
23+
- ``` npm install sweetalert2 ```

Project/frontend/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REACT_APP_BACKEND_URL= http://localhost:4000

Project/frontend/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13+
14+
The page will reload when you make changes.\
15+
You may also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35+
36+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39+
40+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `npm run build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

Project/frontend/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "frontend",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^5.16.5",
7+
"@testing-library/react": "^13.3.0",
8+
"@testing-library/user-event": "^13.5.0",
9+
"axios": "^0.27.2",
10+
"react": "^18.2.0",
11+
"react-dom": "^18.2.0",
12+
"react-router-dom": "^5.2.0",
13+
"react-scripts": "5.0.1",
14+
"sweetalert2": "^11.4.29",
15+
"web-vitals": "^2.1.4"
16+
},
17+
"scripts": {
18+
"start": "react-scripts start",
19+
"build": "react-scripts build",
20+
"test": "react-scripts test",
21+
"eject": "react-scripts eject"
22+
},
23+
"eslintConfig": {
24+
"extends": [
25+
"react-app",
26+
"react-app/jest"
27+
]
28+
},
29+
"browserslist": {
30+
"production": [
31+
">0.2%",
32+
"not dead",
33+
"not op_mini all"
34+
],
35+
"development": [
36+
"last 1 chrome version",
37+
"last 1 firefox version",
38+
"last 1 safari version"
39+
]
40+
}
41+
}

Project/frontend/public/css/app.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
html {
2+
box-sizing: border-box;
3+
font-size: 62.5%;
4+
}
5+
*, *:before, *:after {
6+
box-sizing: inherit;
7+
}
8+
9+
body {
10+
background: #AA076B;
11+
background: -webkit-linear-gradient(to right, #61045F, #AA076B);
12+
background: linear-gradient(to right, #61045F, #AA076B);
13+
font-size: 1.6rem;
14+
}
15+
16+
17+
h1 {
18+
text-align: center;
19+
font-family: 'Staatliches', cursive;
20+
color: white;
21+
font-size: 4rem;
22+
}
23+
h2 {
24+
25+
}
26+
h3 {
27+
font-family: 'Staatliches', cursive;
28+
color:#AA076B;
29+
font-size: 2.4rem;
30+
}
31+
.btn {
32+
font-size:1.4rem;
33+
}
34+
.fecha-alta {
35+
font-family: 'Staatliches', cursive;
36+
color: #AA076B;
37+
font-weight: bold;
38+
font-size: 2rem;
39+
}
40+
.contacto p {
41+
font-size: 1.2rem;
42+
margin: 0;
43+
}
44+
.list-group-item:hover {
45+
background: white;
46+
}
47+
form {
48+
border-radius: .3rem;
49+
}

0 commit comments

Comments
 (0)
0