"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductList = void 0;
const react_web_components_1 = require("@nimles/react-web-components");
const react_1 = __importStar(require("react"));
const react_redux_1 = require("react-redux");
const react_redux_2 = require("@nimles/react-redux");
const styled_1 = __importDefault(require("@emotion/styled"));
const react_web_components_2 = require("@nimles/react-web-components");
const Link_1 = require("./Link");
const Name = styled_1.default.h2 `
  font-size: 16px;
  margin-top: 0;
  font-size: 500;
  flex: 1 0 auto;
`;
const CardLink = (0, styled_1.default)(Link_1.NavLink) `
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
`;
const ProductList = ({ organizationId, productGroupId, start = 0, limit = 24, order = 'name', }) => {
    const dispatch = (0, react_redux_1.useDispatch)();
    const products = (0, react_redux_1.useSelector)(({ publicProducts }) => publicProducts.values);
    const tenant = (0, react_redux_1.useSelector)(({ publicTenants }) => publicTenants.selected);
    (0, react_1.useEffect)(() => {
        dispatch((0, react_redux_2.searchAndLoadPublicProducts)({
            start,
            limit,
            order,
            organizationId,
            productGroupIds: productGroupId,
        }));
    }, [start, limit, order, organizationId, productGroupId]);
    return (<react_web_components_1.Row wrap>
      {products.map((product) => (<react_web_components_1.Column key={product.id} padding xs={100} md={50} lg={33} xl={25}>
          <react_web_components_1.Card flex="1 0 auto">
            <CardLink to={`/${product.uniqueName}/pr`}>
              <react_web_components_2.Image src={`https://media.nimles.com/file/${tenant.id}/${product.images[0].id}?width=200`} alt={product.name}/>
              <react_web_components_1.CardBody>
                <Name>{product.name}</Name>
                <react_web_components_2.Price>{product.netPrice}</react_web_components_2.Price>
              </react_web_components_1.CardBody>
            </CardLink>
          </react_web_components_1.Card>
        </react_web_components_1.Column>))}
    </react_web_components_1.Row>);
};
exports.ProductList = ProductList;
//# sourceMappingURL=ProductList.jsx.map