Skip to content

Commit

Permalink
run prettier on files
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Pasik committed Jan 21, 2021
1 parent e03a961 commit 2176dee
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 87 deletions.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "daily"
rebase-strategy: "auto"
interval: 'daily'
rebase-strategy: 'auto'
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.1.0",
"private": true,
"scripts": {
"start": "yarn server & react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"precommit": "lint-staged",
"server": "yarn json-server --watch ./data/data.json --port 3010"
"server": "yarn json-server --watch ./data/data.json --port 3010",
"start": "yarn server & react-scripts start",
"test": "react-scripts test --env=jsdom"
},
"lint-staged": {
"*.js": [
Expand All @@ -16,6 +16,12 @@
"git add"
]
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"resolutions": {
"immer": "^8.0.1"
},
Expand All @@ -33,11 +39,5 @@
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.9",
"react-scripts": "^4.0.1"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
}
9 changes: 2 additions & 7 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<title>Babylon Web Test</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
</body>
</html>
43 changes: 19 additions & 24 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
import React, { Component } from 'react'
import React, { Component } from 'react';

import logo from './logo.png'
import { API_ENDPOINT } from './config'
import logo from './logo.png';
import { API_ENDPOINT } from './config';

import './App.scss'
import './App.scss';

class App extends Component {
constructor(props) {
super(props)
super(props);

this.state = {
userId: 1,
selectedAppointmentType: 'gp',
availableSlots: [],
}
};
}

componentDidMount() {
fetch(`${API_ENDPOINT}/availableSlots`)
.then((res) => res.json())
.then((json) => {
this.setState({ availableSlots: json })
this.setState({ availableSlots: json });
})
.catch(() => {
// TODO: Handle error here
})
});
}

onClick() {
this.setState({ selectedAppointmentType: 'gp' })
this.setState({ selectedAppointmentType: 'gp' });
}

render() {
// calculate matching slots
let slots = []
let slots = [];
for (let i = 0; i < this.state.availableSlots.length; i++) {
for (
let j = 0;
j < this.state.availableSlots[i]['consultantType'].length;
j++
) {
for (let j = 0; j < this.state.availableSlots[i]['consultantType'].length; j++) {
if (
this.state.availableSlots[j]['consultantType'][i] ===
this.state.selectedAppointmentType
this.state.availableSlots[j]['consultantType'][i] === this.state.selectedAppointmentType
) {
slots.push(this.state.availableSlots[j])
slots.push(this.state.availableSlots[j]);
}
}
}
Expand All @@ -62,23 +57,23 @@ class App extends Component {
<div
className="button"
onClick={(e) => {
this.setState({ selectedAppointmentType: 'Therapist' })
this.setState({ selectedAppointmentType: 'Therapist' });
}}
>
Therapist
</div>
<div
className="button"
onClick={(e) => {
this.setState({ selectedAppointmentType: 'Physio' })
this.setState({ selectedAppointmentType: 'Physio' });
}}
>
Physio
</div>
<div
className="button"
onClick={(e) => {
this.setState({ selectedAppointmentType: 'specialist' })
this.setState({ selectedAppointmentType: 'specialist' });
}}
>
Specialist
Expand All @@ -89,7 +84,7 @@ class App extends Component {
<li
className="appointment-button"
onClick={() => {
this.setState({ selectedAppointment: slot })
this.setState({ selectedAppointment: slot });
}}
>
{slot.time}
Expand All @@ -112,8 +107,8 @@ class App extends Component {
</div>
</div>
</div>
)
);
}
}

export default App
export default App;
12 changes: 6 additions & 6 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
})
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_ENDPOINT = 'http://localhost:3010'
const API_ENDPOINT = 'http://localhost:3010';

// eslint-disable-next-line import/prefer-default-export
export { API_ENDPOINT }
export { API_ENDPOINT };
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import 'normalize.css'
import React from 'react';
import ReactDOM from 'react-dom';
import 'normalize.css';

import App from './App'
import registerServiceWorker from './registerServiceWorker'
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'))
registerServiceWorker()
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
50 changes: 23 additions & 27 deletions src/registerServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,31 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
)
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
);

export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location)
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return
return;
}

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

if (!isLocalhost) {
// Is not local host. Just register service worker
registerValidSW(swUrl)
registerValidSW(swUrl);
} else {
// This is running on localhost. Lets check if a service worker still exists or not.
checkValidServiceWorker(swUrl)
checkValidServiceWorker(swUrl);
}
})
});
}
}

Expand All @@ -48,28 +46,28 @@ function registerValidSW(swUrl) {
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log('New content is available; please refresh.')
console.log('New content is available; please refresh.');
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.')
console.log('Content is cached for offline use.');
}
}
}
}
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error)
})
console.error('Error during service worker registration:', error);
});
}

function checkValidServiceWorker(swUrl) {
Expand All @@ -84,25 +82,23 @@ function checkValidServiceWorker(swUrl) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload()
})
})
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl)
registerValidSW(swUrl);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
)
})
console.log('No internet connection found. App is running in offline mode.');
});
}

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister()
})
registration.unregister();
});
}
}

0 comments on commit 2176dee

Please sign in to comment.