Skip to content

Commit

Permalink
Merge pull request #51 from commercelayer/fix/external-prices
Browse files Browse the repository at this point in the history
Enable support for external prices
  • Loading branch information
gciotola authored Nov 7, 2023
2 parents b2e0a0b + a6ea67a commit dfa813c
Show file tree
Hide file tree
Showing 5 changed files with 1,605 additions and 1,085 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"packages/*"
],
"devDependencies": {
"lerna": "^7.0.0",
"npm-check-updates": "^16.10.12"
"lerna": "^7.4.2",
"npm-check-updates": "^16.14.6"
}
}
66 changes: 33 additions & 33 deletions packages/cart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,52 +37,52 @@
"prepare": "touch ./public/config.local.js"
},
"dependencies": {
"@commercelayer/js-auth": "^4.1.1",
"@commercelayer/react-components": "^4.5.0-beta.13",
"@commercelayer/js-auth": "^4.2.0",
"@commercelayer/react-components": "^4.7.7-beta.0",
"@commercelayer/react-utils": "1.0.0-beta.3",
"@commercelayer/sdk": "5.10.0",
"@playwright/test": "^1.35.0",
"@types/async-retry": "1.4.5",
"@types/iframe-resizer": "^3.5.9",
"@types/node": "20.2.5",
"@types/react": "18.2.9",
"@types/react-dom": "18.2.4",
"@types/react-gtm-module": "^2.0.1",
"@vitejs/plugin-react": "^4.0.0",
"@commercelayer/sdk": "5.19.2",
"@playwright/test": "^1.39.0",
"@types/async-retry": "1.4.7",
"@types/iframe-resizer": "^3.5.11",
"@types/node": "20.8.10",
"@types/react": "18.2.34",
"@types/react-dom": "18.2.14",
"@types/react-gtm-module": "^2.0.2",
"@vitejs/plugin-react": "^4.1.1",
"async-retry": "^1.3.3",
"autoprefixer": "^10.4.14",
"autoprefixer": "^10.4.16",
"classnames": "^2.3.2",
"dotenv": "^16.1.4",
"i18next": "^22.5.1",
"jwt-decode": "^3.1.2",
"postcss": "^8.4.24",
"dotenv": "^16.3.1",
"i18next": "^23.6.0",
"jwt-decode": "^4.0.0",
"postcss": "^8.4.31",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-gtm-module": "^2.0.11",
"react-helmet-async": "^1.3.0",
"react-i18next": "^12.3.1",
"rollup-plugin-visualizer": "^5.9.0",
"tailwindcss": "^3.3.2",
"typescript": "5.1.3",
"vite": "^4.3.9",
"vitest": "^0.32.0",
"wouter": "^2.11.0"
"react-i18next": "^13.3.1",
"rollup-plugin-visualizer": "^5.9.2",
"tailwindcss": "^3.3.5",
"typescript": "5.2.2",
"vite": "^4.5.0",
"vitest": "^0.34.6",
"wouter": "^2.12.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.1.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react": "^7.33.2",
"jsdom": "^22.1.0",
"prettier": "^2.8.8"
"prettier": "^3.0.3"
},
"engines": {
"node": ">=18"
Expand Down
38 changes: 27 additions & 11 deletions packages/cart/src/components/Cart/Summary/QuantitySelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Errors, LineItemQuantity } from "@commercelayer/react-components"
import {
Errors,
LineItemField,
LineItemQuantity,
} from "@commercelayer/react-components"
import { FC } from "react"
import { useTranslation } from "react-i18next"

Expand All @@ -13,16 +17,28 @@ export const QuantitySelector: FC<Props> = () => {

return (
<div className="relative w-full">
<LineItemQuantity>
{({ quantity, handleChange }) => (
<InputSpinner
data-test-id="quantity-selector"
quantity={quantity}
handleChange={handleChange}
debounceMs={600}
/>
)}
</LineItemQuantity>
<LineItemField attribute="metadata" tagElement="div">
{(childrenProps: any) => {
const hasExternalPrice =
childrenProps.attributeValue?.cart_external_price != null

return (
<LineItemQuantity hasExternalPrice={hasExternalPrice}>
{({ quantity, handleChange }) => {
return (
<InputSpinner
data-test-id="quantity-selector"
quantity={quantity}
handleChange={handleChange}
debounceMs={600}
/>
)
}}
</LineItemQuantity>
)
}}
</LineItemField>

<Errors
resource="line_items"
className="absolute top-[100%] block text-xs text-red-400"
Expand Down
4 changes: 2 additions & 2 deletions packages/cart/src/utils/getInfoFromJwt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jwtDecode from "jwt-decode"
import { jwtDecode } from "jwt-decode"

type JWTProps = {
/**
Expand All @@ -25,7 +25,7 @@ type JWTProps = {
* Decodes a JWT string in order to retrive some required organization info.
*
* @param accessToken - The Bearer JWT token used to authenticate Commerce Layer API request.
* @returns an object of type `JWTProps` or an empy object in case of failure.
* @returns an object of type `JWTProps` or an empty object in case of failure.
*
*/
export const getInfoFromJwt = (accessToken: string) => {
Expand Down
Loading

0 comments on commit dfa813c

Please sign in to comment.