diff --git a/package.json b/package.json index c546d9fd4..3a4e865be 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ ], "scripts": { "dev": "evershop dev", - "dev:debug": "evershop dev --debug", "setup": "evershop install", "build": "evershop build", "start": "evershop start", diff --git a/packages/evershop/src/components/common/form/fields/Ckeditor.jsx b/packages/evershop/src/components/common/form/fields/Ckeditor.jsx index 1fb617343..460a7d92a 100644 --- a/packages/evershop/src/components/common/form/fields/Ckeditor.jsx +++ b/packages/evershop/src/components/common/form/fields/Ckeditor.jsx @@ -120,7 +120,9 @@ function FileBrowser({ .then((res) => res.json()) .then((response) => { if (!response.error) { - setFolders(folders.concat(response.data.name)); + // Get the first level folder, incase of recursive folder creation + const recursiveFolders = folder.split('/'); + setFolders([...new Set(folders.concat(recursiveFolders[0]))]); } else { setError(response.error.message); } diff --git a/packages/evershop/src/components/frontStore/catalog/product/list/List.jsx b/packages/evershop/src/components/frontStore/catalog/product/list/List.jsx index 7fee7fe3c..db6020151 100644 --- a/packages/evershop/src/components/frontStore/catalog/product/list/List.jsx +++ b/packages/evershop/src/components/frontStore/catalog/product/list/List.jsx @@ -69,6 +69,7 @@ ProductList.propTypes = { products: PropTypes.arrayOf( PropTypes.shape({ name: PropTypes.string, + sku: PropTypes.string, productId: PropTypes.number, url: PropTypes.string, price: PropTypes.shape({ diff --git a/packages/evershop/src/lib/log/debuger.js b/packages/evershop/src/lib/log/debuger.js index 06a93e9da..353c6c23f 100644 --- a/packages/evershop/src/lib/log/debuger.js +++ b/packages/evershop/src/lib/log/debuger.js @@ -1,43 +1,45 @@ const { green, red, blue, yellow, white } = require('kleur'); +const isDevelopmentMode = require('../util/isDevelopmentMode'); // Define logger function function debug(level, message) { - if (!process.argv.includes('--debug')) { - return; // Do not output message to console or file - } - let logMessage = ``; - let textMessage = `${message}`; - // If message is an exception object, include the stack trace - if (message instanceof Error) { - textMessage = `${message.message}\n${message.stack}`; - } - // Switch color based on level - switch (level) { - case 'critical': - logMessage += red(`[debug] ❌ ${textMessage}`); - break; - case 'warning': - logMessage += yellow(`[debug] ⚠️ ${textMessage}`); - break; - case 'info': - logMessage += blue(`[debug] ℹ️ ${textMessage}`); - break; - case 'success': - logMessage += green(`[debug] ✅ ${textMessage}`); - break; - default: - logMessage += white(`[debug] - ${textMessage}`); - break; - } + if (isDevelopmentMode() || process.argv.includes('--debug')) { + let logMessage = ``; + let textMessage = `${message}`; + // If message is an exception object, include the stack trace + if (message instanceof Error) { + textMessage = `${message.message}\n${message.stack}`; + } + // Switch color based on level + switch (level) { + case 'critical': + logMessage += red(`[debug] ❌ ${textMessage}`); + break; + case 'warning': + logMessage += yellow(`[debug] ⚠️ ${textMessage}`); + break; + case 'info': + logMessage += blue(`[debug] ℹ️ ${textMessage}`); + break; + case 'success': + logMessage += green(`[debug] ✅ ${textMessage}`); + break; + default: + logMessage += white(`[debug] - ${textMessage}`); + break; + } - // If message is added to a group, store it in the group - if (this.group && Array.isArray(this.group.messages)) { - this.group.messages.push(logMessage); - return; // Do not output message to console or file - } + // If message is added to a group, store it in the group + if (this.group && Array.isArray(this.group.messages)) { + this.group.messages.push(logMessage); + return; // Do not output message to console or file + } - // eslint-disable-next-line no-console - console.log(logMessage); + // eslint-disable-next-line no-console + console.log(logMessage); + } else { + // Do not output message to console or file + } } function error(e) { diff --git a/packages/evershop/src/lib/util/buildFilterFromUrl.js b/packages/evershop/src/lib/util/buildFilterFromUrl.js index c8bd76baf..1d40cacb5 100644 --- a/packages/evershop/src/lib/util/buildFilterFromUrl.js +++ b/packages/evershop/src/lib/util/buildFilterFromUrl.js @@ -48,7 +48,7 @@ module.exports.buildFilterFromUrl = (query) => { filtersFromUrl.push({ key: 'sortBy', operation: '=', - value: sortBy + value: sortBy.toString() }); } diff --git a/packages/evershop/src/modules/base/pages/global/[response]errorHandler.js b/packages/evershop/src/modules/base/pages/global/[response]errorHandler.js index 69845d452..be2daa5fb 100644 --- a/packages/evershop/src/modules/base/pages/global/[response]errorHandler.js +++ b/packages/evershop/src/modules/base/pages/global/[response]errorHandler.js @@ -1,3 +1,4 @@ +const { encode } = require('html-entities'); const { INTERNAL_SERVER_ERROR } = require('@evershop/evershop/src/lib/util/httpStatus'); @@ -30,6 +31,6 @@ module.exports = async (err, request, response, delegate, next) => { } }); } else { - response.status(500).send(err.message); + response.status(500).send(encode(err.message)); } }; diff --git a/packages/evershop/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js b/packages/evershop/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js index c6cd2d258..01c2b1b2f 100644 --- a/packages/evershop/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js +++ b/packages/evershop/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js @@ -83,7 +83,7 @@ module.exports = async (request, response, delegate, next) => { filtersFromUrl.push({ key: 'sortBy', operation: '=', - value: sortBy + value: sortBy.toString() }); } diff --git a/packages/evershop/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx b/packages/evershop/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx index fa438688a..b86420da7 100644 --- a/packages/evershop/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx +++ b/packages/evershop/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx @@ -26,6 +26,7 @@ FeaturedProducts.propTypes = { items: PropTypes.arrayOf( PropTypes.shape({ productId: PropTypes.number.isRequired, + sku: PropTypes.string.isRequired, name: PropTypes.string.isRequired, price: PropTypes.shape({ regular: PropTypes.shape({ @@ -62,6 +63,7 @@ export const query = ` items { productId name + sku price { regular { value diff --git a/packages/evershop/src/modules/catalog/pages/frontStore/productView/Form.jsx b/packages/evershop/src/modules/catalog/pages/frontStore/productView/Form.jsx index 7454d8f24..deffc6452 100644 --- a/packages/evershop/src/modules/catalog/pages/frontStore/productView/Form.jsx +++ b/packages/evershop/src/modules/catalog/pages/frontStore/productView/Form.jsx @@ -50,10 +50,7 @@ function ToastMessage({ thumbnail, name, qty, count, cartUrl, toastId }) {
{name}
-
- Qty: - {qty} -
+
{_('QTY: ${qty}', { qty })}
@@ -92,7 +89,7 @@ function AddToCart({ stockAvaibility, loading = false, error }) { validationRules={['notEmpty']} className="qty" name="qty" - placeholder="Qty" + placeholder={_('Qty')} formId="productForm" /> @@ -113,7 +110,7 @@ function AddToCart({ stockAvaibility, loading = false, error }) { /> )} {stockAvaibility === false && ( -