diff --git a/client/src/utils/graphql-errors.js b/client/src/utils/graphql-errors.js index 26b9c18ce..6eed0e939 100644 --- a/client/src/utils/graphql-errors.js +++ b/client/src/utils/graphql-errors.js @@ -3,10 +3,10 @@ const ErrorResponse = { } export const checkGraphQLError = error => { - console.log('checkGraphQLError ', ErrorResponse) + log.debug('checkGraphQLError ', ErrorResponse) if (error.search(/unique constraint/)) { const field = error.substring(error.indexOf('=') + 1) - console.log('unique constraint', field.replace(/ +/g, '')) + log.debug('unique constraint', field.replace(/ +/g, '')) } } diff --git a/client/src/utils/log.js b/client/src/utils/log.js new file mode 100644 index 000000000..47e819934 --- /dev/null +++ b/client/src/utils/log.js @@ -0,0 +1,7 @@ +import minilog from 'minilog' + +if (process.env.NODE_ENV === 'development') minilog.enable() + +const log = minilog('frontend') + +export default log diff --git a/client/src/views/common/components/TeamBar.js b/client/src/views/common/components/TeamBar.js index b51f22e13..67f5ef075 100644 --- a/client/src/views/common/components/TeamBar.js +++ b/client/src/views/common/components/TeamBar.js @@ -16,6 +16,8 @@ import SettingsApplicationsIcon from '@material-ui/icons/SettingsApplications' import { Link } from 'react-router-dom' +import log from '../../../utils/log' + const SettingsLink = props => const FBLink = props => const MembersLink = props => @@ -61,7 +63,7 @@ const styles = theme => ({ class TeamBar extends Component { render () { const { classes, user, match } = this.props - console.log('TeamBar: ', user, match) + log.debug('TeamBar: ', user, match) return (
diff --git a/client/src/views/dashboard/components/CreateTeam.js b/client/src/views/dashboard/components/CreateTeam.js index 1dfb75850..5e655ccf1 100644 --- a/client/src/views/dashboard/components/CreateTeam.js +++ b/client/src/views/dashboard/components/CreateTeam.js @@ -10,9 +10,11 @@ import { checkGraphQLError } from '../../../utils/graphql-errors' import CREATE_TEAM from '../../../graphql/teams/CreateTeamMutation' import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery' +import log from '../../../utils/log' + const CreateTeam = ({ authId }) => { let input - console.log('CreateTeam', authId) + log.debug('CreateTeam', authId) return ( { if (error) { errors = error.graphQLErrors.map(({ message }, i) => { const displayMessage = checkGraphQLError(message) - console.log('createTeam error:', displayMessage) + log.debug('createTeam error:', displayMessage) return ( {message} @@ -73,7 +75,7 @@ const handleSubmit = async (e, createTeam, input) => { const currentUser = await getItem('user') let authId = JSON.parse(currentUser) authId = authId.authId - console.log('createTeam submit: ', authId) + log.debug('createTeam submit: ', authId) const name = input.value const slug = slugify(name) await createTeam({ variables: { name, slug, owner: authId } }) diff --git a/client/src/views/dashboard/components/CreateTeamDialog.js b/client/src/views/dashboard/components/CreateTeamDialog.js index 6da04291b..6c9ce0113 100644 --- a/client/src/views/dashboard/components/CreateTeamDialog.js +++ b/client/src/views/dashboard/components/CreateTeamDialog.js @@ -18,7 +18,7 @@ import { isEmpty } from '../../../utils/js-helpers' import CREATE_TEAM from '../../../graphql/teams/CreateTeamMutation' import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery' -// import { checkGraphQLError } from '../../../utils/graphql-errors' +import log from '../../../utils/log' const styles = theme => ({ dialogContainer: { @@ -207,7 +207,7 @@ export class CreateTeamDialog extends Component { async handleSubmit (e, createTeam, name, botName) { e.preventDefault() - console.log('createTeam submit: ', name, botName) + log.debug('createTeam submit: ', name, botName) const slug = this.slugify(name) const botSlug = this.slugify(botName) await createTeam({ variables: { name, slug, botName, botSlug } }) diff --git a/client/src/views/dashboard/components/CreateTeamForm.js b/client/src/views/dashboard/components/CreateTeamForm.js index 75df97b5d..ebdbaf358 100644 --- a/client/src/views/dashboard/components/CreateTeamForm.js +++ b/client/src/views/dashboard/components/CreateTeamForm.js @@ -11,6 +11,8 @@ import DialogContentText from '@material-ui/core/DialogContentText' import DialogTitle from '@material-ui/core/DialogTitle' import Typography from '@material-ui/core/Typography' +import log from '../../../utils/log' + export class CreateTeamDialog extends Component { constructor (props) { super(props) @@ -50,7 +52,7 @@ export class CreateTeamDialog extends Component { } render () { - console.log(this.props) + log.debug(this.props) return (