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

fix(frontend): solve is define or is assigned but never use issues #837

Merged
merged 2 commits into from
Jun 22, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'
import { useMutation } from '@apollo/react-hooks'
import { makeStyles, useTheme } from '@material-ui/styles'
import { makeStyles } from '@material-ui/styles'
import PropTypes from 'prop-types'
import Box from '@material-ui/core/Box'
import Typography from '@material-ui/core/Typography'
Expand Down Expand Up @@ -146,9 +146,9 @@ const CredentialsRecovery = ({ onCloseCredentialsRecovery }) => {
}}
InputProps={{
endAdornment: (
<InputLabel id="select-label">
{t('common.registeredEmail')}
</InputLabel>
<InputLabel id="select-label">
{t('common.registeredEmail')}
</InputLabel>
)
}}
onChange={(event) =>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/LanguageSelector/LanguageSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const LanguageSelector = ({ alt }) => {
const theme = useTheme()
const location = useLocation()
const isHome = location.pathname === '/'
const [currentUser, { login }] = useUser()
const [ changeLanguageMutation ] = useMutation(CHANGE_LANGUAGE)
const [currentUser] = useUser()
const [changeLanguageMutation] = useMutation(CHANGE_LANGUAGE)

const trigger = useScrollTrigger({
target: window || undefined,
Expand Down
26 changes: 5 additions & 21 deletions webapp/src/components/LoginModal/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo, useState, useEffect } from 'react'
import { useQuery, useMutation } from '@apollo/react-hooks'
import { useMutation } from '@apollo/react-hooks'
import PropTypes from 'prop-types'
import { makeStyles, useTheme } from '@material-ui/styles'
import { useTranslation } from 'react-i18next'
Expand All @@ -25,8 +25,6 @@ import DialogContent from '@material-ui/core/DialogContent'

import {
LOGIN_MUTATION,
VALIDATE_EMAIL,
GET_SECRET_BY_ACCOUNT,
SEND_EMAIL_MUTATION,
CHECK_EMAIL_VERIFIED
} from '../../gql'
Expand Down Expand Up @@ -105,20 +103,6 @@ const LoginModal = ({ isNavBar, isSideBar }) => {
setopenVerify(true)
}

const checkEmail = useQuery(VALIDATE_EMAIL, {
variables: {
email: user.email
},
skip: true
})

const getHash = useQuery(GET_SECRET_BY_ACCOUNT, {
variables: {
account: user.email
},
skip: true
})

const handleOpen = () => {
setOpen(!open)
setActiveStep(0)
Expand Down Expand Up @@ -169,12 +153,12 @@ const LoginModal = ({ isNavBar, isSideBar }) => {
}

useEffect(() => {
if(error){
if(error.graphQLErrors[0].message === 'Inactive account'){
if (error) {
if (error.graphQLErrors[0].message === 'Inactive account') {
handleOpen()
history.replace('/reopen-account/' + user.account)
}
else if(error.graphQLErrors[0].message === 'Invalid account or secret'){
else if (error.graphQLErrors[0].message === 'Invalid account or secret') {
setOpenSnackbar({
show: true,
message: error.message.replace('GraphQL error: ', ''),
Expand All @@ -185,7 +169,7 @@ const LoginModal = ({ isNavBar, isSideBar }) => {
account: user.account
}
})
}
}
}
}, [error])

Expand Down
3 changes: 1 addition & 2 deletions webapp/src/components/Notification/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
} from '../../gql'

import styles from './styles'
import { element } from 'prop-types'

const useStyles = makeStyles(styles)

Expand Down Expand Up @@ -69,7 +68,7 @@ const Notification = () => {
setNotificationStatus(true)
}

const { error: errorNotifications, loading: loadingNotifications, data: notification = {} }
const { loading: loadingNotifications, data: notification = {} }
= useSubscription(NOTIFICATION_SUBSCRIPTION, { variables: { account_to: account, limit: limit } })

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import PropTypes from 'prop-types'
import { makeStyles } from '@material-ui/styles'
import Typography from '@material-ui/core/Typography'
import Button from '@material-ui/core/Button'
import { useTranslation } from 'react-i18next'
import NewNotificationIcon from '@material-ui/icons/Brightness1';
import OldNotificationIcon from '@material-ui/icons/PanoramaFishEye';
import { useQuery, useMutation } from '@apollo/react-hooks'
import Grid from '@material-ui/core/Grid'
import { GET_ACCOUNT_NAME, EDIT_NOTIFICATION_STATE } from '../../gql'
Expand All @@ -25,10 +23,7 @@ const NotificationStructure = ({ id, title, description, state, dateAndTime }) =
skip: true
})

const [
editNotificationState,
{ error: errorEditResults, loading: editLoading, data: { update_notification: editNotificationStateResult } = {} }
] = useMutation(EDIT_NOTIFICATION_STATE)
const [editNotificationState, { }] = useMutation(EDIT_NOTIFICATION_STATE)

useEffect(() => {
const response = async () => {
Expand Down
86 changes: 43 additions & 43 deletions webapp/src/components/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import FormControlLabel from '@material-ui/core/FormControlLabel'
import LanguageSelector from '../LanguageSelector'

import {
PROFILE_QUERY,
CHANGE_PASSWORD,
PROFILE_QUERY,
CHANGE_PASSWORD,
GET_ACCOUNT_SIGNUP_METHOD,
CHANGE_EMAIL,
CHANGE_EMAIL,
UPDATE_EMAIL_SUBSCRIPTION_MUTATION,
CLOSE_ACCOUNT_MUTATION
} from '../../gql'
Expand Down Expand Up @@ -72,7 +72,7 @@ const Settings = ({ onCloseSetting }) => {

const [
updateEmailSubscription,
{ error: errorUpdateEmailSubscription, loading: updateEmailSubscriptionLoading, data: { update_user: updateEmailSubscriptionResult } = {} }
{ data: { update_user: updateEmailSubscriptionResult } = {} }
] = useMutation(UPDATE_EMAIL_SUBSCRIPTION_MUTATION)

const [
Expand Down Expand Up @@ -115,18 +115,18 @@ const Settings = ({ onCloseSetting }) => {

const handleSubmitChangePassword = async () => {
if (getAccountSignupMethodResult && getAccountSignupMethodResult.password_changable) {
changePassword({
variables: {
email: profile.email,
newPassword: user.newPassword,
currentPassword: user.currentPassword,
emailContent: {
subject: t('emailMessage.subjectChangePassword'),
title: t('emailMessage.titleChangePassword'),
message: t('emailMessage.messageChangePassword')
}
changePassword({
variables: {
email: profile.email,
newPassword: user.newPassword,
currentPassword: user.currentPassword,
emailContent: {
subject: t('emailMessage.subjectChangePassword'),
title: t('emailMessage.titleChangePassword'),
message: t('emailMessage.messageChangePassword')
}
})
}
})
} else setOpenSnackbar({
show: true,
message: t('setting.passwordNotChangeable'),
Expand All @@ -135,7 +135,7 @@ const Settings = ({ onCloseSetting }) => {
}

const handleSubmitChangeEmail = async () => {
if(user, profile){
if (user, profile) {
changeEmail({
variables: {
account: profile.account,
Expand All @@ -145,7 +145,7 @@ const Settings = ({ onCloseSetting }) => {
user.email = null
}
}

const handleChangeCheckBox = (event) => {
updateEmailSubscription({
variables: {
Expand All @@ -161,9 +161,9 @@ const Settings = ({ onCloseSetting }) => {
}

useEffect(() => {
loadProfile()
loadProfile()
}, [updateEmailSubscriptionResult])

useEffect(() => {
if (errorProfile)
setOpenSnackbar({
Expand All @@ -180,14 +180,14 @@ const Settings = ({ onCloseSetting }) => {
message: t('setting.emailError'),
severity: 'error'
})
if(responseChangeEmail)
setOpenSnackbar({
show: true,
message: t('setting.emailChanged'),
severity: 'success'
})
loadProfile()
}, [changeEmail,errorChangeEmail,responseChangeEmail])
if (responseChangeEmail)
setOpenSnackbar({
show: true,
message: t('setting.emailChanged'),
severity: 'success'
})
loadProfile()
}, [changeEmail, errorChangeEmail, responseChangeEmail])

useEffect(() => {
if (responseChangePassword) {
Expand Down Expand Up @@ -241,15 +241,15 @@ const Settings = ({ onCloseSetting }) => {
}, [profile])

useEffect(() => {
if(resultCloseAccount) {
if (resultCloseAccount) {
setOpen(false)
logout()
history.push('/')
}
}, [resultCloseAccount])

useEffect(() => {
if(errorCloseAccount) {
if (errorCloseAccount) {
setOpenSnackbar({
show: true,
message: t('setting.errorCloseAccount'),
Expand Down Expand Up @@ -289,7 +289,7 @@ const Settings = ({ onCloseSetting }) => {
BackdropProps={{
timeout: 500
}}
>
>
<Box className={classes.closeIcon}>
<IconButton
aria-label="close"
Expand All @@ -308,7 +308,7 @@ const Settings = ({ onCloseSetting }) => {
<DialogContent className={classes.dimensions} >
<form autoComplete="off">
<Grid container>
<Grid container spacing = {2}>
<Grid container spacing={2}>
<Grid item xs={6}>
<Box className={classes.boxSecondVersion}>
<Typography variant="h3" className={classes.text}>
Expand All @@ -319,7 +319,7 @@ const Settings = ({ onCloseSetting }) => {
<LanguageSelector alt="settings" />
</Box>
</Grid>
<Divider orientation="vertical" flexItem/>
<Divider orientation="vertical" flexItem />
<Grid item xs={5}>
<Box className={classes.boxSecondVersion}>
<Typography variant="h3" className={classes.text}>
Expand All @@ -328,13 +328,13 @@ const Settings = ({ onCloseSetting }) => {
</Box>
<Box className={classes.checkBox}>
<FormControlLabel
disabled= {loading}
checked = {profile ? profile.email_subscription : true}
disabled={loading}
checked={profile ? profile.email_subscription : true}
control={
<Checkbox
color="primary"
onChange={handleChangeCheckBox}
/>
<Checkbox
color="primary"
onChange={handleChangeCheckBox}
/>
}
label={t('setting.checkBoxSuscribe')}
labelPlacement="start"
Expand All @@ -344,7 +344,7 @@ const Settings = ({ onCloseSetting }) => {
</Grid>
<Grid container item xs={12}>
<Box className={classes.boxThirdVersion}>
<Divider className={classes.dividerSecondVersion}/>
<Divider className={classes.dividerSecondVersion} />
<Typography variant="h3" className={classes.text}>
{t('setting.changeEmail')}
</Typography>
Expand All @@ -357,7 +357,7 @@ const Settings = ({ onCloseSetting }) => {
endAdornment: (
<>
<InputLabel id="select-label">
{profile ? profile.email:''}
{profile ? profile.email : ''}
</InputLabel>
</>
)
Expand All @@ -374,7 +374,7 @@ const Settings = ({ onCloseSetting }) => {
</Grid>
<Box className={classes.box}>
<Button
disabled={(!validEmailFormat || !user.email) || loadingChangeEmail || loading}
disabled={(!validEmailFormat || !user.email) || loadingChangeEmail || loading}
variant="contained"
color="secondary"
onClick={handleSubmitChangeEmail}
Expand All @@ -390,7 +390,7 @@ const Settings = ({ onCloseSetting }) => {
</Grid>
<Grid container item xs={12}>
<Box className={classes.box}>
<Divider className={classes.dividerSecondVersion}/>
<Divider className={classes.dividerSecondVersion} />
<Typography variant="h3" className={classes.text}>
{t('setting.changePassword')}
</Typography>
Expand Down Expand Up @@ -478,7 +478,7 @@ const Settings = ({ onCloseSetting }) => {

<Grid container item xs={12}>
<Box className={classes.box}>
<Divider className={classes.dividerSecondVersion}/>
<Divider className={classes.dividerSecondVersion} />
<Typography variant="h3" className={classes.text}>
{t('setting.closeAccount')}
</Typography>
Expand Down
1 change: 0 additions & 1 deletion webapp/src/components/Signup/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const Signup = ({ isHome, isModal, isSideBar, onCloseSignUp }) => {

const handleCreateAccount = () => {
const { email, name, passwordPlainText } = user

createAccount({
variables: {
role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const SignupWithFacebook = ({ handlerSubmit }) => {
return (
<FacebookProvider appId={oAuthConfig.facebook_appID}>
<Login scope="email" onCompleted={facebookResponse} onError={handleError}>
{({ handleClick, error, data }) => (
{({ handleClick }) => (
<Button
onClick={handleClick}
className={classes.btnFacebook}
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/TransactionReport/TransactionReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TransactionReport = ({ dateFrom, dateTo, saveReport, onReportSaved }) => {

const [
loadProfile,
{ error: errroLoadProfile, data: { profile: { profile } = {} } = {}, client }
{ data: { profile: { profile } = {} } = {} }
] = useLazyQuery(PROFILE_QUERY, { fetchPolicy: 'network-only' })

const headSent = [
Expand All @@ -30,7 +30,7 @@ const TransactionReport = ({ dateFrom, dateTo, saveReport, onReportSaved }) => {

const [
getReportQuery,
{ errorReport, data: { get_report: getReportResult } = {} }
{ data: { get_report: getReportResult } = {} }
] = useLazyQuery(GET_REPORT_QUERY, { fetchPolicy: 'network-only' })

useEffect(() => {
Expand Down
Loading