@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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
const {
|
|
3
|
+
rollback,
|
|
4
|
+
commit,
|
|
5
|
+
startTransaction,
|
|
6
|
+
select,
|
|
7
|
+
update
|
|
8
|
+
} = require('@evershop/postgres-query-builder');
|
|
9
|
+
const {
|
|
10
|
+
getConnection
|
|
11
|
+
} = require('@evershop/evershop/src/lib/postgres/connection');
|
|
12
|
+
const {
|
|
13
|
+
OK,
|
|
14
|
+
INTERNAL_SERVER_ERROR,
|
|
15
|
+
INVALID_PAYLOAD
|
|
16
|
+
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
17
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
module.exports = async (request, response, deledate, next) => {
|
|
21
|
+
const connection = await getConnection();
|
|
22
|
+
await startTransaction(connection);
|
|
23
|
+
const { name } = request.body;
|
|
24
|
+
const { id } = request.params;
|
|
25
|
+
try {
|
|
26
|
+
const method = await select()
|
|
27
|
+
.from('shipping_method')
|
|
28
|
+
.where('uuid', '=', id)
|
|
29
|
+
.load(connection);
|
|
30
|
+
|
|
31
|
+
if (!method) {
|
|
32
|
+
response.status(INVALID_PAYLOAD);
|
|
33
|
+
response.json({
|
|
34
|
+
error: {
|
|
35
|
+
status: INVALID_PAYLOAD,
|
|
36
|
+
message: 'Requested method not found'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const newMethod = await update('shipping_method')
|
|
43
|
+
.given({
|
|
44
|
+
name
|
|
45
|
+
})
|
|
46
|
+
.where('uuid', '=', id)
|
|
47
|
+
.execute(connection);
|
|
48
|
+
await commit(connection);
|
|
49
|
+
response.status(OK);
|
|
50
|
+
response.json({
|
|
51
|
+
data: newMethod
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
error(e);
|
|
55
|
+
await rollback(connection);
|
|
56
|
+
response.status(INTERNAL_SERVER_ERROR);
|
|
57
|
+
response.json({
|
|
58
|
+
error: {
|
|
59
|
+
status: INTERNAL_SERVER_ERROR,
|
|
60
|
+
message: e.message
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -11,7 +11,49 @@
|
|
|
11
11
|
},
|
|
12
12
|
"calculation_type": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"enum": ["flat_rate", "api"]
|
|
14
|
+
"enum": ["flat_rate", "price_based_rate", "weight_based_rate", "api"]
|
|
15
|
+
},
|
|
16
|
+
"price_based_cost": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"min_price": {
|
|
22
|
+
"type": ["string", "number"],
|
|
23
|
+
"pattern": "^\\d+(\\.\\d{1,2})?$"
|
|
24
|
+
},
|
|
25
|
+
"cost": {
|
|
26
|
+
"type": ["string", "number"],
|
|
27
|
+
"pattern": "^\\d+(\\.\\d{1,2})?$"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"required": [
|
|
32
|
+
"min_price",
|
|
33
|
+
"cost"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"weight_based_cost": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"min_weight": {
|
|
43
|
+
"type": ["string", "number"],
|
|
44
|
+
"pattern": "^\\d+(\\.\\d{1,2})?$"
|
|
45
|
+
},
|
|
46
|
+
"cost": {
|
|
47
|
+
"type": ["string", "number"],
|
|
48
|
+
"pattern": "^\\d+(\\.\\d{1,2})?$"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"additionalProperties": false,
|
|
52
|
+
"required": [
|
|
53
|
+
"min_weight",
|
|
54
|
+
"cost"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
15
57
|
},
|
|
16
58
|
"condition_type": {
|
|
17
59
|
"type": "string",
|
|
@@ -20,7 +20,15 @@ module.exports = async (request, response, deledate, next) => {
|
|
|
20
20
|
const { method_id, zone_id } = request.params;
|
|
21
21
|
const connection = await getConnection();
|
|
22
22
|
await startTransaction(connection);
|
|
23
|
-
let {
|
|
23
|
+
let {
|
|
24
|
+
cost,
|
|
25
|
+
condition_type,
|
|
26
|
+
calculate_api,
|
|
27
|
+
price_based_cost,
|
|
28
|
+
weight_based_cost,
|
|
29
|
+
min,
|
|
30
|
+
max
|
|
31
|
+
} = request.body;
|
|
24
32
|
const { is_enabled, calculation_type } = request.body;
|
|
25
33
|
try {
|
|
26
34
|
// Load the shipping zone
|
|
@@ -65,9 +73,13 @@ module.exports = async (request, response, deledate, next) => {
|
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
if (calculation_type === 'api') {
|
|
68
|
-
cost = null;
|
|
76
|
+
cost = weight_based_cost = price_based_cost = null;
|
|
77
|
+
} else if (calculation_type === 'price_based_rate') {
|
|
78
|
+
calculate_api = cost = weight_based_cost = null;
|
|
79
|
+
} else if (calculation_type === 'weight_based_rate') {
|
|
80
|
+
calculate_api = cost = price_based_cost = null;
|
|
69
81
|
} else {
|
|
70
|
-
calculate_api = null;
|
|
82
|
+
calculate_api = weight_based_cost = price_based_cost = null;
|
|
71
83
|
}
|
|
72
84
|
if (condition_type === 'none') {
|
|
73
85
|
condition_type = null;
|
|
@@ -80,6 +92,8 @@ module.exports = async (request, response, deledate, next) => {
|
|
|
80
92
|
is_enabled,
|
|
81
93
|
calculate_api,
|
|
82
94
|
condition_type,
|
|
95
|
+
price_based_cost,
|
|
96
|
+
weight_based_cost,
|
|
83
97
|
max,
|
|
84
98
|
min
|
|
85
99
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { select } = require('@evershop/postgres-query-builder');
|
|
2
2
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
3
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
4
|
+
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
Query: {
|
|
@@ -11,5 +12,8 @@ module.exports = {
|
|
|
11
12
|
.execute(pool);
|
|
12
13
|
return shippingMethods.map((row) => camelCase(row));
|
|
13
14
|
}
|
|
15
|
+
},
|
|
16
|
+
ShippingMethod: {
|
|
17
|
+
updateApi: ({ uuid }) => buildUrl('updateShippingMethod', { id: uuid })
|
|
14
18
|
}
|
|
15
19
|
};
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Represents a price based cost
|
|
3
|
+
"""
|
|
4
|
+
type PriceBasedCostItem {
|
|
5
|
+
minPrice: Price!
|
|
6
|
+
cost: Price!
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
Represents a weight based cost
|
|
11
|
+
"""
|
|
12
|
+
type WeightBasedCostItem {
|
|
13
|
+
minWeight: Price!
|
|
14
|
+
cost: Price!
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
"""
|
|
2
18
|
Represents a shipping method.
|
|
3
19
|
"""
|
|
@@ -7,12 +23,15 @@ type ShippingMethodByZone {
|
|
|
7
23
|
uuid: String!
|
|
8
24
|
name: String!
|
|
9
25
|
cost: Price
|
|
26
|
+
priceBasedCost: [PriceBasedCostItem]
|
|
27
|
+
weightBasedCost: [WeightBasedCostItem]
|
|
10
28
|
isEnabled: Boolean!
|
|
11
29
|
calculateApi: String
|
|
12
30
|
conditionType: String
|
|
13
31
|
max: Float
|
|
14
32
|
min: Float
|
|
15
33
|
updateApi: String!
|
|
34
|
+
deleteApi: String!
|
|
16
35
|
}
|
|
17
36
|
|
|
18
37
|
"""
|
|
@@ -22,10 +41,11 @@ type ShippingZone {
|
|
|
22
41
|
shipping_zone_id: Int!
|
|
23
42
|
uuid: String!
|
|
24
43
|
name: String!
|
|
25
|
-
country: Country
|
|
44
|
+
country: Country
|
|
26
45
|
provinces: [Province]
|
|
27
46
|
methods: [ShippingMethodByZone]
|
|
28
47
|
updateApi: String!
|
|
48
|
+
deleteApi: String!
|
|
29
49
|
addMethodApi: String!
|
|
30
50
|
removeMethodApi: String!
|
|
31
51
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { select } = require('@evershop/postgres-query-builder');
|
|
2
|
+
const { contries } = require('@evershop/evershop/src/lib/locale/countries');
|
|
2
3
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
4
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
4
5
|
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
@@ -36,6 +37,18 @@ module.exports = {
|
|
|
36
37
|
const methods = await query.execute(pool);
|
|
37
38
|
return methods.map((row) => camelCase(row));
|
|
38
39
|
},
|
|
40
|
+
country: ({ country }) => {
|
|
41
|
+
if (!country) {
|
|
42
|
+
return null;
|
|
43
|
+
} else {
|
|
44
|
+
const c = contries.find((p) => p.code === country);
|
|
45
|
+
if (c) {
|
|
46
|
+
return c;
|
|
47
|
+
} else {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
39
52
|
provinces: async ({ shippingZoneId }) => {
|
|
40
53
|
const provinces = await select('province')
|
|
41
54
|
.from('shipping_zone_province')
|
|
@@ -43,10 +56,10 @@ module.exports = {
|
|
|
43
56
|
.execute(pool);
|
|
44
57
|
return provinces.map((row) => row.province);
|
|
45
58
|
},
|
|
46
|
-
updateApi:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
removeMethodApi:
|
|
59
|
+
updateApi: ({ uuid }) => buildUrl('updateShippingZone', { id: uuid }),
|
|
60
|
+
deleteApi: ({ uuid }) => buildUrl('deleteShippingZone', { id: uuid }),
|
|
61
|
+
addMethodApi: ({ uuid }) => buildUrl('addShippingZoneMethod', { id: uuid }),
|
|
62
|
+
removeMethodApi: ({ uuid }) =>
|
|
50
63
|
buildUrl('removeShippingZoneMethod', { id: uuid })
|
|
51
64
|
},
|
|
52
65
|
ShippingMethodByZone: {
|
|
@@ -60,6 +73,23 @@ module.exports = {
|
|
|
60
73
|
zone_id: zone.uuid,
|
|
61
74
|
method_id: uuid
|
|
62
75
|
});
|
|
76
|
+
},
|
|
77
|
+
deleteApi: async ({ uuid, zoneId }) => {
|
|
78
|
+
const zone = await select()
|
|
79
|
+
.from('shipping_zone')
|
|
80
|
+
.where('shipping_zone_id', '=', zoneId)
|
|
81
|
+
.load(pool);
|
|
82
|
+
|
|
83
|
+
return buildUrl('deleteShippingZoneMethod', {
|
|
84
|
+
zone_id: zone.uuid,
|
|
85
|
+
method_id: uuid
|
|
86
|
+
});
|
|
63
87
|
}
|
|
88
|
+
},
|
|
89
|
+
WeightBasedCostItem: {
|
|
90
|
+
minWeight: ({ min_weight }) => min_weight
|
|
91
|
+
},
|
|
92
|
+
PriceBasedCostItem: {
|
|
93
|
+
minPrice: ({ min_price }) => min_price
|
|
64
94
|
}
|
|
65
95
|
};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig');
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
Weight: {
|
|
5
|
-
value: (raw) => parseFloat(raw),
|
|
6
|
-
unit:
|
|
7
|
-
const unit =
|
|
5
|
+
value: (raw) => parseFloat(raw),
|
|
6
|
+
unit: () => {
|
|
7
|
+
const unit = getConfig('shop.weightUnit', 'kg');
|
|
8
8
|
return unit;
|
|
9
9
|
},
|
|
10
|
-
text:
|
|
11
|
-
const weight = parseFloat(raw);
|
|
12
|
-
const unit =
|
|
13
|
-
const language = await getSetting('storeLanguage', 'en');
|
|
10
|
+
text: (raw) => {
|
|
11
|
+
const weight = parseFloat(raw);
|
|
12
|
+
const unit = getConfig('shop.weightUnit', 'kg');
|
|
14
13
|
// Localize the weight
|
|
15
|
-
return
|
|
16
|
-
weight
|
|
17
|
-
);
|
|
14
|
+
return `${weight} ${unit}`;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { execute } = require('@evershop/postgres-query-builder');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-multi-assign
|
|
4
|
+
module.exports = exports = async (connection) => {
|
|
5
|
+
// Add a column 'price_based_cost' to the method table if it does not exist
|
|
6
|
+
await execute(
|
|
7
|
+
connection,
|
|
8
|
+
`ALTER TABLE "shipping_zone_method" ADD COLUMN "price_based_cost" jsonb`
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
// Add a column 'price_based_cost' to the method table if it does not exist
|
|
12
|
+
await execute(
|
|
13
|
+
connection,
|
|
14
|
+
`ALTER TABLE "shipping_zone_method" ADD COLUMN "weight_based_cost" jsonb`
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// Delete the constraint 'CONDITION_TYPE_MUST_BE_PRICE_OR_WEIGHT' from the method table
|
|
18
|
+
await execute(
|
|
19
|
+
connection,
|
|
20
|
+
`ALTER TABLE "shipping_zone_method" DROP CONSTRAINT "CONDITION_TYPE_MUST_BE_PRICE_OR_WEIGHT"`
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Delete the constraint 'CONDITION_TYPE_MUST_BE_PRICE_OR_WEIGHT' from the method table
|
|
24
|
+
await execute(
|
|
25
|
+
connection,
|
|
26
|
+
`ALTER TABLE "shipping_zone_method" DROP CONSTRAINT "CALCULATE API MUST BE PROVIDE IF COST IS NULL"`
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -5,9 +5,9 @@ import { Card } from '@components/admin/cms/Card';
|
|
|
5
5
|
import SettingMenu from '@components/admin/setting/SettingMenu';
|
|
6
6
|
import Button from '@components/common/form/Button';
|
|
7
7
|
import { useModal } from '@components/common/modal/useModal';
|
|
8
|
-
import ZoneForm from '@components/admin/
|
|
8
|
+
import ZoneForm from '@components/admin/checkout/shippingSetting/ZoneForm';
|
|
9
9
|
import Spinner from '@components/common/Spinner';
|
|
10
|
-
import { Zones } from '@components/admin/
|
|
10
|
+
import { Zones } from '@components/admin/checkout/shippingSetting/Zones';
|
|
11
11
|
|
|
12
12
|
const CountriesQuery = `
|
|
13
13
|
query Country($countries: [String]) {
|
|
@@ -43,14 +43,36 @@ const ZonesQuery = `
|
|
|
43
43
|
text
|
|
44
44
|
value
|
|
45
45
|
}
|
|
46
|
+
priceBasedCost {
|
|
47
|
+
minPrice {
|
|
48
|
+
value
|
|
49
|
+
text
|
|
50
|
+
}
|
|
51
|
+
cost {
|
|
52
|
+
value
|
|
53
|
+
text
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
weightBasedCost {
|
|
57
|
+
minWeight {
|
|
58
|
+
value
|
|
59
|
+
text
|
|
60
|
+
}
|
|
61
|
+
cost {
|
|
62
|
+
value
|
|
63
|
+
text
|
|
64
|
+
}
|
|
65
|
+
}
|
|
46
66
|
isEnabled
|
|
47
67
|
conditionType
|
|
48
68
|
calculateApi
|
|
49
69
|
max
|
|
50
70
|
min
|
|
51
71
|
updateApi
|
|
72
|
+
deleteApi
|
|
52
73
|
}
|
|
53
74
|
updateApi
|
|
75
|
+
deleteApi
|
|
54
76
|
addMethodApi
|
|
55
77
|
}
|
|
56
78
|
}
|
|
@@ -66,14 +88,6 @@ export default function ShippingSetting({ createShippingZoneApi }) {
|
|
|
66
88
|
query: ZonesQuery
|
|
67
89
|
});
|
|
68
90
|
|
|
69
|
-
if (countriesQueryData.fetching || zonesQueryData.fetching) {
|
|
70
|
-
return (
|
|
71
|
-
<div className="flex justify-center">
|
|
72
|
-
<Spinner />
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
91
|
return (
|
|
78
92
|
<div className="main-content-inner">
|
|
79
93
|
<div className="grid grid-cols-6 gap-x-2 grid-flow-row ">
|
|
@@ -81,27 +95,52 @@ export default function ShippingSetting({ createShippingZoneApi }) {
|
|
|
81
95
|
<SettingMenu />
|
|
82
96
|
</div>
|
|
83
97
|
<div className="col-span-4">
|
|
84
|
-
|
|
98
|
+
{countriesQueryData.fetching || zonesQueryData.fetching ? (
|
|
85
99
|
<Card.Session title="Shipping">
|
|
86
|
-
<div>
|
|
87
|
-
|
|
100
|
+
<div className="flex justify-center p-2">
|
|
101
|
+
<Spinner width={25} height={25} />
|
|
88
102
|
</div>
|
|
89
103
|
</Card.Session>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
) : (
|
|
105
|
+
<Card>
|
|
106
|
+
<Card.Session title="Shipping">
|
|
107
|
+
<div>
|
|
108
|
+
Choose where you ship and how much you charge for shipping.
|
|
109
|
+
</div>
|
|
110
|
+
</Card.Session>
|
|
111
|
+
{zonesQueryData.error ? (
|
|
112
|
+
<Card.Session>
|
|
113
|
+
<div>
|
|
114
|
+
<p className="text-critical">
|
|
115
|
+
{zonesQueryData.error.message}
|
|
116
|
+
</p>
|
|
117
|
+
</div>
|
|
118
|
+
</Card.Session>
|
|
119
|
+
) : (
|
|
120
|
+
<Zones
|
|
121
|
+
zones={zonesQueryData.data.shippingZones}
|
|
122
|
+
countries={countriesQueryData.data.countries}
|
|
123
|
+
getZones={() => {
|
|
124
|
+
reexecuteQuery(
|
|
125
|
+
{
|
|
126
|
+
requestPolicy: 'network-only'
|
|
127
|
+
},
|
|
128
|
+
false
|
|
129
|
+
);
|
|
130
|
+
}}
|
|
101
131
|
/>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
132
|
+
)}
|
|
133
|
+
<Card.Session>
|
|
134
|
+
<div>
|
|
135
|
+
<Button
|
|
136
|
+
title="Create new shipping zone"
|
|
137
|
+
variant="primary"
|
|
138
|
+
onAction={() => modal.openModal()}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
</Card.Session>
|
|
142
|
+
</Card>
|
|
143
|
+
)}
|
|
105
144
|
</div>
|
|
106
145
|
</div>
|
|
107
146
|
{modal.state.showing && (
|
|
@@ -144,21 +183,5 @@ export const layout = {
|
|
|
144
183
|
export const query = `
|
|
145
184
|
query Query {
|
|
146
185
|
createShippingZoneApi: url(routeId: "createShippingZone")
|
|
147
|
-
shippingZones {
|
|
148
|
-
uuid
|
|
149
|
-
name
|
|
150
|
-
country {
|
|
151
|
-
name
|
|
152
|
-
code
|
|
153
|
-
}
|
|
154
|
-
provinces {
|
|
155
|
-
name
|
|
156
|
-
code
|
|
157
|
-
}
|
|
158
|
-
methods {
|
|
159
|
-
uuid
|
|
160
|
-
name
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
186
|
}
|
|
164
187
|
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { select, update } = require('@evershop/postgres-query-builder');
|
|
2
2
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
|
-
const {
|
|
3
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
4
4
|
|
|
5
5
|
module.exports = async (request, response, delegate, next) => {
|
|
6
6
|
try {
|
|
@@ -25,8 +25,8 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
25
25
|
.execute(pool);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
28
|
+
} catch (e) {
|
|
29
|
+
error(e);
|
|
30
30
|
}
|
|
31
31
|
next();
|
|
32
32
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useCheckoutStepsDispatch
|
|
6
6
|
} from '@components/common/context/checkoutSteps';
|
|
7
7
|
import { StepContent } from '@components/frontStore/checkout/checkout/payment/paymentStep/StepContent';
|
|
8
|
+
import { _ } from '@evershop/evershop/src/lib/locale/translate';
|
|
8
9
|
|
|
9
10
|
export default function PaymentStep({ cart }) {
|
|
10
11
|
const steps = useCheckoutSteps();
|
|
@@ -15,8 +16,8 @@ export default function PaymentStep({ cart }) {
|
|
|
15
16
|
React.useEffect(() => {
|
|
16
17
|
addStep({
|
|
17
18
|
id: 'payment',
|
|
18
|
-
title: 'Payment',
|
|
19
|
-
previewTitle: 'Payment',
|
|
19
|
+
title: _('Payment'),
|
|
20
|
+
previewTitle: _('Payment'),
|
|
20
21
|
isCompleted: false,
|
|
21
22
|
sortOrder: 15,
|
|
22
23
|
editable: true
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import { toast } from 'react-toastify';
|
|
4
5
|
import { useClient } from 'urql';
|
|
5
6
|
import { useFormContext } from '@components/common/form/Form';
|
|
6
7
|
import { Field } from '@components/common/form/Field';
|
|
@@ -105,17 +106,29 @@ export default function ShippingMethods({
|
|
|
105
106
|
async function saveMethods() {
|
|
106
107
|
// Get the selected method
|
|
107
108
|
const selectedMethod = methods.find((m) => m.selected === true);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
try {
|
|
110
|
+
const response = await axios.post(
|
|
111
|
+
addShippingMethodApi,
|
|
112
|
+
{
|
|
113
|
+
method_code: selectedMethod.code,
|
|
114
|
+
method_name: selectedMethod.name
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
validateStatus: () => true
|
|
118
|
+
}
|
|
118
119
|
);
|
|
120
|
+
if (!response.data.error) {
|
|
121
|
+
const result = await client.query(QUERY, { cartId }).toPromise();
|
|
122
|
+
const address = result.data.cart.shippingAddress;
|
|
123
|
+
completeStep(
|
|
124
|
+
'shipment',
|
|
125
|
+
`${address.address1}, ${address.city}, ${address.country.name}`
|
|
126
|
+
);
|
|
127
|
+
} else {
|
|
128
|
+
toast.error(response.data.error.message);
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
toast.error(error.message);
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
if (formContext.state === 'submitSuccess') {
|