@evershop/evershop 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build/client/index.js +1 -1
- package/bin/build/complie.js +1 -1
- package/bin/build/index.js +1 -1
- package/bin/build/server/index.js +1 -1
- package/bin/build/server/useDDL.js +1 -1
- package/bin/dev/index.js +2 -1
- package/bin/evershop +8 -7
- package/bin/extension/index.js +1 -1
- package/bin/install/index.js +1 -1
- package/bin/lib/addDefaultMiddlewareFuncs.js +2 -2
- package/bin/lib/app.js +1 -1
- package/bin/lib/bootstrap/migrate.js +1 -1
- package/bin/lib/buildEntry.js +1 -1
- package/bin/lib/onError.js +1 -1
- package/bin/lib/onListening.js +1 -1
- package/bin/lib/startUp.js +10 -9
- package/bin/lib/watch/watchComponents.js +16 -26
- package/bin/lib/watch/watchMF.js +1 -1
- package/bin/lib/watch/watchMR.js +1 -1
- package/bin/lib/watch/watchSchema.js +1 -1
- package/bin/user/changePassword.js +1 -1
- package/bin/user/create.js +1 -1
- package/package.json +2 -2
- package/src/components/admin/catalog/productEdit/category/CategoryItem.jsx +1 -1
- package/src/components/admin/catalog/productEdit/category/CategoryTree.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/CreateVariantGroup.jsx +3 -8
- package/src/components/admin/catalog/productEdit/variants/Variant.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/VariantModal.jsx +62 -6
- package/src/components/admin/catalog/productEdit/variants/Variants.jsx +1 -1
- package/src/components/admin/checkout/shippingSetting/Method.jsx +130 -0
- package/src/components/admin/{oms → checkout}/shippingSetting/MethodForm.jsx +124 -13
- package/src/components/admin/{oms → checkout}/shippingSetting/Methods.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx +101 -0
- package/src/components/admin/checkout/shippingSetting/WeightBasedPrice.jsx +101 -0
- package/src/components/admin/{oms → checkout}/shippingSetting/Zone.jsx +34 -4
- package/src/components/admin/{oms → checkout}/shippingSetting/Zones.jsx +6 -3
- package/src/components/admin/promotion/couponEdit/AttributeGroupSelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/CategorySelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/CollectionSelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/ProductSkuSelector.jsx +27 -6
- package/src/components/common/context/checkout.jsx +8 -14
- package/src/components/common/form/Field.jsx +1 -1
- package/src/components/common/form/fields/Input.jsx +2 -1
- package/src/components/common/form/validator.js +6 -2
- package/src/components/common/grid/headers/Dummy.jsx +1 -1
- package/src/components/common/grid/headers/Sortable.jsx +148 -0
- package/src/components/common/grid/rows/StatusRow.jsx +1 -1
- package/src/components/common/list/Filter.jsx +83 -0
- package/src/components/common/list/Filter.scss +39 -0
- package/src/components/frontStore/catalog/categoryView/filter/AttributeFilter.jsx +19 -5
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.jsx +59 -52
- package/src/components/frontStore/catalog/categoryView/filter/PriceFilter.jsx +20 -11
- package/src/components/frontStore/catalog/product/list/SortOptions.jsx +4 -2
- package/src/components/frontStore/catalog/product/list/Sorting.jsx +5 -5
- package/src/components/frontStore/checkout/checkout/payment/paymentStep/StepContent.jsx +9 -6
- package/src/components/frontStore/stripe/checkout/CheckoutForm.jsx +8 -4
- package/src/lib/event/callSubscibers.js +14 -11
- package/src/lib/event/event-manager.js +1 -1
- package/src/lib/event/loadSubscribers.js +2 -2
- package/src/lib/helpers.js +3 -1
- package/src/lib/log/CustomColorize.js +22 -0
- package/src/lib/log/logger.js +153 -19
- package/src/lib/middleware/Handler.js +2 -3
- package/src/lib/middleware/async.js +5 -9
- package/src/lib/middleware/sync.js +5 -10
- package/src/lib/middleware/tests/app/app.js +1 -1
- package/src/lib/router/buildAbsoluteUrl.js +1 -1
- package/src/lib/util/buildFilterFromUrl.js +31 -64
- package/src/lib/util/defaultPaginationFilters.js +102 -0
- package/src/lib/util/filterOperationMapp.js +16 -0
- package/src/lib/util/registry.js +44 -6
- package/src/lib/webpack/dev/createConfigClient.js +2 -0
- package/src/lib/webpack/loaders/AreaLoader.js +1 -1
- package/src/lib/webpack/loaders/loadTranslationFromCsv.js +1 -1
- package/src/lib/webpack/plugins/Tailwindcss.js +1 -1
- package/src/modules/auth/graphql/types/AdminUser/AdminUser.admin.resolvers.js +6 -6
- package/src/modules/auth/pages/admin/adminLogin/LoginForm.jsx +1 -15
- package/src/modules/base/api/global/[apiResponse]apiErrorHandler.js +2 -2
- package/src/modules/base/pages/global/[response]errorHandler.js +2 -2
- package/src/modules/catalog/api/addProductToCategory/addProducts.js +1 -1
- package/src/modules/catalog/api/addProductToCollection/addProducts.js +35 -22
- package/src/modules/catalog/api/removeProductFromCollection/removeProducts.js +20 -5
- package/src/modules/catalog/bootstrap.js +63 -0
- package/src/modules/catalog/graphql/types/Attribute/Attribute.admin.graphql +2 -2
- package/src/modules/catalog/graphql/types/Attribute/Attribute.admin.resolvers.js +48 -276
- package/src/modules/catalog/graphql/types/Category/Category.graphql +15 -2
- package/src/modules/catalog/graphql/types/Category/Category.resolvers.js +2 -2
- package/src/modules/catalog/graphql/types/Collection/Collection.resolvers.js +2 -2
- package/src/modules/catalog/graphql/types/Product/Product.resolvers.js +1 -1
- package/src/modules/catalog/graphql/types/Product/Variant/Variant.graphql +2 -2
- package/src/modules/catalog/graphql/types/Product/Variant/Variant.resolvers.js +68 -92
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/General.jsx +13 -9
- package/src/modules/catalog/pages/admin/attributeGrid/Grid.jsx +82 -39
- package/src/modules/catalog/pages/admin/attributeGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/categoryEdit/Products.jsx +5 -5
- package/src/modules/catalog/pages/admin/categoryGrid/Grid.jsx +48 -16
- package/src/modules/catalog/pages/admin/categoryGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/collectionEdit/Products.jsx +5 -5
- package/src/modules/catalog/pages/admin/collectionGrid/Grid.jsx +46 -5
- package/src/modules/catalog/pages/admin/collectionGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/productEdit+productNew/Attributes.jsx +28 -24
- package/src/modules/catalog/pages/admin/productGrid/Grid.jsx +158 -26
- package/src/modules/catalog/pages/admin/productGrid/index.js +1 -2
- package/src/modules/catalog/pages/frontStore/all/SearchBox.jsx +2 -1
- package/src/modules/catalog/pages/frontStore/catalogSearch/[index]filters.js +4 -59
- package/src/modules/catalog/pages/frontStore/catalogSearch/index.js +11 -0
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.jsx +22 -6
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.scss +2 -0
- package/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js +5 -105
- package/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Form.jsx +8 -3
- package/src/modules/catalog/pages/frontStore/productView/Variants.jsx +102 -40
- package/src/modules/catalog/services/AttributeCollection.js +59 -0
- package/src/modules/catalog/services/AttributeGroupCollection.js +100 -0
- package/src/modules/catalog/services/CategoryCollection.js +27 -84
- package/src/modules/catalog/services/CollectionCollection.js +24 -72
- package/src/modules/catalog/services/ProductCollection.js +50 -216
- package/src/modules/catalog/services/attribute/deleteProductAttribute.js +15 -0
- package/src/modules/catalog/services/getAttributeGroupsBaseQuery.js +3 -0
- package/src/modules/catalog/services/getAttributesBaseQuery.js +3 -0
- package/src/modules/catalog/services/getCollectionsBaseQuery.js +0 -1
- package/src/modules/catalog/services/product/updateProduct.js +8 -2
- package/src/modules/catalog/services/registerDefaultAttributeCollectionFilters.js +149 -0
- package/src/modules/catalog/services/registerDefaultCategoryCollectionFilters.js +85 -0
- package/src/modules/catalog/services/registerDefaultCollectionCollectionFilters.js +65 -0
- package/src/modules/catalog/services/registerDefaultProductCollectionFilters.js +219 -0
- package/src/modules/catalog/subscribers/category_created/buildUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/category_deleted/deleteUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/category_updated/builUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_created/builUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_deleted/deleteUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js +3 -3
- package/src/modules/checkout/api/addCartShippingMethod/saveShippingMethod.js +6 -1
- package/src/modules/checkout/api/createCart/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/createCart/createNewCart.js +92 -0
- package/src/modules/checkout/api/createCart/payloadSchema.json +44 -0
- package/src/modules/checkout/api/createCart/route.json +5 -0
- package/src/modules/checkout/api/deleteShippingZone/deleteShippingZone.js +58 -0
- package/src/modules/checkout/api/deleteShippingZone/route.json +5 -0
- package/src/modules/checkout/api/deleteShippingZoneMethod/deleteShippingZoneMethod.js +85 -0
- package/src/modules/checkout/api/deleteShippingZoneMethod/route.json +5 -0
- package/src/modules/checkout/api/getShippingMethods/sendMethods.js +37 -0
- package/src/modules/checkout/api/updateShippingMethod/[context]borderParser[auth].js +5 -0
- package/src/modules/checkout/api/updateShippingMethod/payloadSchema.json +12 -0
- package/src/modules/checkout/api/updateShippingMethod/route.json +5 -0
- package/src/modules/checkout/api/updateShippingMethod/updateShippingMethod.js +64 -0
- package/src/modules/checkout/api/updateShippingZoneMethod/payloadSchema.json +43 -1
- package/src/modules/checkout/api/updateShippingZoneMethod/updateShippingZoneMethod.js +17 -3
- package/src/modules/checkout/bootstrap.js +1 -1
- package/src/modules/checkout/graphql/types/ShippingMethod/ShippingMethod.graphql +1 -0
- package/src/modules/checkout/graphql/types/ShippingMethod/ShippingMethod.resolvers.js +4 -0
- package/src/modules/checkout/graphql/types/ShippingZone/ShippingZone.graphql +21 -1
- package/src/modules/checkout/graphql/types/ShippingZone/ShippingZone.resolvers.js +34 -4
- package/src/modules/checkout/graphql/types/Weight/Weight.resolvers.js +8 -11
- package/src/modules/checkout/migration/Version-1.0.5.js +28 -0
- package/src/modules/{oms → checkout}/pages/admin/shippingSetting/ShippingSetting.jsx +66 -43
- package/src/modules/checkout/pages/frontStore/all/[auth]addCustomerToCart.js +3 -3
- package/src/modules/checkout/pages/frontStore/checkout/PaymentStep.jsx +3 -2
- package/src/modules/checkout/pages/frontStore/checkout/ShippingMethods.jsx +23 -10
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.jsx +132 -0
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.scss +7 -0
- package/src/modules/checkout/services/cart/Cart.js +23 -7
- package/src/modules/checkout/services/cart/DataObject.js +3 -3
- package/src/modules/checkout/services/cart/registerCartBaseFields.js +32 -0
- package/src/modules/checkout/services/cart/registerCartItemBaseFields.js +3 -2
- package/src/modules/cms/bootstrap.js +17 -0
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.resolvers.js +2 -11
- package/src/modules/cms/pages/admin/all/Layout.scss +3 -2
- package/src/modules/cms/pages/admin/all/SearchBox.jsx +1 -1
- package/src/modules/cms/pages/admin/cmsPageGrid/Grid.jsx +62 -9
- package/src/modules/cms/pages/admin/cmsPageGrid/index.js +1 -2
- package/src/modules/cms/services/CMSPageCollection.js +23 -70
- package/src/modules/cms/services/registerDefaultPageCollectionFilters.js +62 -0
- package/src/modules/cms/services/tailwind.admin.config.js +6 -1
- package/src/modules/customer/api/createCustomer/[bodyParser]createCustomer.js +2 -2
- package/src/modules/customer/api/resetPassword/[bodyParser]resetPassword.js +2 -2
- package/src/modules/customer/api/updatePassword/[bodyParser]updatePassword.js +2 -2
- package/src/modules/customer/bootstrap.js +29 -0
- package/src/modules/customer/graphql/types/Customer/Customer.admin.resolvers.js +2 -4
- package/src/modules/customer/pages/admin/customerGrid/Grid.jsx +108 -14
- package/src/modules/customer/pages/admin/customerGrid/index.js +1 -2
- package/src/modules/customer/pages/frontStore/login/LoginForm.jsx +0 -1
- package/src/modules/customer/services/CustomerCollection.js +23 -104
- package/src/modules/customer/services/CustomerGroupCollection.js +21 -70
- package/src/modules/customer/services/registerDefaultCustomerCollectionFilters.js +90 -0
- package/src/modules/customer/services/registerDefaultCustomerGroupCollectionFilters.js +50 -0
- package/src/modules/graphql/pages/global/[bodyParser]buildQuery[graphql].js +1 -1
- package/src/modules/graphql/pages/global/[buildQuery]graphql[notification].js +1 -1
- package/src/modules/graphql/services/graphqlMiddleware.js +1 -1
- package/src/modules/oms/bootstrap.js +17 -0
- package/src/modules/oms/graphql/types/Order/Order.admin.resolvers.js +1 -1
- package/src/modules/oms/graphql/types/Order/Order.resolvers.js +2 -1
- package/src/modules/oms/pages/admin/orderGrid/Grid.jsx +152 -51
- package/src/modules/oms/pages/admin/orderGrid/index.js +1 -2
- package/src/modules/oms/services/OrderCollection.js +19 -139
- package/src/modules/oms/services/registerDefaultOrderCollectionFilters.js +121 -0
- package/src/modules/promotion/bootstrap.js +16 -0
- package/src/modules/promotion/graphql/types/Coupon/Coupon.admin.resolvers.js +2 -7
- package/src/modules/promotion/pages/admin/couponGrid/Grid.jsx +157 -33
- package/src/modules/promotion/pages/admin/couponGrid/index.js +1 -2
- package/src/modules/promotion/services/CouponCollection.js +21 -130
- package/src/modules/promotion/services/registerDefaultCouponCollectionFilters.js +72 -0
- package/src/modules/stripe/api/stripeWebHook/[bodyJson]webhook.js +4 -2
- package/src/modules/tax/bootstrap.js +17 -0
- package/src/modules/tax/services/TaxClassCollection.js +22 -56
- package/src/modules/tax/services/registerDefaultTaxClassCollectionFilters.js +49 -0
- package/src/components/admin/oms/shippingSetting/Method.jsx +0 -73
- package/src/components/common/grid/headers/Basic.jsx +0 -55
- package/src/lib/log/debuger.js +0 -89
- package/src/modules/customer/pages/frontStore/login/LoginButton.jsx +0 -27
- /package/src/components/admin/{oms → checkout}/shippingSetting/ZoneForm.jsx +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/all/ShippingSettingMenu.jsx +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/shippingSetting/index.js +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/shippingSetting/route.json +0 -0
|
@@ -3,7 +3,7 @@ const {
|
|
|
3
3
|
INTERNAL_SERVER_ERROR
|
|
4
4
|
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
5
5
|
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
6
|
-
const {
|
|
6
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
7
7
|
const createCustomer = require('../../services/customer/createCustomer');
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -36,7 +36,7 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
36
36
|
};
|
|
37
37
|
next();
|
|
38
38
|
} catch (e) {
|
|
39
|
-
|
|
39
|
+
error(e);
|
|
40
40
|
response.status(INTERNAL_SERVER_ERROR);
|
|
41
41
|
response.json({
|
|
42
42
|
error: {
|
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
OK,
|
|
5
5
|
INTERNAL_SERVER_ERROR
|
|
6
6
|
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
7
|
-
const {
|
|
7
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
8
8
|
const crypto = require('crypto');
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -45,7 +45,7 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
45
45
|
// An extension can add a middleware to this route to send email
|
|
46
46
|
next();
|
|
47
47
|
} catch (e) {
|
|
48
|
-
|
|
48
|
+
error(e);
|
|
49
49
|
response.status(INTERNAL_SERVER_ERROR);
|
|
50
50
|
response.json({
|
|
51
51
|
error: {
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
INTERNAL_SERVER_ERROR,
|
|
10
10
|
INVALID_PAYLOAD
|
|
11
11
|
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
12
|
-
const {
|
|
12
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
13
13
|
const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig');
|
|
14
14
|
const updatePassword = require('../../services/customer/updatePassword');
|
|
15
15
|
|
|
@@ -72,7 +72,7 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
72
72
|
response.$body = {};
|
|
73
73
|
next();
|
|
74
74
|
} catch (e) {
|
|
75
|
-
|
|
75
|
+
error(e);
|
|
76
76
|
response.status(INTERNAL_SERVER_ERROR);
|
|
77
77
|
response.json({
|
|
78
78
|
error: {
|
|
@@ -5,6 +5,11 @@ const { select } = require('@evershop/postgres-query-builder');
|
|
|
5
5
|
const { comparePassword } = require('../../lib/util/passwordHelper');
|
|
6
6
|
const { translate } = require('../../lib/locale/translate/translate');
|
|
7
7
|
const { addProcessor } = require('../../lib/util/registry');
|
|
8
|
+
const registerDefaultCustomerCollectionFilters = require('./services/registerDefaultCustomerCollectionFilters');
|
|
9
|
+
const {
|
|
10
|
+
defaultPaginationFilters
|
|
11
|
+
} = require('../../lib/util/defaultPaginationFilters');
|
|
12
|
+
const registerDefaultCustomerGroupCollectionFilters = require('./services/registerDefaultCustomerGroupCollectionFilters');
|
|
8
13
|
|
|
9
14
|
module.exports = () => {
|
|
10
15
|
addProcessor('cartFields', (fields) => {
|
|
@@ -155,4 +160,28 @@ module.exports = () => {
|
|
|
155
160
|
}
|
|
156
161
|
};
|
|
157
162
|
config.util.setModuleDefaults('customer', customerConfig);
|
|
163
|
+
|
|
164
|
+
// Reigtering the default filters for customer collection
|
|
165
|
+
addProcessor(
|
|
166
|
+
'customerCollectionFilters',
|
|
167
|
+
registerDefaultCustomerCollectionFilters,
|
|
168
|
+
1
|
|
169
|
+
);
|
|
170
|
+
addProcessor(
|
|
171
|
+
'customerCollectionFilters',
|
|
172
|
+
(filters) => [...filters, ...defaultPaginationFilters],
|
|
173
|
+
2
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// Reigtering the default filters for customer group collection
|
|
177
|
+
addProcessor(
|
|
178
|
+
'customerGroupCollectionFilters',
|
|
179
|
+
registerDefaultCustomerGroupCollectionFilters,
|
|
180
|
+
1
|
|
181
|
+
);
|
|
182
|
+
addProcessor(
|
|
183
|
+
'customerGroupCollectionFilters',
|
|
184
|
+
(filters) => [...filters, ...defaultPaginationFilters],
|
|
185
|
+
2
|
|
186
|
+
);
|
|
158
187
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { select } = require('@evershop/postgres-query-builder');
|
|
2
1
|
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
3
2
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
4
3
|
const {
|
|
@@ -9,16 +8,15 @@ const { CustomerCollection } = require('../../../services/CustomerCollection');
|
|
|
9
8
|
module.exports = {
|
|
10
9
|
Query: {
|
|
11
10
|
customer: async (root, { id }, { pool }) => {
|
|
12
|
-
const query =
|
|
11
|
+
const query = getCustomersBaseQuery();
|
|
13
12
|
query.where('uuid', '=', id);
|
|
14
|
-
|
|
15
13
|
const customer = await query.load(pool);
|
|
16
14
|
return customer ? camelCase(customer) : null;
|
|
17
15
|
},
|
|
18
16
|
customers: async (_, { filters = [] }) => {
|
|
19
17
|
const query = getCustomersBaseQuery();
|
|
20
18
|
const root = new CustomerCollection(query);
|
|
21
|
-
await root.init(
|
|
19
|
+
await root.init(filters);
|
|
22
20
|
return root;
|
|
23
21
|
}
|
|
24
22
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
3
|
import React, { useState } from 'react';
|
|
3
4
|
import axios from 'axios';
|
|
@@ -7,11 +8,13 @@ import { Checkbox } from '@components/common/form/fields/Checkbox';
|
|
|
7
8
|
import { useAlertContext } from '@components/common/modal/Alert';
|
|
8
9
|
import StatusRow from '@components/common/grid/rows/StatusRow';
|
|
9
10
|
import BasicRow from '@components/common/grid/rows/BasicRow';
|
|
10
|
-
import BasicColumnHeader from '@components/common/grid/headers/Basic';
|
|
11
|
-
import DropdownColumnHeader from '@components/common/grid/headers/Dropdown';
|
|
12
11
|
import { Card } from '@components/admin/cms/Card';
|
|
13
12
|
import CustomerNameRow from '@components/admin/customer/customerGrid/rows/CustomerName';
|
|
14
13
|
import CreateAt from '@components/admin/customer/customerGrid/rows/CreateAt';
|
|
14
|
+
import { Form } from '@components/common/form/Form';
|
|
15
|
+
import { Field } from '@components/common/form/Field';
|
|
16
|
+
import SortableHeader from '@components/common/grid/headers/Sortable';
|
|
17
|
+
import Filter from '@components/common/list/Filter';
|
|
15
18
|
|
|
16
19
|
function Actions({ customers = [], selectedIds = [] }) {
|
|
17
20
|
const { openAlert, closeAlert } = useAlertContext();
|
|
@@ -127,6 +130,101 @@ export default function CustomerGrid({
|
|
|
127
130
|
|
|
128
131
|
return (
|
|
129
132
|
<Card>
|
|
133
|
+
<Card.Session
|
|
134
|
+
title={
|
|
135
|
+
<Form submitBtn={false}>
|
|
136
|
+
<div className="flex gap-2 justify-center items-center">
|
|
137
|
+
<Area
|
|
138
|
+
id="customerGridFilter"
|
|
139
|
+
noOuter
|
|
140
|
+
coreComponents={[
|
|
141
|
+
{
|
|
142
|
+
component: {
|
|
143
|
+
default: () => (
|
|
144
|
+
<Field
|
|
145
|
+
type="text"
|
|
146
|
+
id="keyword"
|
|
147
|
+
placeholder="Search"
|
|
148
|
+
value={
|
|
149
|
+
currentFilters.find((f) => f.key === 'keyword')
|
|
150
|
+
?.value
|
|
151
|
+
}
|
|
152
|
+
onKeyPress={(e) => {
|
|
153
|
+
// If the user press enter, we should submit the form
|
|
154
|
+
if (e.key === 'Enter') {
|
|
155
|
+
const url = new URL(document.location);
|
|
156
|
+
const keyword =
|
|
157
|
+
document.getElementById('keyword')?.value;
|
|
158
|
+
if (keyword) {
|
|
159
|
+
url.searchParams.set('keyword', keyword);
|
|
160
|
+
} else {
|
|
161
|
+
url.searchParams.delete('keyword');
|
|
162
|
+
}
|
|
163
|
+
window.location.href = url;
|
|
164
|
+
}
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
)
|
|
168
|
+
},
|
|
169
|
+
sortOrder: 5
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
component: {
|
|
173
|
+
default: () => (
|
|
174
|
+
<Filter
|
|
175
|
+
options={[
|
|
176
|
+
{
|
|
177
|
+
label: 'Enabled',
|
|
178
|
+
value: '1',
|
|
179
|
+
onSelect: () => {
|
|
180
|
+
const url = new URL(document.location);
|
|
181
|
+
url.searchParams.set('status', 1);
|
|
182
|
+
window.location.href = url;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: 'Disabled',
|
|
187
|
+
value: '0',
|
|
188
|
+
onSelect: () => {
|
|
189
|
+
const url = new URL(document.location);
|
|
190
|
+
url.searchParams.set('status', 0);
|
|
191
|
+
window.location.href = url;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
]}
|
|
195
|
+
selectedOption={
|
|
196
|
+
currentFilters.find((f) => f.key === 'status')
|
|
197
|
+
? currentFilters.find((f) => f.key === 'status')
|
|
198
|
+
.value === '1'
|
|
199
|
+
? 'Enabled'
|
|
200
|
+
: 'Disabled'
|
|
201
|
+
: undefined
|
|
202
|
+
}
|
|
203
|
+
title="Status"
|
|
204
|
+
/>
|
|
205
|
+
)
|
|
206
|
+
},
|
|
207
|
+
sortOrder: 10
|
|
208
|
+
}
|
|
209
|
+
]}
|
|
210
|
+
currentFilters={currentFilters}
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
</Form>
|
|
214
|
+
}
|
|
215
|
+
actions={[
|
|
216
|
+
{
|
|
217
|
+
variant: 'interactive',
|
|
218
|
+
name: 'Clear filter',
|
|
219
|
+
onAction: () => {
|
|
220
|
+
// Just get the url and remove all query params
|
|
221
|
+
const url = new URL(document.location);
|
|
222
|
+
url.search = '';
|
|
223
|
+
window.location.href = url.href;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
]}
|
|
227
|
+
/>
|
|
130
228
|
<table className="listing sticky">
|
|
131
229
|
<thead>
|
|
132
230
|
<tr>
|
|
@@ -147,9 +245,9 @@ export default function CustomerGrid({
|
|
|
147
245
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
148
246
|
component: {
|
|
149
247
|
default: () => (
|
|
150
|
-
<
|
|
248
|
+
<SortableHeader
|
|
151
249
|
title="Full Name"
|
|
152
|
-
|
|
250
|
+
name="full_name"
|
|
153
251
|
currentFilters={currentFilters}
|
|
154
252
|
/>
|
|
155
253
|
)
|
|
@@ -160,9 +258,9 @@ export default function CustomerGrid({
|
|
|
160
258
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
161
259
|
component: {
|
|
162
260
|
default: () => (
|
|
163
|
-
<
|
|
261
|
+
<SortableHeader
|
|
164
262
|
title="Email"
|
|
165
|
-
|
|
263
|
+
email="email"
|
|
166
264
|
currentFilters={currentFilters}
|
|
167
265
|
/>
|
|
168
266
|
)
|
|
@@ -173,14 +271,10 @@ export default function CustomerGrid({
|
|
|
173
271
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
174
272
|
component: {
|
|
175
273
|
default: () => (
|
|
176
|
-
<
|
|
274
|
+
<SortableHeader
|
|
177
275
|
title="Status"
|
|
178
|
-
|
|
276
|
+
name="status"
|
|
179
277
|
currentFilters={currentFilters}
|
|
180
|
-
options={[
|
|
181
|
-
{ value: 1, text: 'Enabled' },
|
|
182
|
-
{ value: 0, text: 'Disabled' }
|
|
183
|
-
]}
|
|
184
278
|
/>
|
|
185
279
|
)
|
|
186
280
|
},
|
|
@@ -190,9 +284,9 @@ export default function CustomerGrid({
|
|
|
190
284
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
191
285
|
component: {
|
|
192
286
|
default: () => (
|
|
193
|
-
<
|
|
287
|
+
<SortableHeader
|
|
194
288
|
title="Created At"
|
|
195
|
-
|
|
289
|
+
name="created_at"
|
|
196
290
|
currentFilters={currentFilters}
|
|
197
291
|
/>
|
|
198
292
|
)
|
|
@@ -11,6 +11,5 @@ module.exports = (request, response) => {
|
|
|
11
11
|
title: 'Customers',
|
|
12
12
|
description: 'Customers'
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
setContextValue(request, 'filtersFromUrl', buildFilterFromUrl(query));
|
|
14
|
+
setContextValue(request, 'filtersFromUrl', buildFilterFromUrl(request));
|
|
16
15
|
};
|
|
@@ -1,123 +1,42 @@
|
|
|
1
1
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
2
2
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
|
+
const { getValue } = require('@evershop/evershop/src/lib/util/registry');
|
|
3
4
|
|
|
4
5
|
class CustomerCollection {
|
|
5
6
|
constructor(baseQuery) {
|
|
6
7
|
this.baseQuery = baseQuery;
|
|
8
|
+
this.baseQuery.orderBy('customer.customer_id', 'DESC');
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
async init(
|
|
11
|
+
async init(filters = []) {
|
|
10
12
|
const currentFilters = [];
|
|
11
13
|
|
|
12
|
-
//
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'ILIKE',
|
|
18
|
-
`%${nameFilter.value}%`
|
|
19
|
-
);
|
|
20
|
-
currentFilters.push({
|
|
21
|
-
key: 'full_name',
|
|
22
|
-
operation: '=',
|
|
23
|
-
value: nameFilter.value
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Email filter
|
|
28
|
-
const emailFilter = filters.find((f) => f.key === 'email');
|
|
29
|
-
if (emailFilter) {
|
|
30
|
-
this.baseQuery.andWhere(
|
|
31
|
-
'customer.email',
|
|
32
|
-
'ILIKE',
|
|
33
|
-
`%${emailFilter.value}%`
|
|
34
|
-
);
|
|
35
|
-
currentFilters.push({
|
|
36
|
-
key: 'email',
|
|
37
|
-
operation: '=',
|
|
38
|
-
value: emailFilter.value
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Keyword search
|
|
43
|
-
const keywordFilter = filters.find((f) => f.key === 'keyword');
|
|
44
|
-
if (keywordFilter) {
|
|
45
|
-
this.baseQuery
|
|
46
|
-
.andWhere('customer.full_name', 'ILIKE', `%${keywordFilter.value}%`)
|
|
47
|
-
.or('customer.email', 'ILIKE', `%${keywordFilter.value}%`);
|
|
48
|
-
currentFilters.push({
|
|
49
|
-
key: 'keyword',
|
|
50
|
-
operation: '=',
|
|
51
|
-
value: keywordFilter.value
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Status filter
|
|
56
|
-
const statusFilter = filters.find((f) => f.key === 'status');
|
|
57
|
-
if (statusFilter) {
|
|
58
|
-
this.baseQuery.andWhere('customer.status', '=', statusFilter.value);
|
|
59
|
-
currentFilters.push({
|
|
60
|
-
key: 'status',
|
|
61
|
-
operation: '=',
|
|
62
|
-
value: statusFilter.value
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const sortBy = filters.find((f) => f.key === 'sortBy');
|
|
67
|
-
const sortOrder = filters.find(
|
|
68
|
-
(f) =>
|
|
69
|
-
f.key === 'sortOrder' &&
|
|
70
|
-
['ASC', 'DESC', 'asc', 'desc'].includes(f.value)
|
|
71
|
-
) || { value: 'DESC' };
|
|
14
|
+
// Apply the filters
|
|
15
|
+
const customerCollectionFilters = await getValue(
|
|
16
|
+
'customerCollectionFilters',
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
72
19
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
88
|
-
this.baseQuery.orderBy('customer.customer_id', 'DESC');
|
|
89
|
-
}
|
|
90
|
-
if (sortOrder.key) {
|
|
91
|
-
currentFilters.push({
|
|
92
|
-
key: 'sortOrder',
|
|
93
|
-
operation: '=',
|
|
94
|
-
value: sortOrder.value
|
|
95
|
-
});
|
|
96
|
-
}
|
|
20
|
+
customerCollectionFilters.forEach((filter) => {
|
|
21
|
+
const check = filters.find((f) => f.key === filter.key);
|
|
22
|
+
if (check) {
|
|
23
|
+
if (filter.operation.includes(check.operation)) {
|
|
24
|
+
filter.callback(
|
|
25
|
+
this.baseQuery,
|
|
26
|
+
check.operation,
|
|
27
|
+
check.value,
|
|
28
|
+
currentFilters
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
97
33
|
|
|
98
34
|
// Clone the main query for getting total right before doing the paging
|
|
99
35
|
const totalQuery = this.baseQuery.clone();
|
|
100
36
|
totalQuery.select('COUNT(customer.customer_id)', 'total');
|
|
101
37
|
totalQuery.removeOrderBy();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const limit = filters.find((f) => f.key === 'limit' && f.value > 0) || {
|
|
105
|
-
value: 20
|
|
106
|
-
}; // TODO: Get from the config
|
|
107
|
-
currentFilters.push({
|
|
108
|
-
key: 'page',
|
|
109
|
-
operation: '=',
|
|
110
|
-
value: page.value
|
|
111
|
-
});
|
|
112
|
-
currentFilters.push({
|
|
113
|
-
key: 'limit',
|
|
114
|
-
operation: '=',
|
|
115
|
-
value: limit.value
|
|
116
|
-
});
|
|
117
|
-
this.baseQuery.limit(
|
|
118
|
-
(page.value - 1) * parseInt(limit.value, 10),
|
|
119
|
-
parseInt(limit.value, 10)
|
|
120
|
-
);
|
|
38
|
+
totalQuery.removeLimit();
|
|
39
|
+
|
|
121
40
|
this.currentFilters = currentFilters;
|
|
122
41
|
this.totalQuery = totalQuery;
|
|
123
42
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
2
2
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
|
+
const { getValue } = require('@evershop/evershop/src/lib/util/registry');
|
|
3
4
|
|
|
4
5
|
class CustomerGroupCollection {
|
|
5
6
|
constructor(baseQuery) {
|
|
@@ -9,82 +10,32 @@ class CustomerGroupCollection {
|
|
|
9
10
|
async init(args, { filters = [] }) {
|
|
10
11
|
const currentFilters = [];
|
|
11
12
|
|
|
12
|
-
//
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'ILIKE',
|
|
18
|
-
`%${nameFilter.value}%`
|
|
19
|
-
);
|
|
20
|
-
currentFilters.push({
|
|
21
|
-
key: 'group_name',
|
|
22
|
-
operation: '=',
|
|
23
|
-
value: nameFilter.value
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Keyword search
|
|
28
|
-
const keywordFilter = filters.find((f) => f.key === 'keyword');
|
|
29
|
-
if (keywordFilter) {
|
|
30
|
-
this.baseQuery.andWhere(
|
|
31
|
-
'customer_group.group_name',
|
|
32
|
-
'ILIKE',
|
|
33
|
-
`%${keywordFilter.value}%`
|
|
34
|
-
);
|
|
35
|
-
currentFilters.push({
|
|
36
|
-
key: 'keyword',
|
|
37
|
-
operation: '=',
|
|
38
|
-
value: keywordFilter.value
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const sortBy = filters.find((f) => f.key === 'sortBy');
|
|
43
|
-
const sortOrder = filters.find(
|
|
44
|
-
(f) =>
|
|
45
|
-
f.key === 'sortOrder' &&
|
|
46
|
-
['ASC', 'DESC', 'asc', 'desc'].includes(f.value)
|
|
47
|
-
) || { value: 'DESC' };
|
|
13
|
+
// Apply the filters
|
|
14
|
+
const customerGroupCollectionFilters = await getValue(
|
|
15
|
+
'customerGroupCollectionFilters',
|
|
16
|
+
[]
|
|
17
|
+
);
|
|
48
18
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
operation: '=',
|
|
63
|
-
value: sortOrder.value
|
|
64
|
-
});
|
|
65
|
-
}
|
|
19
|
+
customerGroupCollectionFilters.forEach((filter) => {
|
|
20
|
+
const check = filters.find((f) => f.key === filter.key);
|
|
21
|
+
if (check) {
|
|
22
|
+
if (filter.operation.includes(check.operation)) {
|
|
23
|
+
filter.callback(
|
|
24
|
+
this.baseQuery,
|
|
25
|
+
check.operation,
|
|
26
|
+
check.value,
|
|
27
|
+
currentFilters
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
66
32
|
|
|
67
33
|
// Clone the main query for getting total right before doing the paging
|
|
68
34
|
const totalQuery = this.baseQuery.clone();
|
|
69
35
|
totalQuery.select('COUNT(*)', 'total');
|
|
70
36
|
totalQuery.removeOrderBy();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const limit = filters.find((f) => f.key === 'limit') || { value: 20 }; // TODO: Get from the config
|
|
74
|
-
currentFilters.push({
|
|
75
|
-
key: 'page',
|
|
76
|
-
operation: '=',
|
|
77
|
-
value: page.value
|
|
78
|
-
});
|
|
79
|
-
currentFilters.push({
|
|
80
|
-
key: 'limit',
|
|
81
|
-
operation: '=',
|
|
82
|
-
value: limit.value
|
|
83
|
-
});
|
|
84
|
-
this.baseQuery.limit(
|
|
85
|
-
(page.value - 1) * parseInt(limit.value, 10),
|
|
86
|
-
parseInt(limit.value, 10)
|
|
87
|
-
);
|
|
37
|
+
totalQuery.removeLimit();
|
|
38
|
+
|
|
88
39
|
this.currentFilters = currentFilters;
|
|
89
40
|
this.totalQuery = totalQuery;
|
|
90
41
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const {
|
|
2
|
+
OPERATION_MAP
|
|
3
|
+
} = require('@evershop/evershop/src/lib/util/filterOperationMapp');
|
|
4
|
+
const { getValueSync } = require('@evershop/evershop/src/lib/util/registry');
|
|
5
|
+
|
|
6
|
+
module.exports = async function registerDefaultCustomerCollectionFilters() {
|
|
7
|
+
// List of default supported filters
|
|
8
|
+
const defaultFilters = [
|
|
9
|
+
{
|
|
10
|
+
key: 'keyword',
|
|
11
|
+
operation: ['eq'],
|
|
12
|
+
callback: (query, operation, value, currentFilters) => {
|
|
13
|
+
query
|
|
14
|
+
.andWhere('customer.full_name', 'ILIKE', `%${value}%`)
|
|
15
|
+
.or('customer.email', 'ILIKE', `%${value}%`);
|
|
16
|
+
currentFilters.push({
|
|
17
|
+
key: 'keyword',
|
|
18
|
+
operation,
|
|
19
|
+
value
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 'full_name',
|
|
25
|
+
operation: ['like', 'nlike'],
|
|
26
|
+
callback: (query, operation, value, currentFilters) => {
|
|
27
|
+
query.andWhere(
|
|
28
|
+
'customer.full_name',
|
|
29
|
+
OPERATION_MAP[operation],
|
|
30
|
+
`%${value}%`
|
|
31
|
+
);
|
|
32
|
+
currentFilters.push({
|
|
33
|
+
key: 'full_name',
|
|
34
|
+
operation,
|
|
35
|
+
value
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: 'email',
|
|
41
|
+
operation: ['eq', 'like', 'nlike'],
|
|
42
|
+
callback: (query, operation, value, currentFilters) => {
|
|
43
|
+
query.andWhere('customer.email', OPERATION_MAP[operation], value);
|
|
44
|
+
currentFilters.push({
|
|
45
|
+
key: 'email',
|
|
46
|
+
operation,
|
|
47
|
+
value
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'status',
|
|
53
|
+
operation: ['eq'],
|
|
54
|
+
callback: (query, operation, value, currentFilters) => {
|
|
55
|
+
query.andWhere('customer.status', OPERATION_MAP[operation], value);
|
|
56
|
+
currentFilters.push({
|
|
57
|
+
key: 'status',
|
|
58
|
+
operation,
|
|
59
|
+
value
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: 'ob',
|
|
65
|
+
operation: ['eq'],
|
|
66
|
+
callback: (query, operation, value, currentFilters) => {
|
|
67
|
+
const customerCollectionSortBy = getValueSync(
|
|
68
|
+
'customerCollectionSortBy',
|
|
69
|
+
{
|
|
70
|
+
email: (query) => query.orderBy('customer.email'),
|
|
71
|
+
name: (query) => query.orderBy('customer.full_name'),
|
|
72
|
+
status: (query) => query.orderBy('customer.status'),
|
|
73
|
+
created_at: (query) => query.orderBy('customer.created_at')
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (customerCollectionSortBy[value]) {
|
|
78
|
+
customerCollectionSortBy[value](query, operation);
|
|
79
|
+
currentFilters.push({
|
|
80
|
+
key: 'ob',
|
|
81
|
+
operation,
|
|
82
|
+
value
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
return defaultFilters;
|
|
90
|
+
};
|