Skip to content

Commit

Permalink
chore: fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adriexnet committed Oct 10, 2020
1 parent ad5ef92 commit 7bb76ff
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 96 deletions.
10 changes: 5 additions & 5 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trailingComma": "none",
"singleQuote": true,
"semi": false,
"tabWidth": 2
}
"trailingComma": "none",
"singleQuote": true,
"semi": false,
"tabWidth": 2
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
},
"optionalDependencies": {
"@types/node": "*",
"typescript": "*",
"webpack": "*"
"typescript": "*"
},
"files": [
"dist"
Expand Down
5 changes: 4 additions & 1 deletion src/components/ArrayTextField/ArrayTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ const ArrayTextField = ({
}

ArrayTextField.propTypes = {
value: PropTypes.array
value: PropTypes.array,
onChange: PropTypes.func,
className: PropTypes.string,
ChipProps: PropTypes.object
}

ArrayTextField.defaultProps = {
Expand Down
48 changes: 26 additions & 22 deletions src/components/BPJsonGenerator/BPJsonGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@ const initData = {
}
}

const defaultValidationState = {
candidate_name: {
isError: false,
message: 'Candidate Name is required'
},
email: {
isError: false,
message: 'Email is required'
},
website: {
isError: false,
message: 'Website is required'
},
code_of_conduct: {
isError: false,
message: 'Code of Conduct is required'
},
ownership_disclosure: {
isError: false,
message: 'Ownership Disclosure is required'
}
}

const useStyles = makeStyles((theme) => ({
wrapper: {
display: 'flex',
Expand Down Expand Up @@ -88,28 +111,9 @@ const BPJsonForm = ({ accountName, bpJson, onSubmit }) => {
const [nodes, setNodes] = useState([])
const [currentNodeIndex, setCurrentNodeIndex] = useState(null)
const [shouldUpdateChain, setShouldUpdateChain] = useState(false)
const [requiredFieldsValidation, setRequiredFieldsValidation] = useState({
candidate_name: {
isError: false,
message: 'Candidate Name is required'
},
email: {
isError: false,
message: 'Email is required'
},
website: {
isError: false,
message: 'Website is required'
},
code_of_conduct: {
isError: false,
message: 'Code of Conduct is required'
},
ownership_disclosure: {
isError: false,
message: 'Ownership Disclosure is required'
}
})
const [requiredFieldsValidation, setRequiredFieldsValidation] = useState(
defaultValidationState
)

const toCapitalCase = (string = '') => {
return string
Expand Down
59 changes: 28 additions & 31 deletions src/components/CreateAccount/CreateAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,16 @@ const AccountInfo = ({ onHandleSubmit, customBtnStyle }) => {
return (
<div>
<Button
size='large'
color='secondary'
size="large"
color="secondary"
onClick={handleOpen}
className={customBtnStyle}
>
Create Account
</Button>
<Modal
aria-labelledby='transition-modal-title'
aria-describedby='transition-modal-description'
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
open={open}
onClose={handleOpen}
Expand All @@ -279,20 +279,20 @@ const AccountInfo = ({ onHandleSubmit, customBtnStyle }) => {
}}
>
<div className={classes.paper}>
<form noValidate autoComplete='off'>
<form noValidate autoComplete="off">
<Grid
container
direction='column'
justify='space-between'
direction="column"
justify="space-between"
className={classes.root}
>
<div className={classes.deleteBtn}>
<Typography variant='h6' gutterBottom color='primary'>
<Typography variant="h6" gutterBottom color="primary">
Create Account
</Typography>
<IconButton
classes={{ root: classes.iconBtnPadding }}
aria-label='delete'
aria-label="delete"
onClick={() => setOpen(false)}
>
X
Expand All @@ -301,64 +301,61 @@ const AccountInfo = ({ onHandleSubmit, customBtnStyle }) => {
<div className={classes.inputBox}>
<Grid item>
<TextField
variant='filled'
variant="filled"
fullWidth
error={Boolean(values.accountName.error)}
helperText={
values.accountName.error ? values.accountName.error : ''
}
label='Account Name'
placeholder='eoscrtest123'
label="Account Name"
placeholder="eoscrtest123"
required
autoComplete='off'
name='accountName'
autoComplete="off"
name="accountName"
onChange={handleChange}
/>
</Grid>
<Grid item>
<TextField
variant='filled'
variant="filled"
fullWidth
error={Boolean(values.ownerPK.error)}
helperText={
values.ownerPK.error ? values.ownerPK.error : ''
}
label='Owner Public Key'
placeholder='EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'
label="Owner Public Key"
placeholder="EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
required
autoComplete='off'
name='ownerPK'
autoComplete="off"
name="ownerPK"
onChange={handleChange}
/>
</Grid>
<Grid item>
<TextField
variant='filled'
variant="filled"
fullWidth
error={Boolean(values.activePK.error)}
helperText={
values.activePK.error ? values.activePK.error : ''
}
label='Active Public Key'
placeholder='EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'
label="Active Public Key"
placeholder="EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
required
autoComplete='off'
name='activePK'
autoComplete="off"
name="activePK"
onChange={handleChange}
/>
</Grid>
<div className={classes.captcha}>
<ReCAPTCHA
sitekey={config.sitekey}
onChange={(value) => console.log({ value })}
/>
<ReCAPTCHA sitekey={config.sitekey} />
</div>
</div>
<div className={classes.btn}>
<Button
size='large'
variant='contained'
color='secondary'
size="large"
variant="contained"
color="secondary"
onClick={handleOnSubmit}
>
Create account
Expand Down
8 changes: 4 additions & 4 deletions src/components/DropzoneHash/DropzoneHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const useStyles = makeStyles((theme) => ({
height: '100%'
},
dropzoneBox: {
width: '100%',
maxWidth: 620,
height: '50vh',
display: 'flex',
justifyItems: 'center',
Expand All @@ -46,7 +48,7 @@ const DropzoneHash = ({ file, handleOnDropFile, deleteFile }) => {
<CardContent>
<Box
display="flex"
flexDirection="column"
flexDirection="row"
justifyContent="center"
alignContent="center"
>
Expand Down Expand Up @@ -99,14 +101,12 @@ const DropzoneHash = ({ file, handleOnDropFile, deleteFile }) => {

DropzoneHash.propTypes = {
handleOnDropFile: PropTypes.func,
sendButtonText: PropTypes.string,
file: PropTypes.object,
deleteFile: PropTypes.func
}

DropzoneHash.defaultProps = {
handleOnDropFile: () => {},
sendButtonText: 'Enviar'
handleOnDropFile: () => {}
}

export default DropzoneHash
2 changes: 1 addition & 1 deletion src/components/VisualCertificate/VisualCertificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const VisualCertificate = ({

VisualCertificate.propTypes = {
open: PropTypes.bool,
handleCose: PropTypes.func,
handleClose: PropTypes.func,
txData: PropTypes.object,
messages: PropTypes.object,
title: PropTypes.string,
Expand Down
12 changes: 7 additions & 5 deletions src/components/common/DropzoneBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import Typography from '@material-ui/core/Typography'
import Button from '@material-ui/core/Button'
import * as CryptoJS from 'crypto-js'
import { parseFile } from '../../utils/filereader'
import { Box } from '@material-ui/core'
import Box from '@material-ui/core/Box'
import VerticalAlignTopIcon from '@material-ui/icons/VerticalAlignTop'
import Snackbar from '@material-ui/core/Snackbar'
import Alert from '@material-ui/lab/Alert'

const SHA256_REGEX_VALIDATOR = /\b[A-Fa-f0-9]{64}\b/

const DropzoneBox = styled(Box)({
Expand All @@ -19,7 +20,6 @@ const DropzoneBox = styled(Box)({
backgroundColor: '#efefef',
cursor: 'pointer',
display: 'flex',
maxWidth: 620,
flexDirection: 'column',
justifyContent: 'space-evenly',
border: 'dashed 1px #212121',
Expand Down Expand Up @@ -89,14 +89,16 @@ const DropzoneBase = ({
} else fileChange(null)
}

const handleInputClick = (e) => e.preventDefault()

return (
<React.Fragment>
<Box width="100%" height="100%">
{!progress ? (
<DropzoneBox {...getRootProps()}>
<input
multiple="false"
accept=".json,.csv,.xls,.docx"
onClick={(e) => e.preventDefault()}
onClick={handleInputClick}
{...getInputProps()}
/>
<Typography>
Expand All @@ -122,7 +124,7 @@ const DropzoneBase = ({
{message.content}
</Alert>
</Snackbar>
</React.Fragment>
</Box>
)
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/filereader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const parseFile = (file, callback, progress) => {
const fileSize = file.size
const chunkSize = 64 * 1024
const success = true
let offset = 0
let chunkReaderBlock = null

Expand All @@ -11,7 +12,7 @@ export const parseFile = (file, callback, progress) => {
callback(evt.target.result)
} else return callback(new Error('Ha ocurrido un error leyendo el archivo'))

if (offset >= fileSize) return callback(true)
if (offset >= fileSize) return callback(success)

chunkReaderBlock(offset, chunkSize, file)
}
Expand Down
Loading

0 comments on commit 7bb76ff

Please sign in to comment.