Skip to content

Commit

Permalink
detect Internet connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyubinhan committed Jul 6, 2018
1 parent cf0ab5e commit 2b0abb2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"pikaday": "^1.7.0",
"prop-types": "^15.6.0",
"react": "^16.3.2",
"react-detect-offline": "^2.1.1",
"react-dom": "^16.3.2",
"react-pdf": "^2.5.3",
"react-redux": "^5.0.6",
Expand Down
7 changes: 6 additions & 1 deletion src/components/LandingPage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { Offline } from 'react-detect-offline';
import Navbar from './Navbar';
import Toast from './Toast';
import { userHaveRole, isUserActive } from '../utils';
import { fetchUser, fetchReferences, fetchZones } from '../actionCreators';
import { getUser } from '../reducers/rootReducer';
import { USER_NOT_ACTIVE, NO_INTERNET } from '../constants/strings';

const propTypes = {
component: PropTypes.func.isRequired,
Expand All @@ -32,8 +34,11 @@ export class LandingPage extends Component {
return (
<main>
<Navbar {...rest} />
<Offline>
<section className="offline">{NO_INTERNET}</section>
</Offline>
{ !isUserActive(user) &&
<div>This account is not active.</div>
<section>{USER_NOT_ACTIVE}</section>
}
{ userHaveRole(user) &&
<Component {...rest} />
Expand Down
1 change: 1 addition & 0 deletions src/constants/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const TOTAL_AUMS_EXCEEDS = 'Total AUMs exceeds authorized AUMs.';
export const USER_NOT_ACTIVE = 'This account is not active yet, please contact the administrator.';
export const USER_NOT_REGISTERED = 'This account has not been registered.';
export const LINK_CLIENT_SUCCESS = 'You have successfully linked the client.';
export const NO_INTERNET = 'There is no Internet connection.';

// modals
export const COMPLETED_CONFIRMATION_HEADER = 'Update Status: Completed';
Expand Down
7 changes: 7 additions & 0 deletions src/styles/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ body {
background: #fdfdfd;
}

.offline {
background-color: $error-color;
color: white;
text-align: center;
height: 20px;
}

footer {
height: 20px;
}
Expand Down

0 comments on commit 2b0abb2

Please sign in to comment.