Skip to content

Commit 72b0886

Browse files
Fix styling issues for safari browser
1 parent 61e9b84 commit 72b0886

File tree

14 files changed

+106
-77
lines changed

14 files changed

+106
-77
lines changed

client/src/components/routes/checkout/shippingAddress.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import {stateCodes} from "../../../constants/stateCodes";
99
import {setShippingAddress} from "../../../actions"
1010
import {ModalConfirmation} from "../../ui/modalConfirmation";
1111
import {SummaryCard} from "./summaryCard";
12-
import {textFieldStyles} from "../../../styles/js/formStyles";
1312
import {checkoutFormStyles} from "../../../styles/materialUI/checkoutFormStyles";
1413

14+
export const textFieldStyles = {
15+
width: "inherit",
16+
height: "fit-content",
17+
margin: "20px 0 0 20px",
18+
}
19+
1520
const renderTextField = (
1621
{placeholder, shrink, selectField, input, label, meta: { touched, error }, ...custom },
1722
) => {

client/src/components/routes/detail/productDetails.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Button, Grid, Box} from "@material-ui/core";
33
import log from 'loglevel';
44
import BreadcrumbsSection from "../../ui/breadcrumbs";
55
import history from "../../../history";
6-
import {SearchMatchesNotFound} from "../../ui/error/searchMatchesNotFound";
76
import {useDispatch, useSelector} from "react-redux";
87
import {connect} from 'react-redux';
98
import {getDataViaAPI} from '../../../actions'
@@ -39,23 +38,33 @@ function ProductDetails(props) {
3938
const addToCart = useSelector(state => state.addToCartReducer)
4039
const [productQuantity, setProductQuantity] = useState(1)
4140

41+
/**
42+
* Update the Component when product is already selected.
43+
* Cart products are stored in Cookie and we will set the product
44+
* for the first time the page is rendered.
45+
*/
4246
useEffect(() => {
4347
log.info(`[Product Detail] Component did mount selectProductDetail = ${JSON.stringify(selectProductDetail)}`)
4448
log.info(`[Product Detail] Component did mount selectedProduct = ${JSON.stringify(selectedProduct)}`)
4549

50+
// check if have anything in the cart
4651
if (selectedProduct && !_.isEmpty(addToCart.productQty)) {
4752
log.info(`[Product Detail] addToCart = ${JSON.stringify(addToCart)}`)
4853
log.info(`[Product Detail] setProductQuantity = ${addToCart.productQty[selectedProduct.id]}`)
4954
setProductQuantity(addToCart.productQty[selectedProduct.id])
5055
}
56+
57+
// eslint-disable-next-line
5158
}, [selectedProduct])
5259

60+
// if the user change the URL format then just return bad request.
5361
if (history.location.pathname.localeCompare('/products/details') !== 0 ||
5462
history.location.search.search('product_id=') === -1
5563
|| !history.location.search.startsWith('?q=')) {
5664
return <BadRequest/>
5765
}
5866

67+
// find the breadcrumb from the url
5968
const getStringBeforeLastDelimiter = (str, delimiter) => {
6069
return str.substring(0, str.lastIndexOf(delimiter))
6170
}
@@ -80,11 +89,15 @@ function ProductDetails(props) {
8089

8190
if (!selectedProduct) {
8291
try {
92+
93+
// if status code is set then its because of error.
8394
log.info(`[Product Detail] selectProductDetail = ${JSON.stringify(selectProductDetail)}`)
8495
if (selectProductDetail.hasOwnProperty("statusCode")) {
8596
log.info(`[Product Detail] Internal Server Error`)
8697
return <InternalServerError/>
8798
}
99+
100+
// get the product details from server
88101
const extractedProductId = history.location.search.split("product_id=")
89102
log.info(`[Product Detail] extractedProductId = ${JSON.stringify(extractedProductId)}, length = ${extractedProductId.length}`)
90103
if (extractedProductId.length === 2) {
@@ -104,6 +117,7 @@ function ProductDetails(props) {
104117
}
105118
}
106119

120+
// set the cart products in the cookie
107121
const dispatchAddToCart = newAddToCart => {
108122
Cookies.set(SHOPPERS_PRODUCT_INFO_COOKIE, newAddToCart, {expires: 7});
109123
log.info(`[Product Detail] dispatchAddToCart productQty = ${JSON.stringify(newAddToCart)}`)
@@ -117,6 +131,7 @@ function ProductDetails(props) {
117131
log.info(`[Product Detail] Product is added to cart`)
118132
let newAddToCart = addToCart
119133

134+
// add new product to cart
120135
if (newAddToCart.hasOwnProperty("productQty") === false) {
121136
newAddToCart = {
122137
totalQuantity: productQuantity,
@@ -137,6 +152,9 @@ function ProductDetails(props) {
137152
dispatchAddToCart(newAddToCart)
138153
}
139154

155+
/**
156+
* Navigate to shopping bag page.
157+
*/
140158
const handleProceedToBagBtnClick = () => {
141159
history.push(`${history.location.pathname}/shopping-bag${history.location.search}`)
142160
}

client/src/components/routes/navbar/navBar.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ import useNavBarStyles from "../../../styles/materialUI/navBarStyles";
2020
import TabList from "./tabList";
2121
import {Link} from "react-router-dom";
2222
import {useSelector} from "react-redux";
23-
import {ADD_TO_CART, CART_TOTAL, LOAD_TABS_DATA} from "../../../actions/types";
23+
import {ADD_TO_CART, LOAD_TABS_DATA} from "../../../actions/types";
2424
import log from "loglevel";
2525
import Hidden from "@material-ui/core/Hidden";
2626
import BagButton from "./bagButton";
27-
import {
28-
cartTotalReducer,
29-
shoppingBagProductReducer,
30-
tabsDataReducer
31-
} from "../../../reducers/screens/commonScreenReducer";
27+
import {tabsDataReducer} from "../../../reducers/screens/commonScreenReducer";
3228
import Spinner from "../../ui/spinner";
3329
import {HTTPError} from "../../ui/error/httpError";
3430
import {BadRequest} from "../../ui/error/badRequest";
@@ -51,6 +47,9 @@ const NavBar = props => {
5147
const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);
5248
const dispatch = useDispatch()
5349

50+
/**
51+
* set the cart from saved Cookie
52+
*/
5453
const setAddToCartValuesFromCookie = () => {
5554
let savedProductsFromCookie = Cookies.get(SHOPPERS_PRODUCT_INFO_COOKIE)
5655
let totalQuantity = 0
@@ -71,8 +70,14 @@ const NavBar = props => {
7170
}
7271
}
7372

73+
/**
74+
* This will execute only once.
75+
*/
7476
useEffect(() => {
7577
log.info(`[NavBar]: Component did update.`)
78+
79+
// if user is not signed in then signed it in using
80+
// account details from the cookie.
7681
if (isSignedIn === null) {
7782
log.info(`[NavBar]: isSignedIn is null`)
7883
let tokenIdFromCookie = Cookies.get(TOKEN_ID_COOKIE)
@@ -81,10 +86,13 @@ const NavBar = props => {
8186
props.setTokenFromCookie(tokenIdFromCookie)
8287
}
8388
}
89+
90+
// tabs data is not loaded then load it.
8491
if(!tabsAPIData.hasOwnProperty("data")) {
8592
props.getDataViaAPI(LOAD_TABS_DATA, TABS_DATA_API)
8693
}
8794

95+
// set the cart values
8896
setAddToCartValuesFromCookie()
8997

9098
// eslint-disable-next-line
@@ -271,7 +279,7 @@ const NavBar = props => {
271279
<Hidden xsDown>
272280
<Box display="flex" justifyContent="center" alignItems="center" css={{width: 90}}>
273281
<Box width="50%" onClick={handleProfileMenuOpen} css={{cursor: 'pointer'}}>
274-
<Box pl={1}>
282+
<Box pl={1} pt={0.3}>
275283
<AccountCircle/>
276284
</Box>
277285
<Box style={{color: "black", fontSize: "0.8rem", fontWeight: 'bold'}}>

client/src/components/routes/navbar/tabList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default function TabList() {
1515
const handleMouseEnter = (event) => {
1616
log.debug(`[TabList]: dispatching HANDLE_TAB_HOVER_EVENT with
1717
index = ${parseInt(event.target.id.split('-')[2])} and hover = true`)
18+
19+
// check if index is number
1820
let index = parseInt(event.target.id.split('-')[2])
1921
if (isNaN(index)) {
2022
return

client/src/components/routes/product/filterSideNavbar/apparelCheckBox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {useDispatch, useSelector} from "react-redux";
55
import {ADD_SELECTED_CATEGORY} from "../../../../actions/types";
66
import CheckboxMoreButton from "./checkboxMoreButton";
77
import CheckboxSearchBar from "./checkboxSearchBar";
8+
import {Grid} from "@material-ui/core";
89

910
export default function ApparelCheckBox() {
1011
const TITLE = "Apparel"

client/src/components/routes/product/filterSideNavbar/brandCheckBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import CheckboxSearchBar from "./checkboxSearchBar";
88

99
export default function BrandCheckBox() {
1010
const TITLE = "Brand"
11-
const propName="brands"
11+
const propName = "brands"
1212
const dispatch = useDispatch()
1313
const brandList = useSelector(state => state.filterAttributesReducer ?
1414
state.filterAttributesReducer.brands : null)

client/src/components/routes/product/filterSideNavbar/checkboxMoreButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default function CheckboxMoreButton(props) {
8080
const renderMoreButton = () => {
8181
if (props.checkboxList.length > 6) {
8282
return (
83-
<Box pl={1.5} pb={1}>
83+
<Box pl={1.5}>
8484
<Button color="secondary" onClick={handleMoreButton}>
8585
{`+ ${props.checkboxList.length - 6} more`}
8686
</Button>

client/src/components/routes/product/filterSideNavbar/checkboxSearchBar.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import log from 'loglevel';
33
import {NavBarHeader} from "../../../ui/headers";
4-
import {Box} from "@material-ui/core";
4+
import {Box, Grid} from "@material-ui/core";
55
import CollapsableSearch from "../../../ui/collapsableSearch";
66

77
export default function CheckboxSearchBar(props) {
@@ -24,17 +24,15 @@ export default function CheckboxSearchBar(props) {
2424
log.info(`[CheckboxSearchBar] Rendering CheckboxSearchBar Component`)
2525

2626
return (
27-
<Box display="flex" alignItems="center" pt={2}>
28-
<Box width="50%">
27+
<Grid container alignItems="center" style={{padding: "1rem 0", height: "fit-content"}}>
28+
<Grid item style={{paddingLeft: "0.1rem"}}>
2929
<NavBarHeader title={props.title}/>
30-
</Box>
31-
<Box width="50%">
32-
<CollapsableSearch
33-
handleOnSearchChange={handleSearchBarChange}
34-
handleCancelButton={handleSearchBarCancel}
35-
placeholder={props.placeholderText}
36-
/>
37-
</Box>
38-
</Box>
30+
</Grid>
31+
<CollapsableSearch
32+
handleOnSearchChange={handleSearchBarChange}
33+
handleCancelButton={handleSearchBarCancel}
34+
placeholder={props.placeholderText}
35+
/>
36+
</Grid>
3937
);
4038
}

client/src/components/routes/product/filterSideNavbar/filterNavBar.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import PriceCheckBox from "./priceCheckBox";
1111
import ClearAllButton from "./clearAllButton";
1212
import {connect, useDispatch, useSelector} from "react-redux";
1313
import {loadFilterAttributes} from "../../../../actions";
14-
import {Box} from "@material-ui/core";
14+
import {Box, Grid} from "@material-ui/core";
1515
import {useFilterNavBarStyles} from "../../../../styles/materialUI/filterNavBarStyles";
1616
import {
1717
FILTER_ATTRIBUTES, INITIAL_PAGINATION_STATE,
@@ -344,26 +344,34 @@ function FilterNavBar(props) {
344344
const renderDrawerComponents = (component) => {
345345
return (
346346
<>
347-
<Box display="flex" flexDirection="column" px={1} pl={3}>
348-
<Box>
349-
{component}
350-
</Box>
351-
</Box>
352-
<Divider/>
347+
<Grid container direction="column" style={{paddingLeft: "1.5rem"}}>
348+
{component}
349+
</Grid>
350+
351+
<div style={{paddingTop: "0.5rem"}}>
352+
<Divider/>
353+
</div>
353354
</>
354355
)
355356
}
356357

357358
const drawer = (
358359
<>
359-
<Box display="flex" p={2} style={{
360+
<Grid container alignItems="center" style={{
360361
position: 'sticky', top: 0, backgroundColor: 'white',
361-
fontWeight: "bold", fontSize: "1.2rem", zIndex: 1040
362+
fontWeight: "bold", fontSize: "1.2rem", zIndex: 1040,
363+
paddingTop: "1rem"
362364
}}>
363-
<Box alignSelf="center" flex="1">FILTERS</Box>
364-
<Box alignSelf="center"><ClearAllButton/></Box>
365-
</Box>
366-
<Divider/>
365+
<Grid item sm={6} style={{paddingLeft: "1.5rem"}}>
366+
FILTERS
367+
</Grid>
368+
<Grid item sm={6} style={{paddingLeft: "3rem"}}>
369+
<ClearAllButton/>
370+
</Grid>
371+
<Grid item style={{height: "1px", width: "100%", paddingTop: "1rem"}}>
372+
<Divider/>
373+
</Grid>
374+
</Grid>
367375

368376
{renderDrawerComponents(<GenderRadioButton/>)}
369377
{renderDrawerComponents(<ApparelCheckBox/>)}

client/src/components/routes/product/filterSideNavbar/genderRadioButton.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import log from 'loglevel';
33
import RadioButtonsGroup from "../../../ui/radioButtonGroup";
44
import {useDispatch, useSelector} from "react-redux";
55
import {ADD_SELECTED_CATEGORY} from "../../../../actions/types";
6-
import {Box} from "@material-ui/core";
6+
import {Box, Grid} from "@material-ui/core";
77
import {NavBarHeader} from "../../../ui/headers";
88

99
export default function GenderRadioButton() {
@@ -45,14 +45,16 @@ export default function GenderRadioButton() {
4545
log.info(`[GenderRadioButton] Rendering FilterRadioButtonSection Component = ${JSON.stringify(gender[0])}`)
4646

4747
return (
48-
<Box pb={1}>
49-
<Box pt={2.5} pb={1}>
48+
<>
49+
<Grid item style={{padding: "1rem 0"}}>
5050
<NavBarHeader title="Gender"/>
51-
</Box>
52-
<RadioButtonsGroup onChangeHandler={handleRadioButtonChange}
53-
attrList={genderList.filter(obj => obj.id < 5)}
54-
selectedValue={gender.length > 0 ? gender[0].value : false}
55-
title="Gender"/>
56-
</Box>
51+
</Grid>
52+
<Grid item style={{marginLeft: "0.5rem"}}>
53+
<RadioButtonsGroup onChangeHandler={handleRadioButtonChange}
54+
attrList={genderList.filter(obj => obj.id < 5)}
55+
selectedValue={gender.length > 0 ? gender[0].value : false}
56+
title="Gender"/>
57+
</Grid>
58+
</>
5759
);
5860
}

0 commit comments

Comments
 (0)