diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..71a67a4b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: "[QE] Lint" + +on: + workflow_dispatch: + pull_request: + branches: + - master + - main + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: 12.x + env: + RUNNER_TEMP: /tmp + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: 'echo "::set-output name=dir::$(yarn cache dir)"' + - uses: actions/cache@v1 + id: yarn-cache + with: + path: "${{ steps.yarn-cache-dir-path.outputs.dir }}" + key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}" + restore-keys: | + ${{ runner.os }}-yarn- + - name: Lint project + uses: vtex/action-lint@master \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 00000000..80db5a6a --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,49 @@ +name: "[QE] SonarCloud" + +on: + push: + branches: + - master + - main + - release/* + - feature/* + - fix/* + - chore/* + pull_request: + types: [opened, synchronize, reopened] + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Cache for node_modules + uses: actions/cache@v2 + with: + path: "**/node_modules" + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install base packages + run: yarn install --frozen-lockfile + if: steps.cache-node-modules.outputs.cache-hit != 'true' + + - name: Install node packages + run: yarn install --frozen-lockfile + working-directory: ./node + if: steps.cache-node-modules.outputs.cache-hit != 'true' + + - name: Install react packages + run: yarn install --frozen-lockfile + working-directory: ./react + if: steps.cache-node-modules.outputs.cache-hit != 'true' + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e01cfa32..4d313cb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + - Restricting the Quick Order Upload to accept only .xls and .xlsx files +## [3.4.1] - 2022-01-07 + +## [3.4.0] - 2021-12-29 + ## [3.3.2] - 2021-12-21 ### Fixed diff --git a/manifest.json b/manifest.json index 60d1543d..5a42ef5e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "vendor": "vtex", "name": "quickorder", - "version": "3.3.2", + "version": "3.4.1", "title": "Quickorder", "description": "Allow users to add multiple products to the cart at once", "defaultLocale": "en-US", diff --git a/node/package.json b/node/package.json index 2fb3a5d7..2201bc56 100644 --- a/node/package.json +++ b/node/package.json @@ -53,5 +53,5 @@ "vtex.store-resources": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.73.0/public/_types/react", "vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.132.1/public/@types/vtex.styleguide" }, - "version": "3.3.2" + "version": "3.4.1" } diff --git a/react/AutocompleteBlock.tsx b/react/AutocompleteBlock.tsx index 7cb66c7b..07f12ed2 100644 --- a/react/AutocompleteBlock.tsx +++ b/react/AutocompleteBlock.tsx @@ -69,6 +69,7 @@ const AutocompleteBlock: StorefrontFunctionComponent { return intl.formatMessage(message) @@ -115,9 +116,16 @@ const AutocompleteBlock: StorefrontFunctionComponent { + const currentItemsInCart = orderForm.orderForm.items const mutationResult = await addToCart({ variables: { items: items.map((item: any) => { + const [existsInCurrentOrder] = currentItemsInCart.filter( + el => el.id === item.id.toString() + ) + if (existsInCurrentOrder) { + item.quantity = item.quantity + existsInCurrentOrder.quantity + } return { ...item, } diff --git a/react/TextAreaBlock.tsx b/react/TextAreaBlock.tsx index 3597d1fa..3ed3dc2f 100644 --- a/react/TextAreaBlock.tsx +++ b/react/TextAreaBlock.tsx @@ -66,6 +66,7 @@ const TextAreaBlock: StorefrontFunctionComponent { @@ -97,9 +98,16 @@ const TextAreaBlock: StorefrontFunctionComponent { + const currentItemsInCart = orderForm.orderForm.items const mutationResult = await addToCart({ variables: { items: items.map((item: any) => { + const [existsInCurrentOrder] = currentItemsInCart.filter( + el => el.id === item.id.toString() + ) + if (existsInCurrentOrder) { + item.quantity = item.quantity + existsInCurrentOrder.quantity + } return { ...item, } @@ -211,13 +219,20 @@ const TextAreaBlock: StorefrontFunctionComponent { + return internalItems.reduce((acc, val) => { + const { id, quantity } = val + const ind = acc.findIndex(el => el.id === id) + if (ind !== -1) { + acc[ind].quantity += quantity + } else { + acc.push(val) } - - callAddToCart(items) + return acc + }, []) + } + const mergedItems = merge(items) + callAddToCart(mergedItems) } const onRefidLoading = (data: boolean) => { setRefIdLoading(data) diff --git a/react/UploadBlock.tsx b/react/UploadBlock.tsx index 31c11735..084ec760 100644 --- a/react/UploadBlock.tsx +++ b/react/UploadBlock.tsx @@ -64,6 +64,7 @@ const UploadBlock: StorefrontFunctionComponent { @@ -216,9 +217,16 @@ const UploadBlock: StorefrontFunctionComponent { + const [existsInCurrentOrder] = currentItemsInCart.filter( + el => el.id === item.id.toString() + ) + if (existsInCurrentOrder) { + item.quantity = item.quantity + existsInCurrentOrder.quantity + } return { ...item, } @@ -289,13 +297,20 @@ const UploadBlock: StorefrontFunctionComponent { + return internalItems.reduce((acc, val) => { + const { id, quantity } = val + const ind = acc.findIndex(el => el.id === id) + if (ind !== -1) { + acc[ind].quantity += quantity + } else { + acc.push(val) } - - callAddToCart(items) + return acc + }, []) + } + const mergedItems = merge(items) + callAddToCart(mergedItems) } const CSS_HANDLES = [ diff --git a/react/package.json b/react/package.json index 6e4c0ec9..5205c488 100644 --- a/react/package.json +++ b/react/package.json @@ -51,5 +51,5 @@ "vtex.store-resources": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-resources@0.73.0/public/_types/react", "vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.132.1/public/@types/vtex.styleguide" }, - "version": "3.3.2" + "version": "3.4.1" } diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..4d8acd43 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=vtex-apps_quickorder +sonar.organization=vtex-apps + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=quickorder +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8