Skip to content

Commit

Permalink
Run prettier over codebase (#236)
Browse files Browse the repository at this point in the history
* 🎨 run prettier over all files under src

* ⏪ undo package.lock changes
  • Loading branch information
munroTom authored Mar 11, 2020
1 parent a10c3a7 commit bf37193
Show file tree
Hide file tree
Showing 34 changed files with 1,563 additions and 1,136 deletions.
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,11 @@ class App extends Component {
/>
</Switch>

{ !this.state.welcomeShown &&
{!this.state.welcomeShown &&
config.PAGES.embeddable.path &&
!this.props.history.location.pathname.includes(config.PAGES.embeddable.path) && (
<WelcomePage handleClose={this.handleWelcomePageClose} />
)}
!this.props.history.location.pathname.includes(
config.PAGES.embeddable.path
) && <WelcomePage handleClose={this.handleWelcomePageClose} />}

<Map
history={this.props.history}
Expand Down
74 changes: 49 additions & 25 deletions src/authFirebase.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import firebase from "firebase/app";
import md5 from 'md5';
import md5 from "md5";

import User from "./types/User";
import dbFirebase from "./dbFirebase";
import { gtagEvent,gtagSetId } from './gtag.js';
import config from './custom/config'
import { gtagEvent, gtagSetId } from "./gtag.js";
import config from "./custom/config";

/**
* When the user login call fn
Expand All @@ -13,36 +13,51 @@ import config from './custom/config'

let currentUser;

const onAuthStateChanged = (fn) => {
const firebaseStatusChange = (user) => {
const onAuthStateChanged = fn => {
const firebaseStatusChange = user => {
currentUser = user;
if (config.ENABLE_GRAVATAR_PROFILES && currentUser) {
gtagSetId(user.uid)
gtagEvent('Logged in','User',user.uid)
gtagSetId(user.uid);
gtagEvent("Logged in", "User", user.uid);

const gravatarURL = "https://www.gravatar.com/" + md5(user.email) + ".json";
const photoURL = user.photoURL || "https://www.gravatar.com/avatar/" + md5(user.email);
currentUser = new User(user.uid, user.displayName, false, user.email, user.emailVerified, user.isAnonymous, user.phoneNumber, photoURL, null, null, null);
const gravatarURL =
"https://www.gravatar.com/" + md5(user.email) + ".json";
const photoURL =
user.photoURL || "https://www.gravatar.com/avatar/" + md5(user.email);
currentUser = new User(
user.uid,
user.displayName,
false,
user.email,
user.emailVerified,
user.isAnonymous,
user.phoneNumber,
photoURL,
null,
null,
null
);

// this has to be global to be found by the jsonp
window.userFromGravatar = (profile) => {
window.userFromGravatar = profile => {
const info = profile.entry[0];
currentUser.description = info.aboutMe;
currentUser.location = info.currentLocation;
currentUser.profileURL = info.profileUrl;
currentUser.displayName = info.name ? info.name.formatted : currentUser.displayName;
currentUser.displayName = info.name
? info.name.formatted
: currentUser.displayName;
};

// add a script node to the dom. The browser will run it but we don't know when.
const script= document.createElement('script');
script.src=`${gravatarURL}?callback=userFromGravatar`;
const script = document.createElement("script");
script.src = `${gravatarURL}?callback=userFromGravatar`;
document.head.append(script);

dbFirebase.getUser(user.uid)
.then(fbUser => {
currentUser.isModerator = fbUser ? fbUser.isModerator : false;
fn(currentUser);
})
dbFirebase.getUser(user.uid).then(fbUser => {
currentUser.isModerator = fbUser ? fbUser.isModerator : false;
fn(currentUser);
});
}
fn(currentUser);
};
Expand All @@ -54,17 +69,21 @@ const signOut = () => {
};

const sendEmailVerification = () => {
return firebase.auth().currentUser.sendEmailVerification()
return firebase
.auth()
.currentUser.sendEmailVerification()
.then(() => {
const message = {
title: 'Notification',
body: 'A verification link has been sent to email account: ' + firebase.auth().currentUser.email
title: "Notification",
body:
"A verification link has been sent to email account: " +
firebase.auth().currentUser.email
};
return message;
})
.catch( error => {
.catch(error => {
const message = {
title: 'Warning',
title: "Warning",
body: error.message
};
return message;
Expand All @@ -76,4 +95,9 @@ const reloadUser = async () => {
return firebase.auth().currentUser;
};

export default { onAuthStateChanged, signOut, sendEmailVerification, reloadUser }
export default {
onAuthStateChanged,
signOut,
sendEmailVerification,
reloadUser
};
10 changes: 5 additions & 5 deletions src/components/AboutPage.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import React from "react";
import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
import CachedIcon from "@material-ui/icons/Cached";
import { withStyles } from '@material-ui/core/styles';
import { withStyles } from "@material-ui/core/styles";

import PageWrapper from "./PageWrapper";
import utils from "../utils";

const styles = theme => ({
typography : {
typography: {
...theme.mixins.gutters(),
whiteSpace: 'pre-wrap',
whiteSpace: "pre-wrap"
}
});

Expand Down
101 changes: 58 additions & 43 deletions src/components/CardComponent.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,96 @@
import React from 'react';
import React from "react";

import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import IconButton from '@material-ui/core/IconButton';
import ThumbUpIcon from '@material-ui/icons/ThumbUp';
import ThumbDownIcon from '@material-ui/icons/ThumbDown';
import { withStyles } from '@material-ui/core/styles';
import config from '.././custom/config';
import Card from "@material-ui/core/Card";
import CardActionArea from "@material-ui/core/CardActionArea";
import CardActions from "@material-ui/core/CardActions";
import CardContent from "@material-ui/core/CardContent";
import IconButton from "@material-ui/core/IconButton";
import ThumbUpIcon from "@material-ui/icons/ThumbUp";
import ThumbDownIcon from "@material-ui/icons/ThumbDown";
import { withStyles } from "@material-ui/core/styles";
import config from ".././custom/config";

const styles = theme => ({
card : {
width:'100%'
card: {
width: "100%"
}
});

class CardComponent extends React.Component {


presentField = (fieldName, fieldValue) => {
let rtn;
const field = config['PHOTO_FIELDS'][fieldName];
if(field && field.nakedComponent) {
rtn = field.nakedComponent.toFormattedString(fieldValue,field.data);
}
else {
const field = config["PHOTO_FIELDS"][fieldName];
if (field && field.nakedComponent) {
rtn = field.nakedComponent.toFormattedString(fieldValue, field.data);
} else {
switch (fieldName) {
case 'location':
case "location":
const link = `https://www.google.com/maps/@${fieldValue.latitude},${fieldValue.longitude},18z`;
rtn = (<a href={link} target="_">See Google Map</a>);
rtn = (
<a href={link} target="_">
See Google Map
</a>
);
break;
case 'moderated':
case "moderated":
rtn = new Date(fieldValue).toDateString();
break;
case 'updated':
case "updated":
rtn = new Date(fieldValue).toDateString();
break;
case 'thumbnail':
case 'main':
rtn = (<a href={fieldValue} target="_">See photo</a>);
case "thumbnail":
case "main":
rtn = (
<a href={fieldValue} target="_">
See photo
</a>
);
break;
default:
rtn = String(fieldValue);
}
}
return rtn;
}
};

render() {
const { photoSelected, handleRejectClick, handleApproveClick, classes } = this.props;
const {
photoSelected,
handleRejectClick,
handleApproveClick,
classes
} = this.props;
return (
<Card className={classes.card}>
<CardActionArea>
<CardContent>
{Object.keys(photoSelected).map(key => (
<div key={key}>
{key}: <strong> {this.presentField(key,photoSelected[key])}</strong>
{key}:{" "}
<strong> {this.presentField(key, photoSelected[key])}</strong>
</div>
))}
</CardContent>
</CardActionArea>
<CardActions>
{ handleRejectClick &&
<IconButton aria-label='Reject'
disabled={photoSelected.published === false}
onClick={() => handleRejectClick(photoSelected)}>
<ThumbDownIcon />
</IconButton>
}
{ handleApproveClick &&
<IconButton aria-label='Approve'
disabled={!!photoSelected.published}
onClick={() => handleApproveClick(photoSelected)}>
<ThumbUpIcon />
</IconButton>
}
{handleRejectClick && (
<IconButton
aria-label="Reject"
disabled={photoSelected.published === false}
onClick={() => handleRejectClick(photoSelected)}
>
<ThumbDownIcon />
</IconButton>
)}
{handleApproveClick && (
<IconButton
aria-label="Approve"
disabled={!!photoSelected.published}
onClick={() => handleApproveClick(photoSelected)}
>
<ThumbUpIcon />
</IconButton>
)}
</CardActions>
</Card>
);
Expand Down
40 changes: 21 additions & 19 deletions src/components/CustomPhotoDialog.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// Custom Dialog to choose camera and photo library to interact with cordova-plugin-camera

import React from 'react';
import PropTypes from 'prop-types';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import IconButton from '@material-ui/core/IconButton';
import ListItemText from '@material-ui/core/ListItemText';
import Dialog from '@material-ui/core/Dialog';
import CameraIcon from '@material-ui/icons/PhotoCamera';
import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary';
import CancelIcon from '@material-ui/icons/Close';
import React from "react";
import PropTypes from "prop-types";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import IconButton from "@material-ui/core/IconButton";
import ListItemText from "@material-ui/core/ListItemText";
import Dialog from "@material-ui/core/Dialog";
import CameraIcon from "@material-ui/icons/PhotoCamera";
import PhotoLibraryIcon from "@material-ui/icons/PhotoLibrary";
import CancelIcon from "@material-ui/icons/Close";

class CustomPhotoDialog extends React.Component {

handleClose = () => {
this.props.onClose();
};
Expand All @@ -27,23 +26,26 @@ class CustomPhotoDialog extends React.Component {
return (
<Dialog onClose={this.handleClose} open={open}>
<List>
<ListItem button onClick={() => this.handleListItemClick('CAMERA')}>
<IconButton color='primary' edge={false}>
<ListItem button onClick={() => this.handleListItemClick("CAMERA")}>
<IconButton color="primary" edge={false}>
<CameraIcon />
</IconButton>
<ListItemText primary={'Camera'} />
<ListItemText primary={"Camera"} />
</ListItem>
<ListItem button onClick={() => this.handleListItemClick('PHOTOLIBRARY')}>
<IconButton color='primary' edge={false}>
<PhotoLibraryIcon />
<ListItem
button
onClick={() => this.handleListItemClick("PHOTOLIBRARY")}
>
<IconButton color="primary" edge={false}>
<PhotoLibraryIcon />
</IconButton>
<ListItemText primary={'Photo Library'} />
<ListItemText primary={"Photo Library"} />
</ListItem>
<ListItem button onClick={this.handleClose}>
<IconButton edge={false}>
<CancelIcon />
</IconButton>
<ListItemText primary='Cancel' />
<ListItemText primary="Cancel" />
</ListItem>
</List>
</Dialog>
Expand Down
Loading

0 comments on commit bf37193

Please sign in to comment.