Skip to content

Commit

Permalink
prettier /src
Browse files Browse the repository at this point in the history
  • Loading branch information
decimoseptimo committed Mar 25, 2021
1 parent 01cb539 commit d3d1fb5
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 71 deletions.
6 changes: 3 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {

const products = result.data.products.edges
const _categories = result.data.categories.edges
const categories = _categories.map(i => i.node)
const categories = _categories.map((i) => i.node)
const tags = result.data.tags.group

console.log("products:" + products.length)
Expand Down Expand Up @@ -88,7 +88,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
for (const i of categories) {
const allSupercategories = getParentRecursively(categories, i).reverse()
const allSubcategories = getChildrenRecursively(categories, i)
const allSubcategoriesIds = [i._id, ...allSubcategories.map(i => i._id)]
const allSubcategoriesIds = [i._id, ...allSubcategories.map((i) => i._id)]
const subcategories = getChildren(allSubcategories, i._id)

const result = await graphql(
Expand Down Expand Up @@ -128,7 +128,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
})
}

tags.forEach(tag => {
tags.forEach((tag) => {
paginate({
createPage,
items: tag.edges,
Expand Down
4 changes: 3 additions & 1 deletion src/components/baseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import PropTypes from "prop-types"

const BaseButton = (props) => (
<>
<button {...props} className={`baseButton ${props.className}`}>{props.children}</button>
<button {...props} className={`baseButton ${props.className}`}>
{props.children}
</button>
<style jsx>{`
.baseButton {
background: none;
Expand Down
4 changes: 2 additions & 2 deletions src/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const Button = (props) => {
background: linear-gradient(to bottom, #f9f9f9, #dfdfdf);
color: #333;
}
.default3 {
background: linear-gradient(to bottom,#f9f9f9,#f5f5f5);
background: linear-gradient(to bottom, #f9f9f9, #f5f5f5);
color: #333;
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/buttonCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import { FaShoppingCart } from "react-icons/fa"

import BaseButton from "./baseButton"

const ButtonCart = ({count, onClick}) => (
const ButtonCart = ({ count, onClick }) => (
<>
<BaseButton className="buttonCart" aria-label="cart button" onClick={onClick}>
<BaseButton
className="buttonCart"
aria-label="cart button"
onClick={onClick}
>
<>
<FaShoppingCart color="white" />
<span className="cart-count">{count}</span>
Expand Down
17 changes: 9 additions & 8 deletions src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import IconBars from "./iconBars"
import Search from "./search/search"
import * as Routes from "./sidepanel/routes"

const Header = ({
location,
setRoutes,
getFromRoutesHistory,
}) => {
const Header = ({ location, setRoutes, getFromRoutesHistory }) => {
const [state /* , dispatch */] = useContext(CartContext)
const [, /* miscState */ miscDispatch] = useContext(MiscContext)

Expand All @@ -26,7 +22,8 @@ const Header = ({
className="buttonCategories"
aria-label="categories button"
onClick={() =>
setRoutes( location,
setRoutes(
location,
getFromRoutesHistory(Routes.CATEGORIES) || [Routes.CATEGORIES]
)
}
Expand Down Expand Up @@ -61,7 +58,8 @@ const Header = ({
className="buttonUser"
aria-label="my-account button"
onClick={() =>
setRoutes( location,
setRoutes(
location,
getFromRoutesHistory(Routes.MY_ACCOUNT) || [Routes.MY_ACCOUNT]
)
}
Expand All @@ -71,7 +69,10 @@ const Header = ({
<ButtonCart
count={state.length}
onClick={() =>
setRoutes( location,getFromRoutesHistory(Routes.CART) || [Routes.CART])
setRoutes(
location,
getFromRoutesHistory(Routes.CART) || [Routes.CART]
)
}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/iconBars.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const IconBars = (props) => (
<style jsx>{`
.iconBars {
border: 1px solid #e0b324;
padding: .2rem .3rem;
padding: 0.2rem 0.3rem;
border-radius: 3px;
padding: 4px 4px 1px 4px;
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const InputNumber = ({
//TODO should validate 'value' prop?
const [numberValue, setNumberValue] = useState(value) //valid value as float number
const [stringValue, setStringValue] = useState(formatToString(value)) //input value as string

const setValues = (value, skipOnChange = false) => {
// console.log("setValues")
// console.log(value)
Expand Down
16 changes: 10 additions & 6 deletions src/components/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ ul {
padding: 0;
}

h1:first-child, h2:first-child, h3:first-child, h4:first-child, h5:first-child {
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child {
margin-top: 0;
}

a {
color: #4183c4;
text-decoration: none;
color: #4183c4;
text-decoration: none;
}

p {
/*margin: 0 0 1em;*/
line-height: 1.4285em;
}
/*margin: 0 0 1em;*/
line-height: 1.4285em;
}
8 changes: 6 additions & 2 deletions src/components/overlay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from "react"

const Overlay = ({_key, isActive = false, onClick }) => (
const Overlay = ({ _key, isActive = false, onClick }) => (
<>
<div key={_key} className={`overlay ${isActive && "visible"}`} onClick={onClick} />
<div
key={_key}
className={`overlay ${isActive && "visible"}`}
onClick={onClick}
/>
<style jsx>{`
.overlay {
position: fixed;
Expand Down
1 change: 0 additions & 1 deletion src/components/product/productCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ProductCard = ({
AddButton,
hasMountedAndHasValue,
}) => {

const image = data.images ? (
<Img fluid={data.images[0].childImageSharp.fluid} alt={data.title} />
) : (
Expand Down
6 changes: 3 additions & 3 deletions src/components/search/searchBox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import React from "react"
import Autosuggest from "react-autosuggest"

const SearchBox = props => {
const SearchBox = (props) => {
return (
<div className="searchBox">
<Autosuggest {...props} ref={props.inputEl} />
Expand Down Expand Up @@ -68,7 +68,7 @@ const SearchBox = props => {
color: rgba(0, 0, 0, 0.87);
line-height: 1.33;
}
.react-autosuggest__suggestion--highlighted {
background-color: #f3f4f5;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidepanel/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default} from "./sidepanel"
export { default } from "./sidepanel"
9 changes: 5 additions & 4 deletions src/components/sidepanel/panels/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ export default function Login(props) {
onSubmit={(data, setError) => {
const result = login(data)
if (!!result) navigate(myAccountUrl, { replace: true })
else setError("auth", {
type: "loginFailed",
message: "Nombre de usuario o contraseña invalidos"
});
else
setError("auth", {
type: "loginFailed",
message: "Nombre de usuario o contraseña invalidos",
})
}}
onSignup={() => navigate(signupUrl)}
onPasswordReset={() => navigate(passwordResetUrl)}
Expand Down
5 changes: 1 addition & 4 deletions src/components/sidepanel/panels/auth/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import React from "react"
import "../panel.css"

export default function Logout(props) {

return (
<>
<div className="panel">
Cerrando sesion...
</div>
<div className="panel">Cerrando sesion...</div>
</>
)
}
2 changes: 1 addition & 1 deletion src/components/sidepanel/panels/auth/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Signup(props) {
<>
<div className="panel">
<Form
onSubmit={() => alert('SERVICE UNAVAILABLE')}
onSubmit={() => alert("SERVICE UNAVAILABLE")}
onLogin={() => setRoutes(location, [MY_ACCOUNT, LOGIN])}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/sidepanel/panels/cart/cartItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ const CartItem = (props) => {
td {
padding-right: 1rem;
}
td.item-total {
text-align: right;
}
td:nth-child(3) {
display: none
display: none;
}
td:first-child,
Expand Down
3 changes: 2 additions & 1 deletion src/components/sidepanel/panels/cart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const Cart = (props) => {
const [state, dispatch] = useContext(CartContext)
const nextPrivateUrl = useGetRelativeUrl(CART, SHIPPING)
const loginUrl = useGetRelativeUrl(MY_ACCOUNT, LOGIN)
const onNextPrivateRoute = () => navigate(isLoggedIn() ? nextPrivateUrl: loginUrl)
const onNextPrivateRoute = () =>
navigate(isLoggedIn() ? nextPrivateUrl : loginUrl)

const cartTotal = () => {
let cartTotal = 0
Expand Down
13 changes: 5 additions & 8 deletions src/components/sidepanel/panels/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Categories = () => {
}
`)

const [/* miscState */, miscDispatch] = useContext(MiscContext)
const [, /* miscState */ miscDispatch] = useContext(MiscContext)
const propsCategories = data.allCategoriesJson.edges
const categories = propsCategories.map((i) => i.node)
const rootCategories = getChildren(categories, null)
Expand All @@ -37,14 +37,15 @@ const Categories = () => {

const { Panel } = Collapse

const expandIcon = (props) =>
const expandIcon = (props) => (
<IconContext.Provider
value={!props.isActive ? { style: { transform: "rotate(90deg)" } } : {}}
>
<AiOutlineRight />
</IconContext.Provider>
)

const ItemLink = ({ name, className='' }) => (
const ItemLink = ({ name, className = "" }) => (
<Link
to={`/${slugify(name.toLowerCase())}`}
replace
Expand Down Expand Up @@ -72,11 +73,7 @@ const Categories = () => {
return children ? (
getPanel(_id, name, children)
) : (
<ItemLink
key={_id}
name={name}
className="rc-collapse-item"
/>
<ItemLink key={_id} name={name} className="rc-collapse-item" />
)
})}
</Collapse>
Expand Down
28 changes: 14 additions & 14 deletions src/components/sidepanel/panels/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//categories
export {default as Categories} from "./categories"
export { default as Categories } from "./categories"

//cart
export {default as Cart} from "./cart"
export {default as Shipping} from "./cart/shipping"
export {default as Payment} from "./cart/payment"
export {default as Pay} from "./cart/pay"
export { default as Cart } from "./cart"
export { default as Shipping } from "./cart/shipping"
export { default as Payment } from "./cart/payment"
export { default as Pay } from "./cart/pay"

//myAccount
export {default as MyAccount} from "./myAccount"
export {default as Profile} from "./myAccount/profile"
export {default as Cards} from "./myAccount/cards"
export {default as Addresses} from "./myAccount/addresses"
export {default as Orders} from "./myAccount/orders"
export { default as MyAccount } from "./myAccount"
export { default as Profile } from "./myAccount/profile"
export { default as Cards } from "./myAccount/cards"
export { default as Addresses } from "./myAccount/addresses"
export { default as Orders } from "./myAccount/orders"

//misc
export {default as Login} from "./auth/login"
export {default as Logout} from "./auth/logout"
export {default as Signup} from "./auth/signup"
export {default as PasswordReset} from "./auth/passwordReset"
export { default as Login } from "./auth/login"
export { default as Logout } from "./auth/logout"
export { default as Signup } from "./auth/signup"
export { default as PasswordReset } from "./auth/passwordReset"
2 changes: 1 addition & 1 deletion src/components/sidepanel/panels/panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@

.sub.panel span {
margin-left: 1.6rem;
}
}
2 changes: 1 addition & 1 deletion src/data/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion src/templates/productIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Pagination from "../components/pagination"

const ProductIndex = (props) => {
const products = props.data.allProductsJson.edges

const handlePageChange = (current) => {
current === 1 ? navigate(`/`) : navigate(`/${current}`)
}
Expand Down
3 changes: 0 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



exports.round = (value, decimals = 2) => {
return Number(Math.round(value + "e" + decimals) + "e-" + decimals).toFixed(
decimals
Expand Down

0 comments on commit d3d1fb5

Please sign in to comment.