@adobe/aem-core-cif-react-components
Advanced tools
Comparing version 0.7.0 to 0.9.0
{ | ||
"name": "@adobe/aem-core-cif-react-components", | ||
"version": "0.7.0", | ||
"version": "0.9.0", | ||
"description": "A collection of React components used in the AEM CIF Core Components project", | ||
@@ -13,3 +13,2 @@ "author": "Adobe Systems Inc.", | ||
"scripts": { | ||
"prepare": "rm -rf ./dist", | ||
"lint": "eslint 'src/**/*.js'", | ||
@@ -16,0 +15,0 @@ "webpack:dev": "webpack --mode=development", |
@@ -36,2 +36,7 @@ /******************************************************************************* | ||
if (initialValues && key in initialValues) { | ||
// Convert street from array to flat strings | ||
if (key === 'street') { | ||
initialValues[key].forEach((v, i) => (acc[`street${i}`] = v)); | ||
return acc; | ||
} | ||
acc[key] = initialValues[key]; | ||
@@ -47,6 +52,8 @@ } | ||
setIsSubmitting(true); | ||
submit(values); | ||
// Convert street back to array | ||
submit({ ...values, street: [values.street0] }); | ||
}, | ||
[submit] | ||
); | ||
return ( | ||
@@ -58,3 +65,3 @@ <Form className={classes.root} initialValues={values} onSubmit={handleSubmit}> | ||
<Field label="First Name"> | ||
<TextInput id={classes.firstname} field="firstname" validate={isRequired} /> | ||
<TextInput id={classes.firstname} field="firstname" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -64,3 +71,3 @@ </div> | ||
<Field label="Last Name"> | ||
<TextInput id={classes.lastname} field="lastname" validate={isRequired} /> | ||
<TextInput id={classes.lastname} field="lastname" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -70,3 +77,8 @@ </div> | ||
<Field label="Email"> | ||
<TextInput id={classes.email} field="email" validate={combine([isRequired, validateEmail])} /> | ||
<TextInput | ||
id={classes.email} | ||
field="email" | ||
validateOnBlur | ||
validate={combine([isRequired, validateEmail])} | ||
/> | ||
</Field> | ||
@@ -76,3 +88,3 @@ </div> | ||
<Field label="Street"> | ||
<TextInput id={classes.street0} field="street[0]" validate={isRequired} /> | ||
<TextInput id={classes.street0} field="street0" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -82,3 +94,3 @@ </div> | ||
<Field label="City"> | ||
<TextInput id={classes.city} field="city" validate={isRequired} /> | ||
<TextInput id={classes.city} field="city" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -91,2 +103,3 @@ </div> | ||
field="region_code" | ||
validateOnBlur | ||
validate={combine([isRequired, [hasLengthExactly, 2], [validateRegionCode, countries]])} | ||
@@ -98,3 +111,3 @@ /> | ||
<Field label="ZIP"> | ||
<TextInput id={classes.postcode} field="postcode" validate={isRequired} /> | ||
<TextInput id={classes.postcode} field="postcode" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -104,3 +117,3 @@ </div> | ||
<Field label="Phone"> | ||
<TextInput id={classes.telephone} field="telephone" validate={isRequired} /> | ||
<TextInput id={classes.telephone} field="telephone" validateOnBlur validate={isRequired} /> | ||
</Field> | ||
@@ -107,0 +120,0 @@ </div> |
@@ -28,12 +28,14 @@ /******************************************************************************* | ||
quantity: 2, | ||
product: { | ||
name: 'Dummy product', | ||
prices: { | ||
price: { | ||
regularPrice: { | ||
amount: { | ||
value: 100, | ||
currency: 'USD' | ||
} | ||
} | ||
currency: 'USD', | ||
value: 100 | ||
}, | ||
row_total: { | ||
currency: 'USD', | ||
value: 100 | ||
} | ||
}, | ||
product: { | ||
name: 'Dummy product' | ||
} | ||
@@ -40,0 +42,0 @@ } |
@@ -24,10 +24,12 @@ /******************************************************************************* | ||
}, | ||
name, | ||
name | ||
}, | ||
prices: { | ||
price: { | ||
regularPrice: { | ||
amount: { | ||
value: 22, | ||
currency: 'USD' | ||
} | ||
} | ||
currency: 'USD', | ||
value: 22 | ||
}, | ||
row_total: { | ||
currency: 'USD', | ||
value: 22 | ||
} | ||
@@ -34,0 +36,0 @@ }, |
@@ -26,10 +26,12 @@ /******************************************************************************* | ||
}, | ||
name: 'Some t-shirt', | ||
name: 'Some t-shirt' | ||
}, | ||
prices: { | ||
price: { | ||
regularPrice: { | ||
amount: { | ||
value: 1, | ||
currency: 'USD' | ||
} | ||
} | ||
currency: 'USD', | ||
value: 1 | ||
}, | ||
row_total: { | ||
currency: 'USD', | ||
value: 1 | ||
} | ||
@@ -45,10 +47,12 @@ }, | ||
}, | ||
name: 'Some shorts', | ||
name: 'Some shorts' | ||
}, | ||
prices: { | ||
price: { | ||
regularPrice: { | ||
amount: { | ||
value: 30, | ||
currency: 'USD' | ||
} | ||
} | ||
currency: 'USD', | ||
value: 30 | ||
}, | ||
row_total: { | ||
currency: 'USD', | ||
value: 30 | ||
} | ||
@@ -55,0 +59,0 @@ }, |
@@ -27,2 +27,3 @@ /******************************************************************************* | ||
import { useCartState } from './cartContext'; | ||
import DiscountList from './discountList'; | ||
@@ -53,2 +54,8 @@ const loadingIndicator = <LoadingIndicator>{`Fetching cart data...`}</LoadingIndicator>; | ||
const couponFragment = !cart.applied_coupon ? <CouponForm /> : <CouponItem />; | ||
const discountFragment = | ||
cart.prices.discounts && cart.prices.discounts.length > 0 ? ( | ||
<DiscountList discounts={cart.prices.discounts} /> | ||
) : ( | ||
<div /> | ||
); | ||
@@ -58,2 +65,3 @@ return ( | ||
<ProductList cartItems={cartItems} /> | ||
{discountFragment} | ||
{couponFragment} | ||
@@ -60,0 +68,0 @@ </div> |
@@ -31,7 +31,6 @@ /******************************************************************************* | ||
const { product, quantity: initialQuantity } = editItem; | ||
const { name, price: productPrice } = product; | ||
const { product, quantity: initialQuantity, prices } = editItem; | ||
const { name } = product; | ||
const { value, currency } = prices.price; | ||
const { value, currency } = productPrice.regularPrice.amount; | ||
const [quantity, setQuantity] = useState(initialQuantity); | ||
@@ -38,0 +37,0 @@ |
@@ -24,7 +24,11 @@ /******************************************************************************* | ||
const { currency, value: totalPrice } = cart.prices.grand_total; | ||
const { subtotal_excluding_tax, subtotal_with_discount_excluding_tax } = cart.prices; | ||
return ( | ||
<div className={footerClassName}> | ||
<TotalsSummary currencyCode={currency} numItems={cart.items.length} subtotal={totalPrice} /> | ||
<TotalsSummary | ||
subtotal={subtotal_excluding_tax} | ||
subtotalDiscount={subtotal_with_discount_excluding_tax} | ||
numItems={cart.items.length} | ||
/> | ||
<Checkout /> | ||
@@ -31,0 +35,0 @@ </div> |
@@ -33,6 +33,7 @@ /******************************************************************************* | ||
const { product = {}, quantity = 0, id = '' } = item; | ||
const { thumbnail, name, price } = product; | ||
const { value, currency } = price.regularPrice.amount; | ||
const { product = {}, quantity = 0, id = '', prices } = item; | ||
const { thumbnail, name } = product; | ||
let { price, row_total } = prices; | ||
const productImage = useMemo(() => { | ||
@@ -59,5 +60,10 @@ const src = | ||
<span className={classes.price}> | ||
<Price currencyCode={currency} value={value} /> | ||
<Price currencyCode={price.currency} value={price.value} /> | ||
</span> | ||
</div> | ||
<div className={classes.rowTotalRow}> | ||
<span className={classes.rowTotal}> | ||
<Price currencyCode={row_total.currency} value={row_total.value} /> | ||
</span> | ||
</div> | ||
</div> | ||
@@ -82,12 +88,14 @@ <Kebab> | ||
quantity: number.isRequired, | ||
prices: shape({ | ||
price: shape({ | ||
value: number.isRequired, | ||
currency: string.isRequired | ||
}).isRequired, | ||
row_total: shape({ | ||
value: number.isRequired, | ||
currency: string.isRequired | ||
}).isRequired | ||
}).isRequired, | ||
product: shape({ | ||
name: string.isRequired, | ||
price: shape({ | ||
regularPrice: shape({ | ||
amount: shape({ | ||
value: number.isRequired, | ||
currency: string.isRequired | ||
}).isRequired | ||
}).isRequired | ||
}).isRequired, | ||
image: object | ||
@@ -94,0 +102,0 @@ }) |
@@ -15,3 +15,3 @@ /******************************************************************************* | ||
import React from 'react'; | ||
import { number, string } from 'prop-types'; | ||
import { number, string, shape } from 'prop-types'; | ||
@@ -24,9 +24,20 @@ import { Price } from '@magento/peregrine'; | ||
// Props. | ||
const { currencyCode, numItems, subtotal } = props; | ||
const { numItems, subtotal, subtotalDiscount } = props; | ||
// Do not display price, if cart is empty. But display price, if the cart has | ||
// items and the price is 0 (e.g. when coupons are applied). | ||
const hasSubtotal = Boolean(subtotal) || numItems > 0; | ||
const hasSubtotal = Boolean(subtotal.value) || numItems > 0; | ||
const hasDiscount = subtotal.value !== subtotalDiscount.value; | ||
const numItemsText = numItems === 1 ? 'item' : 'items'; | ||
let priceClasses = {}; | ||
if (hasDiscount) { | ||
priceClasses = { | ||
currency: classes.discounted, | ||
integer: classes.discounted, | ||
decimal: classes.discounted, | ||
fraction: classes.discounted | ||
}; | ||
} | ||
return ( | ||
@@ -38,4 +49,4 @@ <div className={classes.root}> | ||
<span> | ||
{'Cart Total : '} | ||
<Price currencyCode={currencyCode} value={subtotal} /> | ||
{'Cart Total: '} | ||
<Price classes={priceClasses} currencyCode={subtotal.currency} value={subtotal.value} /> | ||
</span> | ||
@@ -48,2 +59,15 @@ </dt> | ||
)} | ||
{hasSubtotal && hasDiscount && ( | ||
<dl className={classes.totalsDiscount}> | ||
<dt className={classes.subtotalLabel}> | ||
<span> | ||
{'New Cart Total: '} | ||
<Price currencyCode={subtotalDiscount.currency} value={subtotalDiscount.value} /> | ||
</span> | ||
</dt> | ||
<dd className={classes.subtotalValue}> | ||
({numItems} {numItemsText}) | ||
</dd> | ||
</dl> | ||
)} | ||
</div> | ||
@@ -56,5 +80,12 @@ ); | ||
numItems: number, | ||
subtotal: number | ||
subtotal: shape({ | ||
currency: string, | ||
value: number | ||
}), | ||
subtotalDiscount: shape({ | ||
currency: string, | ||
value: number | ||
}) | ||
}; | ||
export default TotalsSummary; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3784836
224
11776
3
17
5