Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All steps are Completed #223

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.ico
Binary file not shown.
128 changes: 102 additions & 26 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,105 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link type="text/plain" rel="author" href="humans.txt" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/7.17.1/firebase-analytics.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js"></script>
<script src="https://kit.fontawesome.com/0d4aacb00e.js" crossorigin="anonymous"></script>
<title>MyCovidConnect: Find Nearest Healthcare facility</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
</body>

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link type="text/plain" rel="author" href="humans.txt" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script
defer
src="https://www.gstatic.com/firebasejs/7.17.1/firebase-analytics.js"
></script>
<script
defer
src="https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js"
></script>
<script
src="https://kit.fontawesome.com/0d4aacb00e.js"
crossorigin="anonymous"
></script>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<link rel="manifest" href="manifest.json" />
<title>MyCovidConnect: Find Nearest Healthcare facility</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div class="add-to" id="add-to">
<div style="position: fixed; bottom: 10px; right: 10px; color: green">
<button class="add-to-btn" id="add-to-btn">Install Our App</button>
</div>
</div>
<script>

if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/serviceworker.js")
.then(function (registration) {
console.info(
"Service worker registered with these scopes.",
registration.scope
);

})
.catch(function (error) {
console.log(error);
});
}

let deferredPrompt;

var div = document.querySelector(".add-to");
var button = document.querySelector(".add-to-btn");
div.style.display = "none";
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt = e;
div.style.display = "block";
console.log(`'beforeinstallprompt' event was fired.`);
button.addEventListener("click", async () => {
div.style.display = "none";
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
console.log(`User response to the install prompt: ${outcome}`);
deferredPrompt = null;
});
window.addEventListener("appinstalled", () => {
div.style.display = "none";
deferredPrompt = null;
console.log("PWA was installed");
});
});
</script>
<script
async
defer
src="https://scripts.simpleanalyticscdn.com/latest.js"
></script>
<noscript
><img
src="https://queue.simpleanalyticscdn.com/noscript.gif"
alt=""
referrerpolicy="no-referrer-when-downgrade"
/></noscript>
</body>
</html>
26 changes: 26 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"short_name": "mycovidconnecct",
"name": "XCOV19",
"description": "Web app for covid patients",
"icons": [
{
"src": "cookie-icon.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "512x512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
40 changes: 40 additions & 0 deletions public/offline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>You are offline</title>
<style>
body {
font-family: helvetica, arial, sans-serif;
margin: 2em;
}

h1 {
font-style: italic;
color: #373fff;
}
p {
margin-block: 1rem;
}

button {
display: block;
}
</style>
shehzad-haroon marked this conversation as resolved.
Show resolved Hide resolved
</head>
<body>
<h1>You are offline</h1>
<button type="button">⤾ Reload</button>
<script>
document.querySelector('button').addEventListener('click', () => {
window.location.reload();
});
window.addEventListener('online', () => {
window.location.reload();
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Disallow:
42 changes: 42 additions & 0 deletions public/serviceworker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable array-callback-return */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you wrap this inside a class and export?

/*jshint esversion: 6 */
const CACHE_NAME = "version-1";
shehzad-haroon marked this conversation as resolved.
Show resolved Hide resolved
const urlsToCache = [ 'index.html', 'offline.html' ];
const SELF = this;
/* eslint-disable array-callback-return */
SELF.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
console.log('Opened cache');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are debugging using these logs, print them only if DEBUG is enabled. see my comment on DEBUG somewhere above in the review

return cache.addAll(urlsToCache);
})
);
});
/* eslint-disable array-callback-return */
SELF.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then(() => {
return fetch(event.request)
.catch(() => caches.match('offline.html'))
shehzad-haroon marked this conversation as resolved.
Show resolved Hide resolved
})
);
});
/* eslint-disable array-callback-return */
SELF.addEventListener('activate', (event) => {
const cacheWhitelist = [];
cacheWhitelist.push(CACHE_NAME);
event.waitUntil(
caches.keys().then((cacheNames) => Promise.all(
cacheNames.map((cacheName) => {
if(!cacheWhitelist.includes(cacheName)) {
return caches.delete(cacheName);
}
})
))

);


});
22 changes: 22 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* h1 {
font-style: italic;
color: #373fff;
} */
/* button {
display: block;
} */
.add-button {
position: absolute;
top: 1px;
left: 1px;
}
.add-to-btn {
background-color: #f15c08;
padding: 10px;
border: 0px;
color: wheat;
border-radius: 20px;
font-weight: normal;
text-transform: capitalize;
font-family: "Lato", sans-serif;
}
2 changes: 1 addition & 1 deletion src/firebase/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ const CONSTANTS = {
FIREBASE_MSG_SENDER_ID: process.env.REACT_APP_FIREBASE_MSG_SENDER_ID,
FIREBASE_APP_ID: process.env.REACT_APP_FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID,
REACT_APP_DEBUG: process.env.REACT_APP_DEBUG,
}

export default CONSTANTS;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ReactDOM.render(<App />, document.getElementById("root"));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
serviceWorker.register();
4 changes: 2 additions & 2 deletions src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA

/*jshint esversion: 6 */
const isLocalhost = Boolean(
window.location.hostname === "localhost" ||
// [::1] is the IPv6 localhost address.
Expand All @@ -32,7 +32,7 @@ export function register(config) {
}

window.addEventListener("load", () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
const swUrl = `${process.env.PUBLIC_URL}/serviceworker.js`;

if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"resolveJsonModule": true,
"jsx": "react"
"jsx": "react",
"noFallthroughCasesInSwitch": true
},
"include": [
"src/**/*"
Expand Down