Skip to content

Commit

Permalink
refactor: Standardize js
Browse files Browse the repository at this point in the history
  • Loading branch information
eccentricexit committed Sep 3, 2018
1 parent 4424f29 commit 348ec64
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 92 deletions.
10 changes: 5 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const http = require('http')
const https = require('https')
const express = require('express')
const app = express()
app.use('*',ensureSecure)
app.use('*', ensureSecure)
app.use(express.static('build'))

const options = {
Expand All @@ -14,12 +14,12 @@ const options = {
http.createServer(app).listen(80)
https.createServer(options, app).listen(443)

function ensureSecure(req, res, next){
if(req.secure){
function ensureSecure (req, res, next) {
if (req.secure) {
// OK, continue
return next();
return next()
};
// handle port numbers if you need non defaults
// res.redirect('https://' + req.host + req.url); // express 3.x
res.redirect('https://' + req.hostname + req.url); // express 4.x
res.redirect('https://' + req.hostname + req.url) // express 4.x
}
2 changes: 0 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,3 @@ export function setProperty (property) {
property
}
}


2 changes: 1 addition & 1 deletion src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const SET_PROPERTY = 'SET_PROPERTY'
export const SET_ACTIVE = 'SET_ACTIVE'
export const SET_INFO = 'SET_INFO'

export const SET_LOADING = 'SET_LOADING'
export const SET_LOADING = 'SET_LOADING'
12 changes: 6 additions & 6 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import LoadingView from './layout/LoadingView'
class AppContainer extends React.Component {
render () {
const { isLoading, eosClient } = this.props

return (
<div className='fsapp'>
<Navbar />
<Container>
{isLoading && <LoadingView />}
{!isLoading && (
<div>
{eosClient.locked === true && <LoginContainer />}
{eosClient.locked !== true && <Properties />}
</div>
)}
<div>
{eosClient.locked === true && <LoginContainer />}
{eosClient.locked !== true && <Properties />}
</div>
)}
</Container>
</div>
)
Expand Down
20 changes: 10 additions & 10 deletions src/components/account/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const LoginForm = props => {
/>
{errors.privKey &&
touched.privKey && (
<FormFeedback>{errors.privKey}</FormFeedback>
)}
<FormFeedback>{errors.privKey}</FormFeedback>
)}
</FormGroup>

<Button type='submit' color='primary'>Unlock</Button>{' '}
{scatterDetected &&
{scatterDetected &&
<Button type='button' outline color='primary' onClick={onScatterClick}>Scatter</Button>
}
</Form>
Expand All @@ -43,20 +43,20 @@ const LoginForm = props => {
const EnhancedLoginForm = withFormik({
mapPropsToValues: () => ({ privKey: '' }),
validate: values => {
let errors = {};
let errors = {}
if (!values.privKey) {
errors.privKey = 'Required';
errors.privKey = 'Required'
} else if (values.privKey.length !== 51) {
errors.privKey = 'Invalid private key';
errors.privKey = 'Invalid private key'
}
return errors;
return errors
},

handleSubmit: ({ privKey }, { props }) => {
props.handleImportPrivKey(privKey)
},

displayName: 'LoginForm', // helps with React DevTools
displayName: 'LoginForm' // helps with React DevTools
})(LoginForm)

export default EnhancedLoginForm
export default EnhancedLoginForm
77 changes: 38 additions & 39 deletions src/components/account/SelectAcc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
import React from 'react'
import {
Button,
Modal,
ModalHeader,
ModalBody,
ModalFooter,
ListGroup,
ListGroupItem,
InputGroup,
InputGroupAddon,
Input
import {
Button,
Modal,
ModalHeader,
ModalBody,
ModalFooter,
ListGroup,
ListGroupItem,
InputGroup,
InputGroupAddon,
Input
} from 'reactstrap'

export default function SelectAcc (props) {
const { accounts, handleToggle, onAccountSelect, isOpen} = props
return (
<Modal isOpen={isOpen} toggle={handleToggle} >
<ModalHeader toggle={handleToggle}>Please select an account</ModalHeader>
<ModalBody>
<ListGroup>
{
accounts.map(account =>
(
<ListGroupItem key={account}>
<InputGroup>
<Input disabled value={account}/>
<InputGroupAddon addonType="append">
<Button onClick={() => onAccountSelect(account)}>
const { accounts, handleToggle, onAccountSelect, isOpen} = props
return (
<Modal isOpen={isOpen} toggle={handleToggle} >
<ModalHeader toggle={handleToggle}>Please select an account</ModalHeader>
<ModalBody>
<ListGroup>
{
accounts.map(account =>
(
<ListGroupItem key={account}>
<InputGroup>
<Input disabled value={account} />
<InputGroupAddon addonType='append'>
<Button onClick={() => onAccountSelect(account)}>
Select this account
</Button>
</InputGroupAddon>
</InputGroup>
</ListGroupItem>
)
)
}
</ListGroup>
</ModalBody>
<ModalFooter>
</ModalFooter>
</Modal>
)
}
</Button>
</InputGroupAddon>
</InputGroup>
</ListGroupItem>
)
)
}
</ListGroup>
</ModalBody>
<ModalFooter />
</Modal>
)
}
28 changes: 13 additions & 15 deletions src/components/layout/LoadingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import Spinner from 'react-spinkit'
import { Container } from 'reactstrap'

export default function LoadingView () {
return (
<Container className='justify-content-center align-items-center' >
<Spinner
className='justify-content-center align-items-center mx-auto'
name='line-scale'
color='#00B1EF'
style={{
width: 50,
marginTop: 270,
}}
/>
</Container>
)
return (
<Container className='justify-content-center align-items-center' >
<Spinner
className='justify-content-center align-items-center mx-auto'
name='line-scale'
color='#00B1EF'
style={{
width: 50,
marginTop: 270
}}
/>
</Container>
)
}


5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import 'bootstrap/dist/css/bootstrap.min.css'
// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const store = createStore(
reducer,
reducer
// composeEnhancers(
// applyMiddleware(logger)
// )
)


// Fallback eosjs
const eos = getFallbackEos(Eos)
store.dispatch(setEosClient({...eos,locked:true}))
store.dispatch(setEosClient({...eos, locked: true}))

getScatter.then(async (results) => {
const { scatter } = results
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/accountData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
SET_INFO
} from '../actions/types'

export function accountData (state = {}, action) {
export function accountData (state = {}, action) {
switch (action.type) {
case SET_ACTIVE: {
return {
Expand All @@ -16,7 +16,7 @@ export function accountData (state = {}, action) {
...state,
info: action.payload
}
}
}
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { accountData } from './accountData'
import { SET_LOADING } from '../actions/types'

function isLoading (state = false, action) {
switch (action.type) {
switch (action.type) {
case SET_LOADING: {
return action.payload
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/properties.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ADD_PROPERTIES,
SET_PROPERTY
SET_PROPERTY
} from '../actions/types'

export function properties (state = {}, action) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/consts.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const PROPERTY = 'property'
export const FSMGRCONTRACT = 'fsmgrcode111'
export const FSMGRCONTRACT = 'fsmgrcode111'
2 changes: 1 addition & 1 deletion src/utils/getScatter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let getScatter = new Promise((resolve, reject) => {
document.addEventListener('scatterLoaded', scatterExtension => {
document.addEventListener('scatterLoaded', scatterExtension => {
let scatter = window.scatter
window.scatter = null
if (typeof scatter === 'undefined') {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ export const idFromPath = (pathname) => {
return result === '' ? '-1' : result
}

export const getImportedKeyEos = (Eos,privKey) => {
export const getImportedKeyEos = (Eos, privKey) => {
const network = getNetworkData()
return Eos({
httpEndpoint: `${network.protocol}://${network.host}:${network.port}`,
httpEndpoint: `${network.protocol}://${network.host}:${network.port}`,
chainId: network.chainId,
keyProvider: privKey
})
}

export const getFallbackEos = (Eos) => {
export const getFallbackEos = (Eos) => {
const network = getNetworkData()
return Eos({
httpEndpoint: `${network.protocol}://${network.host}:${network.port}`,
httpEndpoint: `${network.protocol}://${network.host}:${network.port}`,
chainId: network.chainId
})
}
Expand Down Expand Up @@ -102,4 +102,4 @@ export const fakeData = {
postal_code: '58543',
unit_count: 4
}
}
}

0 comments on commit 348ec64

Please sign in to comment.