Skip to content

Commit

Permalink
Merge pull request leandrowd#109 from the-container-store/feature/180…
Browse files Browse the repository at this point in the history
…383495/sku-future-availability

[#180383495] - SKU future availability
  • Loading branch information
PradeepChada authored Dec 9, 2021
2 parents 1109a2c + 9626387 commit ba0f2a2
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 56 deletions.
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import CardSwipe from './pages/card-swipe/CardSwipe';
import PaymentFailure from './pages/payment-failure/PaymentFailure';
import PaymentSuccess from './pages/payment-success/PaymentSuccess';
import TransactionComplete from './pages/transaction-success/TransactionComplete';
import SKUFuture from './pages/sku-future/SKUFuture';
import StoreSearch from './pages/store-search/StoreSearch';

const StyledBody = styled('div')({
Expand Down Expand Up @@ -104,6 +105,11 @@ const App = () => {
path='/transaction-success'
component={TransactionComplete}
/>
<Route
exact
path='/sku-future-availability'
component={SKUFuture}
/>
<Route exact path='/store-search' component={StoreSearch} />
</Switch>
</StyledBody>
Expand Down
1 change: 1 addition & 0 deletions src/components/sku-tile/SkuTile.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const StockError = styled(Box)({
borderRadius: '0.25rem',
fontWeight: font.weight[400],
marginTop: styles.margin[1],
marginBottom: styles.margin[2],
padding: '0.625rem',
});

Expand Down
127 changes: 74 additions & 53 deletions src/pages/product-details/ProductDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,28 @@ const LoadingSkeleton = () => {
</Container>
);
};
const showStockDetails = (skuAvailabilityLoading, inStoreQty) => {
const showStockDetails = (
skuAvailabilityLoading,
inStoreQty,
skuAvailabilityError,
fetchSkuAvailabilityData
) => {
if (skuAvailabilityLoading) {
return <Skeleton />;
}
if (skuAvailabilityError) {
return (
<StockError>
{skuErrorMessages.inventory?.shortDescription}
<Box className='refresh-btn'>
<img src={RefreshIcon} alt='Refresh' />
<Button onClick={fetchSkuAvailabilityData} variant='text'>
Refresh Page
</Button>
</Box>
</StockError>
);
}
return (
<div className='stock-details'>
{inStoreQty ? (
Expand All @@ -111,7 +129,7 @@ const showAvailabilityInOtherStore = (skuAvailabilityLoading, toggleDrawer) => {
variant='text'
onClick={() => toggleDrawer(true)}
>
Show availability in other stores
Check Availability in Other Stores
<ChevronRight />
</Button>
</>
Expand Down Expand Up @@ -336,59 +354,62 @@ const ProductDetails = ({ history, match }) => {
</div>
<Availability>
<Typography className='sub-head'>Availability</Typography>
{skuAvailabilityError ? (
<StockError>
{skuErrorMessages.inventory?.shortDescription}
<Box className='refresh-btn'>
{/* <CachedIcon /> */}
<img src={RefreshIcon} alt='Refresh' />
<Button onClick={fetchSkuAvailabilityData} variant='text'>
Refresh Page
</Button>
</Box>
</StockError>
) : (
<>
<Box className='store-tile'>
<img
src={StoreIcon}
alt='Store'
/>
<Box flexGrow={1}>
{showStockDetails(skuAvailabilityLoading, inStoreQty)}
{showAvailabilityInOtherStore(
skuAvailabilityLoading,
toggleDrawer
)}
</Box>
{history.location.pathname.includes(SKUCheckoutDetailsURL) && (
<ButtonGroupWrapper>
<Typography
className='plus-button'
onClick={minusButtonHandler}
>
-
</Typography>
<InputWrapper
value={skuQuantity}
onChange={onChangeQuantity}
onBlur={onBlurQuantityInput}
/>
<Typography
className='minus-button'
onClick={plusButtonHandler}
>
+
</Typography>
</ButtonGroupWrapper>
<Box className='store-tile'>
<Box display='flex' flexDirection='row' width='100%'>
<img
src={StoreIcon}
alt='Store'
style={{ alignSelf: 'flex-start' }}
/>
<Box flexGrow={1}>
{showStockDetails(
skuAvailabilityLoading,
inStoreQty,
skuAvailabilityError,
fetchSkuAvailabilityData
)}
<Typography className='department'>
Department: Kitchen
</Typography>
</Box>
<Box className='store-tile other-stores'>
<img src={DeliveryIcon} alt='Store' />
<Box flexGrow={1}>{_renderDCInfo()}</Box>
</Box>
</>
)}
{history.location.pathname.includes(SKUCheckoutDetailsURL) && (
<ButtonGroupWrapper>
<Typography
className='plus-button'
onClick={minusButtonHandler}
>
-
</Typography>
<InputWrapper
value={skuQuantity}
onChange={onChangeQuantity}
onBlur={onBlurQuantityInput}
/>
<Typography
className='minus-button'
onClick={plusButtonHandler}
>
+
</Typography>
</ButtonGroupWrapper>
)}
</Box>
<hr />
<Typography className='need-more-text'>Need More ?</Typography>
<Button
className='availability-link'
variant='text'
onClick={() => history.push('/sku-future-availability')}
>
Check Future Availability
<ChevronRight />
</Button>
{showAvailabilityInOtherStore(skuAvailabilityLoading, toggleDrawer)}
</Box>
<Box className='store-tile other-stores'>
<img src={DeliveryIcon} alt='Store' />
<Box flexGrow={1}>{_renderDCInfo()}</Box>
</Box>
</Availability>
<Box>
{videos.length > 0 && (
Expand Down
24 changes: 21 additions & 3 deletions src/pages/product-details/ProductDetails.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ export const Availability = styled(Box)({
padding: '0.75rem 0.875rem',
margin: `${styles.margin[2]} 0`,
display: styles.display.flex,
alignItems: styles.align.center,
flexDirection: 'column',
alignItems: styles.align.start,
'&.other-stores': {
padding: '1.125rem 0.875rem',
},
'& img': {
marginRight: styles.margin[3],
},
'& .department': {
fontSize: font.size[14],
fontWeight: font.weight[400],
marginTop: styles.margin[2],
},
'& .stock-details': {
fontWeight: font.weight[600],
fontSize: font.size[16],
Expand All @@ -78,14 +84,26 @@ export const Availability = styled(Box)({
},
'& .availability-link': {
color: colors.brandBlue,
fontSize: font.size[14],
fontSize: font.size[16],
fontWeight: font.weight['bold'],
textTransform: 'unset',
padding: styles.padding[0],
marginTop: styles.margin[1],
marginTop: styles.margin[3],
},
'& hr': {
width: '100%',
border: `1px solid ${colors.gray85}`,
marginTop: styles.margin[3],
},
'& .need-more-text': {
width: '100%',
marginTop: styles.margin[3],
fontSize: font.size[14],
fontWeight: font.weight['bold'],
},
},
'& .other-stores': {
flexDirection:"row",
alignItems: styles.align.center,
'& .stock-details': {
padding: '0.375rem 0',
Expand Down
48 changes: 48 additions & 0 deletions src/pages/sku-future/SKUFuture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Button, TextField, Typography } from '@mui/material';
import { Box } from '@mui/system';
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { getDigitOnly } from '../../utils/skuHelpers';
import { Wrapper } from './SKUFuture.styles';
function SKUFuture() {
const history = useHistory();
const [skuQuantity, setSkuQuantity] = useState('');
const inputHandler = ({ target }) => {
const quantity = getDigitOnly(target.value);
if (quantity < 10000) {
setSkuQuantity(quantity);
}
};
return (
<Wrapper>
<Box>
<Typography>Future Availability Check</Typography>
<Typography>
Showing next available date for a desired quantity.
</Typography>
<TextField
fullWidth
label='Desired Quantity'
placeholder='Desired Quantity'
type='text'
value={skuQuantity}
onChange={inputHandler}
/>
<Typography className='available'>
45 will be available at Arlington Highlands on on 01/22/2022{' '}
</Typography>
<Typography className='not-available'>
Backordered: This item may be available at other stores near you.
</Typography>
</Box>
<Box display='flex' flexDirection='column' width='100%'>
<Button className='search-button'>SEARCH</Button>
<Button className='cancel-button' onClick={() => history.goBack()}>
CANCEL
</Button>
</Box>
</Wrapper>
);
}

export default SKUFuture;
52 changes: 52 additions & 0 deletions src/pages/sku-future/SKUFuture.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { colors, styles, font } from '../../utils/themeUtils';
import { Container } from '@mui/material';
import { styled } from '@mui/system';

export const Wrapper = styled(Container)({
display: styles.display.flex,
flexDirection: 'column',
justifyContent: styles.justify.between,
height: '100vh',
padding: styles.padding[3],
'& p:nth-of-type(1)': {
fontSize: font.size[20],
fontWeight: font.weight['bold'],
},
'& p:nth-of-type(2)': {
fontSize: font.size[12],
fontWeight: font.weight['normal'],
marginBottom: '1.75rem',
},
'& .available': {
marginTop: styles.margin[3],
fontSize: font.size[16],
fontWeight: font.weight['bold'],
color: colors.green,
},
'& .not-available': {
marginTop: styles.margin[3],
fontSize: font.size[16],
fontWeight: font.weight['bold'],
color: colors.danger,
},
'& .search-button': {
display: styles.display.flex,
justifyContent: styles.justify.center,
alignItems: styles.align.center,
borderRadius: '4px',
backgroundColor: colors.lightBlue,
color: colors.white,
fontSize: font.size[14],
fontWeight: font.weight['bold'],
padding: `${styles.padding[3]} 0`,
},
'& .cancel-button': {
display: styles.display.flex,
justifyContent: styles.justify.center,
alignItems: styles.align.center,
borderRadius: '4px',
fontSize: font.size[14],
fontWeight: font.weight['bold'],
padding: `${styles.padding[3]} 0`,
},
});

0 comments on commit ba0f2a2

Please sign in to comment.