Skip to content

Commit

Permalink
Final Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkumar-22 committed May 18, 2022
1 parent b6822fb commit 5c748a1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Vaxtrail Web App

### Deployed Link: https://superlative-marigold-19de0c.netlify.app/

## Introduction

Vaxtrail is an online vaccine booking or distribution system, helping users to tackle the current pandemic. It’s a completely online system which would promote digitization and even promote social distancing as slots for vaccination would be available at the nearest hospital <b>(within 2 kilometres of radius)</b> everyday thus reducing/ minimizing the risk of overcrowding.
Expand Down
16 changes: 16 additions & 0 deletions backend/routes/hospitals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const router = require("express").Router();
let Location = require("../models/hospital.model");
const axios = require("axios");

Location = Location.Location;

Expand Down Expand Up @@ -65,6 +66,21 @@ router.route("/govt").get((req, res) => {
});
});

router.route("/news").all((req, res) => {
axios
.get(
"https://newsapi.org/v2/everything?apiKey=f6f396807a8248ed98cec28d06fe6bd7&q=coronavirus&language=en&pageSize=20"
)
.then(function (response) {
// handle success
res.send(response.data);
})
.catch(function (error) {
// handle error
console.log(error);
});
});

router.route("/pvt").get((req, res) => {
Location.find({ type: "pvt" }).then((data) => {
res.send(data);
Expand Down
16 changes: 14 additions & 2 deletions src/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ function News() {
const [news, setNews] = useState([]);
useEffect(() => {
async function getNews() {
// await axios
// .get(
// "https://newsapi.org/v2/everything?apiKey=f6f396807a8248ed98cec28d06fe6bd7&q=coronavirus&language=en&pageSize=20"
// )
// .then(function (response) {
// // handle success
// setNews(response.data.articles);
// })
// .catch(function (error) {
// // handle error
// console.log(error);
// });
await axios
.get(
"https://newsapi.org/v2/everything?apiKey=f6f396807a8248ed98cec28d06fe6bd7&q=coronavirus&language=en&pageSize=20"
"http://localhost:5000/hospitals/news"
)
.then(function (response) {
// handle success
console.log(response);
setNews(response.data.articles);
})
.catch(function (error) {
Expand All @@ -21,7 +34,6 @@ function News() {
}
getNews();
}, []);
// console.log(news);
return (
<div className="news-clm">
<h1 className="stats-heading">LATEST COVID-19 NEWS</h1>
Expand Down
38 changes: 25 additions & 13 deletions src/Topbar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Link } from "react-router-dom";
import { useDataLayerValue } from "./DataLayer";
import Cookies from 'js-cookie';
import Cookies from "js-cookie";
const linkstyle = {
textDecoration: "none",
};
Expand All @@ -15,8 +15,8 @@ function Topbar() {
type: "SET_LOGGED",
logged: false,
});
Cookies.remove('loggedcookie');
Cookies.remove('name');
Cookies.remove("loggedcookie");
Cookies.remove("name");
} else console.log("Can't Logout");
}
return (
Expand All @@ -42,29 +42,41 @@ function Topbar() {
<p className="tab-options">REGISTRATIONS</p>
</Link>
)}
{!logged && <Link to="/status" style={linkstyle}>
<p className="tab-options">STATUS</p>
</Link>}
{!logged && (
<Link to="/status" style={linkstyle}>
<p className="tab-options">STATUS</p>
</Link>
)}

{!logged && <Link to="/hospitals" style={linkstyle}>
<p className="tab-options">HOSPITALS</p>
</Link>}
{!logged && (
<Link to="/hospitals" style={linkstyle}>
<p className="tab-options">HOSPITALS</p>
</Link>
)}
<Link to="/vaccines" style={linkstyle}>
<p className="tab-options">VACCINES</p>
</Link>
{!logged && (
<>
<Link to="/login" style={linkstyle}>
<p className="tab-options">LOGIN</p>
</Link>
<Link to="/admin/register" style={linkstyle}>
<p className="tab-options">REGISTER</p>
</Link>
</>
)}
{logged && <p className="tab-options">||</p>}
{/* {logged ? (
<Link to="/" style={linkstyle} onClick={handleLogout}>
<p className="tab-options">{username.toUpperCase()}</p>
</Link>
) : (
<Link to="/login" style={linkstyle}>
<p className="tab-options">LOGIN</p>
</Link>
)} */}
{logged && (
<Link to="/" style={linkstyle} onClick={handleLogout}>
<p className="tab-options">{username.toUpperCase()}</p>
<p className="tab-options">{username.toUpperCase()}</p>
</Link>
)}
</div>
Expand Down

0 comments on commit 5c748a1

Please sign in to comment.