Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [quick order] adjust validation of skus and show better status #167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Fixes validation of SKU codes in the quickorder and styles of the ReviewBlock component

## [3.15.4] - 2024-06-13

## [3.15.3] - 2024-06-10
Expand Down
68 changes: 35 additions & 33 deletions react/components/ReviewBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import {
Input,
ButtonWithIcon,
IconDelete,
IconInfo,
Tooltip,
Dropdown,
ToastContext,
Tag,
} from 'vtex.styleguide'
import type { WrappedComponentProps } from 'react-intl'
import { injectIntl } from 'react-intl'
Expand All @@ -32,8 +31,8 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
hiddenColumns,
reviewedItems,
onRefidLoading,
backList,
intl,
backList,
}: any) => {
const client = useApolloClient()
const { showToast } = useContext(ToastContext)
Expand Down Expand Up @@ -128,11 +127,11 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({

// drops sellers without stock from refidData
refidData?.skuFromRefIds.items.forEach((item: any) => {
if (!item.sellers) return
if (!item?.sellers) return
item.sellers = item.sellers.filter(
(seller: any) =>
seller.availability === 'available' ||
seller.availability === 'partiallyAvailable'
seller?.availability === 'available' ||
seller?.availability === 'partiallyAvailable'
)
})

Expand Down Expand Up @@ -192,19 +191,20 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({

let selectedSellerHasPartialStock
const foundHasStock =
found?.sellers?.length &&
found.sellers.filter((seller: any) => {
if (seller.id === sellerWithStock) {
selectedSellerHasPartialStock =
seller.availability === 'partiallyAvailable'
}

return (
seller.availability &&
(seller.availability === 'available' ||
seller.availability === 'partiallyAvailable')
)
}).length
(found?.sellers?.length &&
found.sellers.filter((seller: any) => {
if (seller?.id === sellerWithStock) {
selectedSellerHasPartialStock =
seller?.availability === 'partiallyAvailable'
}

return (
seller?.availability &&
(seller?.availability === 'available' ||
seller?.availability === 'partiallyAvailable')
)
})?.length) ||
0

const itemRestricted = sellerWithStock
? null
Expand Down Expand Up @@ -281,6 +281,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
})

onReviewItems(updated)

if (JSON.stringify(reviewItems) !== JSON.stringify(updated)) {
setReviewState({
...state,
Expand Down Expand Up @@ -475,7 +476,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
tableSchema.properties.sku = {
type: 'string',
title: intl.formatMessage({ id: 'store/quickorder.review.label.sku' }),
width: 125,
width: 112,
ataideverton marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -485,7 +486,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
title: intl.formatMessage({
id: 'store/quickorder.review.label.quantity',
}),
width: 75,
width: 72,
}
}

Expand All @@ -502,10 +503,14 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
if (columnsToBeHidden.indexOf('totalQuantity') === -1) {
tableSchema.properties.totalQuantity = {
type: 'float',
title: intl.formatMessage({
id: 'store/quickorder.review.label.totalQuantity',
}),
width: 100,
title: (
<div style={{ whiteSpace: 'break-spaces' }}>
{intl.formatMessage({
id: 'store/quickorder.review.label.totalQuantity',
})}
</div>
),
width: 82,
}
}

Expand Down Expand Up @@ -546,7 +551,6 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
title: intl.formatMessage({
id: 'store/quickorder.review.label.status',
}),
width: 75,
cellRenderer: ({ cellData, rowData }: any) => {
if (rowData.error) {
const errMsg = errorMessage[cellData || 'store/quickorder.valid']
Expand All @@ -560,12 +564,10 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
: intl.formatMessage(errMsg)

return (
<span className="pa3 br2 dib mr5 mv0">
<Tooltip label={text}>
<span className="c-danger pointer">
<IconInfo />
</span>
</Tooltip>
<span>
<Tag type="error" variation="low" size="small">
{text}
</Tag>
</span>
)
}
Expand All @@ -579,7 +581,7 @@ const ReviewBlock: FunctionComponent<WrappedComponentProps & any> = ({
tableSchema.properties.delete = {
type: 'object',
title: ' ',
width: 75,
width: 58,
// eslint-disable-next-line react/display-name
cellRenderer: ({ rowData }: any) => {
return (
Expand Down
Loading