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

[Bugfix] Fixed a bug where removing all items from review block would send the user to a nothing to show page #100

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Fixed a bug where removing all items from review block would send the user to a "Nothing to Show" page.

## [3.15.4] - 2024-06-13

## [3.15.3] - 2024-06-10
Expand Down
7 changes: 3 additions & 4 deletions react/TextAreaBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { usePixel } from 'vtex.pixel-manager/PixelContext'

import { categoryMessages as messages } from './utils/messages'
import ReviewBlock from './components/ReviewBlock'
import { ParseText, GetText } from './utils'
import { ParseText } from './utils'

interface ItemType {
id: string
Expand Down Expand Up @@ -156,7 +156,7 @@ const TextAreaBlock: FunctionComponent<
}

const onReviewItems = (items: any) => {
if (items) {
if (items?.length) {
const show =
items.filter((item: any) => {
return item.error
Expand All @@ -167,9 +167,8 @@ const TextAreaBlock: FunctionComponent<
reviewItems: items,
reviewState: true,
showAddToCart: show,
textAreaValue: GetText(items),
})
}
} else backList()

return true
}
Expand Down
9 changes: 6 additions & 3 deletions react/UploadBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ const UploadBlock: FunctionComponent<
}

const onReviewItems = (items: any) => {
if (items) {
const show = !items.some((item: any) => item.error)
if (items?.length) {
const show =
items.filter((item: any) => {
return !item.vtexSku
}).length === 0

setState({
...state,
Expand All @@ -126,7 +129,7 @@ const UploadBlock: FunctionComponent<
showAddToCart: alwaysShowAddToCart || show,
textAreaValue: GetText(items),
})
}
} else backList()

return true
}
Expand Down