@evershop/evershop 1.0.0-beta → 1.0.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evershop/evershop",
3
- "version": "1.0.0-beta",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "The React Ecommerce platform. Built with React and MySQL. Open-source and free. Fast and customizable.",
5
5
  "files": [
6
6
  "bin",
@@ -0,0 +1,20 @@
1
+ const { getConfig } = require('../../../../../lib/util/getConfig');
2
+ const { getContextValue } = require('../../../../graphql/services/contextHelper');
3
+
4
+ module.exports = (request, response, stack, next) => {
5
+ if (request.method == "GET") {
6
+ next();
7
+ } else {
8
+ const tokenPayLoad = getContextValue(request, 'tokenPayload');
9
+ const currentUserEmail = tokenPayLoad?.user?.email;
10
+ const demoUserEmail = getConfig('system.demoUser');
11
+ if (demoUserEmail && currentUserEmail === demoUserEmail) {
12
+ response.json({
13
+ success: false,
14
+ message: 'The demo account is not allowed to make changes'
15
+ });
16
+ } else {
17
+ next();
18
+ }
19
+ }
20
+ };
@@ -6,7 +6,7 @@ module.exports = exports = async () => {
6
6
  await execute(pool, `DROP TABLE IF EXISTS \`admin_user\``);
7
7
  await execute(pool, `CREATE TABLE \`admin_user\` (
8
8
  \`admin_user_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
- \`uuid\` varchar(255) DEFAULT replace(uuid(),'-',''),
9
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
10
10
  \`status\` smallint(5) unsigned NOT NULL,
11
11
  \`email\` varchar(255) NOT NULL,
12
12
  \`password\` varchar(255) NOT NULL,
@@ -132,6 +132,7 @@ module.exports = exports = async () => {
132
132
 
133
133
  await execute(pool, `CREATE TABLE \`customer_group\` (
134
134
  \`customer_group_id\` int(10) unsigned NOT NULL,
135
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
135
136
  \`group_name\` char(255) NOT NULL,
136
137
  \`created_at\` timestamp NOT NULL DEFAULT current_timestamp(),
137
138
  \`updated_at\` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
@@ -143,6 +144,7 @@ module.exports = exports = async () => {
143
144
 
144
145
  await execute(pool, `CREATE TABLE \`product\` (
145
146
  \`product_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
147
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
146
148
  \`variant_group_id\` int(10) unsigned DEFAULT NULL,
147
149
  \`visibility\` smallint(2) DEFAULT NULL,
148
150
  \`group_id\` int(10) unsigned DEFAULT NULL,
@@ -247,6 +249,7 @@ module.exports = exports = async () => {
247
249
 
248
250
  await execute(pool, `CREATE TABLE \`category\` (
249
251
  \`category_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
252
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
250
253
  \`status\` smallint(6) NOT NULL,
251
254
  \`parent_id\` int(10) unsigned DEFAULT NULL,
252
255
  \`include_in_nav\` smallint(5) unsigned NOT NULL,
@@ -1,2 +1,2 @@
1
- POST
1
+ GET
2
2
  /lifetimesales
@@ -1,2 +1,2 @@
1
- POST
1
+ GET
2
2
  /bestsellers
@@ -5,7 +5,7 @@ const { pool } = require('../../../../../lib/mysql/connection');
5
5
  // eslint-disable-next-line no-unused-vars
6
6
  module.exports = async (request, response, stack, next) => {
7
7
  response.$body = [];
8
- const { period } = request.params;
8
+ const { period = 'weekly' } = request.query;
9
9
  let i = 5;
10
10
  const result = [];
11
11
  const today = dayjs().format('YYYY-MM-DD').toString();
@@ -1,2 +1,2 @@
1
- POST
2
- /salestatistic/:period
1
+ GET
2
+ /salestatistic
@@ -5,6 +5,8 @@ const { pool } = require('../../../lib/mysql/connection');
5
5
  module.exports = exports = async () => {
6
6
  await execute(pool, `CREATE TABLE \`cart\` (
7
7
  \`cart_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
8
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
9
+ \`sid\` varchar(255) DEFAULT NULL,
8
10
  \`currency\` varchar(11) NOT NULL,
9
11
  \`customer_id\` int(10) unsigned DEFAULT NULL,
10
12
  \`customer_group_id\` smallint(6) DEFAULT NULL,
@@ -36,6 +38,7 @@ module.exports = exports = async () => {
36
38
 
37
39
  await execute(pool, `CREATE TABLE \`cart_address\` (
38
40
  \`cart_address_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
41
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
39
42
  \`full_name\` varchar(255) DEFAULT NULL,
40
43
  \`postcode\` varchar(255) DEFAULT NULL,
41
44
  \`telephone\` varchar(255) DEFAULT NULL,
@@ -50,10 +53,12 @@ module.exports = exports = async () => {
50
53
 
51
54
  await execute(pool, `CREATE TABLE \`cart_item\` (
52
55
  \`cart_item_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
56
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
53
57
  \`cart_id\` int(10) unsigned NOT NULL,
54
58
  \`product_id\` int(10) unsigned NOT NULL,
55
59
  \`product_sku\` varchar(255) NOT NULL,
56
60
  \`product_name\` text NOT NULL,
61
+ \`thumbnail\` varchar(255) DEFAULT NULL,
57
62
  \`product_weight\` decimal(12,4) DEFAULT NULL,
58
63
  \`product_price\` decimal(12,4) NOT NULL,
59
64
  \`product_price_incl_tax\` decimal(12,4) NOT NULL,
@@ -79,6 +84,8 @@ module.exports = exports = async () => {
79
84
 
80
85
  await execute(pool, `CREATE TABLE \`order\` (
81
86
  \`order_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
87
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
88
+ \`sid\` varchar(255) DEFAULT NULL,
82
89
  \`order_number\` varchar(255) NOT NULL,
83
90
  \`cart_id\` int(10) unsigned NOT NULL,
84
91
  \`currency\` varchar(11) NOT NULL,
@@ -127,6 +134,7 @@ module.exports = exports = async () => {
127
134
 
128
135
  await execute(pool, `CREATE TABLE \`order_address\` (
129
136
  \`order_address_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
137
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
130
138
  \`full_name\` varchar(255) DEFAULT NULL,
131
139
  \`postcode\` varchar(255) DEFAULT NULL,
132
140
  \`telephone\` varchar(255) DEFAULT NULL,
@@ -141,11 +149,13 @@ module.exports = exports = async () => {
141
149
 
142
150
  await execute(pool, `CREATE TABLE \`order_item\` (
143
151
  \`order_item_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
152
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
144
153
  \`order_item_order_id\` int(10) unsigned NOT NULL,
145
154
  \`product_id\` int(10) unsigned NOT NULL,
146
155
  \`referer\` int(10) unsigned DEFAULT NULL,
147
156
  \`product_sku\` varchar(255) NOT NULL,
148
157
  \`product_name\` text NOT NULL,
158
+ \`thumbnail\` varchar(255) DEFAULT NULL,
149
159
  \`product_weight\` decimal(12,4) DEFAULT NULL,
150
160
  \`product_price\` decimal(12,4) NOT NULL,
151
161
  \`product_price_incl_tax\` decimal(12,4) NOT NULL,
@@ -170,6 +180,7 @@ module.exports = exports = async () => {
170
180
 
171
181
  await execute(pool, `CREATE TABLE \`payment_transaction\` (
172
182
  \`payment_transaction_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
183
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
173
184
  \`payment_transaction_order_id\` int(10) unsigned NOT NULL,
174
185
  \`transaction_id\` varchar(100) DEFAULT NULL,
175
186
  \`transaction_type\` char(255) NOT NULL,
@@ -186,6 +197,7 @@ module.exports = exports = async () => {
186
197
 
187
198
  await execute(pool, `CREATE TABLE \`shipment\` (
188
199
  \`shipment_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
200
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
189
201
  \`shipment_order_id\` int(10) unsigned NOT NULL,
190
202
  \`carrier_name\` varchar(255) DEFAULT NULL,
191
203
  \`tracking_number\` varchar(255) DEFAULT NULL,
@@ -13,7 +13,7 @@ export default function BestSellers({ api }) {
13
13
  React.useEffect(() => {
14
14
  if (window !== undefined) {
15
15
  fetch(api, {
16
- method: 'POST', // or 'PUT'
16
+ method: 'GET',
17
17
  headers: {
18
18
  'Content-Type': 'application/json'
19
19
  }
@@ -26,7 +26,7 @@ export default function LifetimeSale({ api }) {
26
26
  React.useEffect(() => {
27
27
  if (window !== undefined) {
28
28
  fetch(api, {
29
- method: 'POST', // or 'PUT'
29
+ method: 'GET',
30
30
  headers: {
31
31
  'Content-Type': 'application/json'
32
32
  }
@@ -14,12 +14,11 @@ export default function SaleStatistic({ api }) {
14
14
 
15
15
  useEffect(() => {
16
16
  if (window !== undefined) {
17
- fetch(api.replace('monthly', period).replace('weekly', period).replace('daily', period), {
18
- method: 'POST', // or 'PUT'
17
+ fetch((api + `?period=${period}`), {
18
+ method: 'GET',
19
19
  headers: {
20
20
  'Content-Type': 'application/json'
21
- },
22
- body: JSON.stringify(data)
21
+ }
23
22
  })
24
23
  .then((response) => response.json())
25
24
  .then((json) => {
@@ -5,6 +5,7 @@ const { pool } = require('../../../lib/mysql/connection');
5
5
  module.exports = exports = async () => {
6
6
  await execute(pool, `CREATE TABLE \`cms_page\` (
7
7
  \`cms_page_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
8
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
8
9
  \`layout\` varchar(255) NOT NULL,
9
10
  \`status\` smallint(6) DEFAULT NULL,
10
11
  \`created_at\` datetime DEFAULT NULL,
@@ -5,6 +5,7 @@ const { pool } = require('../../../lib/mysql/connection');
5
5
  module.exports = exports = async () => {
6
6
  await execute(pool, `CREATE TABLE \`customer\` (
7
7
  \`customer_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
8
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
8
9
  \`status\` smallint(6) NOT NULL DEFAULT 1,
9
10
  \`group_id\` int(10) unsigned DEFAULT NULL,
10
11
  \`email\` char(255) NOT NULL,
@@ -21,6 +22,7 @@ module.exports = exports = async () => {
21
22
 
22
23
  await execute(pool, `CREATE TABLE \`customer_address\` (
23
24
  \`customer_address_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
25
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
24
26
  \`customer_id\` int(10) unsigned NOT NULL,
25
27
  \`full_name\` varchar(255) DEFAULT NULL,
26
28
  \`telephone\` varchar(255) DEFAULT NULL,
@@ -5,6 +5,7 @@ const { pool } = require('../../../lib/mysql/connection');
5
5
  module.exports = exports = async () => {
6
6
  await execute(pool, `CREATE TABLE \`coupon\` (
7
7
  \`coupon_id\` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
8
+ \`uuid\` varchar(255) DEFAULT (replace(uuid(),'-','')),
8
9
  \`status\` smallint(6) NOT NULL DEFAULT 1,
9
10
  \`description\` char(255) NOT NULL,
10
11
  \`discount_amount\` decimal(12,4) NOT NULL,
@@ -1,10 +0,0 @@
1
- const { execute } = require('@evershop/mysql-query-builder');
2
- const { pool } = require('../../../lib/mysql/connection');
3
-
4
- // eslint-disable-next-line no-multi-assign
5
- module.exports = exports = async () => {
6
- await execute(pool, `ALTER TABLE \`cart\` ADD \`sid\` text DEFAULT NULL AFTER \`user_ip\``);
7
- await execute(pool, `ALTER TABLE \`order\` ADD \`sid\` text DEFAULT NULL AFTER \`user_ip\``);
8
- await execute(pool, `ALTER TABLE \`cart_item\` ADD \`thumbnail\` text DEFAULT NULL AFTER \`product_name\``);
9
- await execute(pool, `ALTER TABLE \`order_item\` ADD \`thumbnail\` text DEFAULT NULL AFTER \`product_name\``);
10
- };
@@ -1,14 +0,0 @@
1
- const { execute } = require('@evershop/mysql-query-builder');
2
- const { pool } = require('../../../lib/mysql/connection');
3
-
4
- // eslint-disable-next-line no-multi-assign
5
- module.exports = exports = async () => {
6
- await execute(pool, `ALTER TABLE \`cart\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`cart_id\``);
7
- await execute(pool, `ALTER TABLE \`order\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`order_id\``);
8
- await execute(pool, `ALTER TABLE \`cart_item\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`cart_item_id\``);
9
- await execute(pool, `ALTER TABLE \`order_item\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`order_item_id\``);
10
- await execute(pool, `ALTER TABLE \`cart_address\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`cart_address_id\``);
11
- await execute(pool, `ALTER TABLE \`order_address\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`order_address_id\``);
12
- await execute(pool, `ALTER TABLE \`payment_transaction\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`payment_transaction_id\``);
13
- await execute(pool, `ALTER TABLE \`shipment\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`shipment_id\``);
14
- };
@@ -1,8 +0,0 @@
1
- const { execute } = require('@evershop/mysql-query-builder');
2
- const { pool } = require('../../../lib/mysql/connection');
3
-
4
- // eslint-disable-next-line no-multi-assign
5
- module.exports = exports = async () => {
6
- await execute(pool, `ALTER TABLE \`customer\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`customer_id\``);
7
- await execute(pool, `ALTER TABLE \`customer_address\` ADD \`uuid\` varchar(255) DEFAULT replace(uuid(),'-','') AFTER \`customer_address_id\``);
8
- };