Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
gmoniava committed Jun 6, 2020
1 parent 6e3916c commit f1ea430
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 92 deletions.
5 changes: 1 addition & 4 deletions src/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ class Api {
maxPrice = 1000,
page = 1
}) {

// Turn this into a boolean
usePriceFilter = usePriceFilter === "true" && true;

return new Promise((resolve, reject) => {

return new Promise((resolve, reject) => {
setTimeout(() => {

let data = sampleProducts.filter(item => {
if (
usePriceFilter &&
Expand Down
28 changes: 14 additions & 14 deletions src/Components/Details/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConnectedDetails extends Component {
relatedItems: [],
quantity: 1,
item: null,
itemLoading: false,
itemLoading: false
};
}

Expand All @@ -28,16 +28,16 @@ class ConnectedDetails extends Component {
let item = await Api.getItemUsingID(productId);

let relatedItems = await Api.searchItems({
category: item.category,
category: item.category
});

// Make sure this component is still mounted before we set state..
if (this.isCompMounted) {
this.setState({
item,
quantity: 1,
relatedItems: relatedItems.data.filter((x) => x.id !== item.id),
itemLoading: false,
relatedItems: relatedItems.data.filter(x => x.id !== item.id),
itemLoading: false
});
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ class ConnectedDetails extends Component {
style={{
marginBottom: 20,
marginTop: 10,
fontSize: 22,
fontSize: 22
}}
>
{this.state.item.name}
Expand All @@ -87,20 +87,20 @@ class ConnectedDetails extends Component {
style={{
border: "1px solid lightgray",
borderRadius: "5px",
objectFit: "cover",
objectFit: "cover"
}}
/>
<div
style={{
flex: 1,
marginLeft: 20,
display: "flex",
flexDirection: "column",
flexDirection: "column"
}}
>
<div
style={{
fontSize: 16,
fontSize: 16
}}
>
Price: {this.state.item.price} $
Expand All @@ -117,7 +117,7 @@ class ConnectedDetails extends Component {
style={{ marginTop: 20, marginBottom: 10, width: 70 }}
label="Quantity"
inputProps={{ min: 1, max: 10, step: 1 }}
onChange={(e) => {
onChange={e => {
this.setState({ quantity: parseInt(e.target.value) });
}}
/>
Expand All @@ -129,7 +129,7 @@ class ConnectedDetails extends Component {
this.props.dispatch(
addItemInCart({
...this.state.item,
quantity: this.state.quantity,
quantity: this.state.quantity
})
);
}}
Expand All @@ -144,7 +144,7 @@ class ConnectedDetails extends Component {
style={{
marginTop: 20,
marginBottom: 20,
fontSize: 22,
fontSize: 22
}}
>
Product Description
Expand All @@ -153,7 +153,7 @@ class ConnectedDetails extends Component {
style={{
maxHeight: 200,
fontSize: 13,
overflow: "auto",
overflow: "auto"
}}
>
{this.state.item.description
Expand All @@ -166,12 +166,12 @@ class ConnectedDetails extends Component {
style={{
marginTop: 20,
marginBottom: 10,
fontSize: 22,
fontSize: 22
}}
>
Related Items
</div>
{this.state.relatedItems.slice(0, 3).map((x) => {
{this.state.relatedItems.slice(0, 3).map(x => {
return <Item key={x.id} item={x} />;
})}
</div>
Expand Down
37 changes: 14 additions & 23 deletions src/Components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import TextField from "@material-ui/core/TextField";
import Button from "@material-ui/core/Button";
import { withRouter } from "react-router-dom";
import { connect } from "react-redux";
import {
showCartDlg,
toggleMenu,
logout
} from "../../Redux/Actions";
import { showCartDlg, toggleMenu, logout } from "../../Redux/Actions";
import cartImage from "../../Images/logo2.png";
import Auth from "../../Auth";
import { categories } from "../../Data";
Expand Down Expand Up @@ -65,12 +61,7 @@ class ConnectedHeader extends Component {
<MenuIcon size="medium" />
</IconButton>

<img
src={cartImage}
alt={"Logo"}
style={{ marginLeft: 10 }}

/>
<img src={cartImage} alt={"Logo"} style={{ marginLeft: 10 }} />
<TextField
label="Search products"
value={this.state.searchTerm}
Expand Down Expand Up @@ -102,9 +93,9 @@ class ConnectedHeader extends Component {
onClick={() => {
this.props.history.push(
"/?category=" +
this.state.categoryFilterValue +
"&term=" +
this.state.searchTerm
this.state.categoryFilterValue +
"&term=" +
this.state.searchTerm
);
}}
>
Expand All @@ -125,15 +116,15 @@ class ConnectedHeader extends Component {
Log in
</Button>
) : (
<Avatar
onClick={event => {
this.setState({ anchorEl: event.currentTarget });
}}
style={{ backgroundColor: "#3f51b5", marginRight: 10 }}
>
<Person />
</Avatar>
)}
<Avatar
onClick={event => {
this.setState({ anchorEl: event.currentTarget });
}}
style={{ backgroundColor: "#3f51b5", marginRight: 10 }}
>
<Person />
</Avatar>
)}
<IconButton
aria-label="Cart"
onClick={() => {
Expand Down
24 changes: 11 additions & 13 deletions src/Components/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import Auth from "../../Auth";
import TextField from "@material-ui/core/TextField";
import Button from "@material-ui/core/Button";
import { setLoggedInUser } from "../../Redux/Actions";
import Avatar from '@material-ui/core/Avatar';
import LockOutlinedIcon from '@material-ui/icons/LockOutlined';

import Avatar from "@material-ui/core/Avatar";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined";

class ConnectedLogin extends Component {
state = {
Expand All @@ -24,13 +23,15 @@ class ConnectedLogin extends Component {
}

return (
<div style={{
height: "100%",
display: "flex",
justifyContent: "center",
<div
style={{
height: "100%",
display: "flex",
justifyContent: "center",

alignItems: "center",
}}>
alignItems: "center"
}}
>
<div
style={{
height: 300,
Expand All @@ -53,8 +54,7 @@ class ConnectedLogin extends Component {
}}
>
{" "}
Log in
{" "}
Log in{" "}
</div>
<TextField
value={this.state.userName}
Expand All @@ -76,10 +76,8 @@ class ConnectedLogin extends Component {
variant="outlined"
color="primary"
onClick={() => {

// Simulate authentication call
Auth.authenticate(this.state.userName, this.state.pass, user => {

if (!user) {
this.setState({ wrongCred: true });
return;
Expand Down
20 changes: 10 additions & 10 deletions src/Components/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import ListItemIcon from "@material-ui/core/ListItemIcon";
import ListItemText from "@material-ui/core/ListItemText";
import Collapse from "@material-ui/core/Collapse";

const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
showMenu: state.showMenu,
showMenu: state.showMenu
};
};

Expand All @@ -26,9 +26,9 @@ class ConnectedMenu extends Component {
this.state = {
// initially item with id 1 is expanded
expandedMenuItems: {
1: true,
1: true
},
dataForTheMenu,
dataForTheMenu
};

this.renderMenu = this.renderMenu.bind(this);
Expand Down Expand Up @@ -59,12 +59,12 @@ class ConnectedMenu extends Component {
}}
style={{
textDecoration: "none",
color: "rgb(32, 32, 34)",
color: "rgb(32, 32, 34)"
}}
key={x.id}
activeStyle={{
color: "#4282ad",
fontWeight: "bold",
fontWeight: "bold"
}}
>
<ListItem dense button>
Expand All @@ -86,12 +86,12 @@ class ConnectedMenu extends Component {
dense
onClick={() => {
// Update in state which menu items are expanded.
this.setState((ps) => {
this.setState(ps => {
return {
expandedMenuItems: {
...ps.expandedMenuItems,
[x.id]: !ps.expandedMenuItems[x.id],
},
[x.id]: !ps.expandedMenuItems[x.id]
}
};
});
}}
Expand Down Expand Up @@ -124,7 +124,7 @@ class ConnectedMenu extends Component {
<div
style={{
backgroundColor: "#FAFAFB",
minWidth: 250,
minWidth: 250
}}
>
{/* Render our menu */}
Expand Down
4 changes: 1 addition & 3 deletions src/Components/Order/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class ConnectedOrder extends Component {

return (
<div style={{ padding: 10 }}>
<div style={{ fontSize: 24, marginTop: 10 }}>
Order summary
</div>
<div style={{ fontSize: 24, marginTop: 10 }}>Order summary</div>
<Table>
<TableHead>
<TableRow>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Paging/Paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import IconButton from "@material-ui/core/IconButton";
import Typography from "@material-ui/core/Typography";
import { withRouter } from "react-router-dom";

const Paging = (props) => {
const Paging = props => {
let { parsedQueryStr } = props;
let itemsPerPage = parseInt(parsedQueryStr.itemsPerPage) || 10;
let page = parseInt(parsedQueryStr.page) || 1;
Expand All @@ -20,7 +20,7 @@ const Paging = (props) => {
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
alignItems: "center"
}}
>
<IconButton
Expand Down
Loading

0 comments on commit f1ea430

Please sign in to comment.