Skip to content

Commit

Permalink
fix: update order details issues
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Jan 3, 2023
1 parent 7138b17 commit 413c547
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 43 deletions.
2 changes: 1 addition & 1 deletion apps/storefront/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ <h1>Ugly Cornerstone Store Theme with Weird CSS</h1>
</small>
</label>

<textarea class="form-input" id="attribute_textarea_134" name="attribute[134]" required="" maxlength="255" style="width: 561px; height: 118px;"></textarea>
<textarea class="form-input" id="attribute_textarea_134" name="attribute[134]" required="" maxlength="255" style="width: 100%; height: 118px;"></textarea>
</div>

<div class="form-field" data-product-attribute="input-checkbox">
Expand Down
5 changes: 1 addition & 4 deletions apps/storefront/src/components/B3Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
DialogActions,
DialogContent,
DialogTitle,
Divider,
} from '@mui/material'

import {
Expand Down Expand Up @@ -75,7 +74,7 @@ export const B3Dialog:<T> ({
children,
loading = false,
row,
isShowBordered = false,
isShowBordered = true,
showRightBtn = true,
maxWidth = 'sm',
fullWidth = false,
Expand Down Expand Up @@ -135,11 +134,9 @@ export const B3Dialog:<T> ({
</DialogTitle>
)
}
<Divider />
<DialogContent>
{children}
</DialogContent>
<Divider />
<DialogActions
sx={
isShowBordered ? {
Expand Down
63 changes: 41 additions & 22 deletions apps/storefront/src/components/B3LinkTipContent.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,57 @@
import {
Link,
Box,
} from '@mui/material'

import {
useNavigate,
} from 'react-router-dom'

interface B3SuccessTipContentProps{
message: string,
link?: string,
linkText?: string,
isOutLink?: boolean,
}

export const B3LinkTipContent = ({
message,
link,
link = '',
linkText = 'View',
}: B3SuccessTipContentProps) => (
<Box>
<Box
sx={{
display: 'inline',
marginRight: link ? '20px' : '0',
}}
>
{message}
</Box>
{link && (
<Link
href={link}
isOutLink = false,
}: B3SuccessTipContentProps) => {
const navigate = useNavigate()

const handleLink = () => {
if (isOutLink) {
window.location.href = link
} else {
navigate(link)
}
}

return (
<Box>
<Box
sx={{
color: 'inherit',
textDecoration: 'none',
display: 'inline',
marginRight: link ? '20px' : '0',
}}
>
{linkText}
</Link>
)}
</Box>
)
{message}
</Box>
{link && (
<Box
onClick={handleLink}
sx={{
color: 'inherit',
display: 'inline',
textDecoration: 'none',
cursor: 'pointer',
}}
>
{linkText}
</Box>
)}
</Box>
)
}
4 changes: 4 additions & 0 deletions apps/storefront/src/components/B3ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ export const B3ProductList: <T>(props: ProductProps<T>) => ReactElement = (props
size="small"
sx={{
width: isMobile ? '60%' : '100%',
'& .MuiFormHelperText-root': {
marginLeft: '0',
marginRight: '0',
},
}}
error={!!product.helperText}
helperText={product.helperText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ export const OrderCheckboxProduct = (props: OrderCheckboxProductProps) => {
size="small"
sx={{
width: isMobile ? '60%' : '100%',
'& .MuiFormHelperText-root': {
marginLeft: '0',
marginRight: '0',
},
}}
error={!!product.helperText}
helperText={product.helperText}
Expand Down
54 changes: 39 additions & 15 deletions apps/storefront/src/pages/orderDetail/components/OrderDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import {
B3LinkTipContent,
} from '@/components'

import {
useMobile,
} from '@/hooks'

import {
snackbar,
} from '@/utils'
Expand Down Expand Up @@ -75,6 +79,22 @@ interface OrderDialogProps {
currencyInfo: OrderCurrency,
}

interface successTipOptions{
message: string,
link?: string,
linkText?: string,
isOutLink?: boolean,
}

const successTip = (options: successTipOptions) => () => (
<B3LinkTipContent
message={options.message}
link={options.link}
linkText={options.linkText}
isOutLink={options.isOutLink}
/>
)

export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
open,
products = [],
Expand All @@ -94,6 +114,8 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({

const [returnFormFields] = useState(getReturnFormFields())

const [isMobile] = useMobile()

const {
control,
handleSubmit,
Expand Down Expand Up @@ -167,14 +189,6 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
return isValid
}

const successTip = () => (
<B3LinkTipContent
message="Products are added to cart"
link="/cart.php"
linkText="VIEW CART"
/>
)

const handleReorder = async () => {
setIsRequestLoading(true)

Expand Down Expand Up @@ -222,7 +236,12 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
} else {
setOpen(false)
snackbar.success('', {
jsx: successTip,
jsx: successTip({
message: 'Products are added to cart',
link: '/cart.php',
linkText: 'VIEW CART',
isOutLink: true,
}),
})
}
} finally {
Expand All @@ -231,11 +250,10 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
}

const handleSaveClick = () => {
if (checkedArr.length === 0) {
return
}

if (type === 'shoppingList') {
if (checkedArr.length === 0) {
return
}
handleClose()
setOpenShoppingList(true)
}
Expand Down Expand Up @@ -293,7 +311,13 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
items: params,
})

snackbar.success('Products were added to your shopping list')
snackbar.success('', {
jsx: successTip({
message: 'Products were added to your shopping list',
link: '/shoppingLists',
linkText: 'VIEW SHOPPING LIST',
}),
})

setOpenShoppingList(false)
} finally {
Expand Down Expand Up @@ -356,7 +380,7 @@ export const OrderDialog: (props: OrderDialogProps) => ReactElement = ({
>
<Typography
sx={{
margin: '1rem 0',
margin: isMobile ? '0 0 1rem' : '1rem 0',
}}
>
{currentDialogData?.description || ''}
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/pages/orderDetail/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getReturnFormFields = () => [
}, {
name: 'return_comments',
label: 'Comment',
required: true,
required: false,
xs: 12,
rows: 5,
variant: 'filled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ export const ReAddToCart = (props: ShoppingProductsProps) => {
size="small"
sx={{
width: isMobile ? '60%' : '100%',
'& .MuiFormHelperText-root': {
marginLeft: '0',
marginRight: '0',
},
}}
/>
</FlexItem>
Expand Down

0 comments on commit 413c547

Please sign in to comment.