META-INF.resources.js.DiagramTable.MappedProductRow.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.commerce.shop.by.diagram.web
Show all versions of com.liferay.commerce.shop.by.diagram.web
Liferay Commerce Shop by Diagram Web
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
import ClayButton, {ClayButtonWithIcon} from '@clayui/button';
import {ClayCheckbox} from '@clayui/form';
import ClayTable from '@clayui/table';
import {QuantitySelectorComponent} from 'commerce-frontend-js';
import {sub} from 'frontend-js-web';
import React from 'react';
import Price from '../components/Price';
import {formatLabel} from '../utilities/index';
export default function MappedProductRow({
handleMouseEnter,
handleMouseLeave,
handleTitleClicked,
isAdmin,
onDelete,
product,
quantity,
setMappedProducts,
setNewQuantity,
}) {
function updateSelected(selected) {
setMappedProducts((mappedProducts) =>
mappedProducts.map((mappedProduct) =>
mappedProduct.skuId === product.skuId
? {
...mappedProduct,
selected,
}
: mappedProduct
)
);
}
return (
handleMouseEnter(product)}
onMouseLeave={() => handleMouseLeave(product)}
>
{!isAdmin && (
{
updateSelected(event.target.checked);
}}
/>
)}
{formatLabel(product.sequence)}
handleTitleClicked(product)}
>
{product.type === 'diagram'
? product.productName[
Liferay.ThemeDisplay.getLanguageId()
]
: product.sku}
{product.type === 'sku' && (
{
product.productName[
Liferay.ThemeDisplay.getLanguageId()
]
}
)}
{isAdmin && product.type !== 'diagram' && product.quantity}
{!isAdmin &&
product.productConfiguration &&
product.type === 'sku' && (
{
setNewQuantity(value);
if (errors.length) {
updateSelected(false);
}
}}
quantity={quantity}
size="sm"
step={
product.productConfiguration
.multipleOrderQuantity
}
/>
)}
{!isAdmin && product.type === 'external' && product.quantity}
{isAdmin ? (
onDelete(product.id)}
small
symbol="trash"
/>
) : (
{product.price && }
)}
);
}