ilya_shyian преди 2 години
родител
ревизия
414676525a

+ 2 - 2
src/actions/actionCatAll.js

@@ -1,5 +1,5 @@
 import { actionPromise } from '../reducers';
-import { gql } from '../helpers';
+import { backendURL, gql } from '../helpers';
 
 export const actionCatAll =
     ({ limit = 20, skip = 0, promiseName = 'catAll', orderBy = '' } = {}) =>
@@ -7,7 +7,7 @@ export const actionCatAll =
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/categories/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
+                fetch(`${backendURL}/categories/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
                     method: 'GET',
                     headers: {
                         'Content-Type': 'application/json',

+ 2 - 2
src/actions/actionCatById.js

@@ -1,11 +1,11 @@
-import { mock, query } from '../helpers';
+import { backendURL, mock, query } from '../helpers';
 
 import { actionPromise } from '../reducers';
 
 export const actionCatById = ({ _id, promiseName = 'catById', orderBy = '', limit = 20, skip = 0 }) =>
     actionPromise(
         promiseName,
-        fetch(`/categories/${_id}/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
+        fetch(`${backendURL}/categories/${_id}/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
             method: 'GET',
             headers: {
                 'Content-Type': 'application/json',

+ 2 - 1
src/actions/actionCategoryUpsert.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionCategoryUpsert = (category) => async (dispatch) => {
@@ -10,7 +11,7 @@ export const actionCategoryUpsert = (category) => async (dispatch) => {
     dispatch(
         actionPromise(
             'categoryUpsert',
-            fetch(`/category/`, {
+            fetch(`${backendURL}/category/`, {
                 method: 'POST',
                 headers: {
                     ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),

+ 13 - 7
src/actions/actionCatsFind.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionCatsFind =
@@ -6,13 +7,18 @@ export const actionCatsFind =
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/categories/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
-                    method: 'GET',
-                    headers: {
-                        'Content-Type': 'application/json',
-                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
-                    },
-                })
+                fetch(
+                    `${backendURL}/categories/?limit=${limit}&skip=${skip}&text=${text}${
+                        orderBy && `&orderBy=` + orderBy
+                    }`,
+                    {
+                        method: 'GET',
+                        headers: {
+                            'Content-Type': 'application/json',
+                            ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                        },
+                    }
+                )
                     .then((res) => res.json())
                     .then((data) => {
                         if (data.errors) {

+ 2 - 2
src/actions/actionGoodById.js

@@ -1,11 +1,11 @@
-import { getQuery, mock, query } from '../helpers';
+import { backendURL, getQuery, mock, query } from '../helpers';
 
 import { actionPromise } from '../reducers';
 
 export const actionGoodById = ({ _id, promiseName = 'goodById' } = {}) =>
     actionPromise(
         promiseName,
-        fetch(`/goods/${_id}/`, {
+        fetch(`${backendURL}/goods/${_id}/`, {
             method: 'GET',
             headers: {
                 'Content-Type': 'application/json',

+ 2 - 1
src/actions/actionGoodUpsert.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionGoodUpsert = (good) => async (dispatch) => {
@@ -13,7 +14,7 @@ export const actionGoodUpsert = (good) => async (dispatch) => {
     dispatch(
         actionPromise(
             'goodUpsert',
-            fetch(`/good/`, {
+            fetch(`${backendURL}/good/`, {
                 method: 'POST',
                 headers: {
                     ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),

+ 2 - 2
src/actions/actionGoodsAll.js

@@ -1,4 +1,4 @@
-import { getQuery } from '../helpers';
+import { backendURL, getQuery } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionGoodsAll =
@@ -7,7 +7,7 @@ export const actionGoodsAll =
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/goods/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
+                fetch(`${backendURL}/goods/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
                     method: 'GET',
                     headers: {
                         'Content-Type': 'application/json',

+ 11 - 7
src/actions/actionGoodsFind.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionGoodsFind =
@@ -6,13 +7,16 @@ export const actionGoodsFind =
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/goods/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
-                    method: 'GET',
-                    headers: {
-                        'Content-Type': 'application/json',
-                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
-                    },
-                })
+                fetch(
+                    `${backendURL}/goods/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`,
+                    {
+                        method: 'GET',
+                        headers: {
+                            'Content-Type': 'application/json',
+                            ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                        },
+                    }
+                )
                     .then((res) => res.json())
                     .then((data) => {
                         if (data.errors) {

+ 2 - 2
src/actions/actionGoodsPopular.js

@@ -1,4 +1,4 @@
-import { mock, query } from '../helpers';
+import { backendURL, mock, query } from '../helpers';
 
 import { actionPromise } from '../reducers';
 
@@ -6,7 +6,7 @@ export const actionGoodsPopular = () => async (dispatch, getState) => {
     dispatch(
         actionPromise(
             'goodsPopular',
-            fetch(`/goods/?limit=20&skip=0&popular=1`, {
+            fetch(`${backendURL}/goods/?limit=20&skip=0&popular=1`, {
                 method: 'GET',
                 headers: {
                     'Content-Type': 'application/json',

+ 2 - 2
src/actions/actionLogin.js

@@ -1,5 +1,5 @@
 import { actionPromise } from '../reducers';
-import { gql } from '../helpers';
+import { backendURL, gql } from '../helpers';
 import { actionAuthLogin } from '../reducers';
 
 export const actionLogin = (login, password) => async (dispatch, getState) => {
@@ -11,7 +11,7 @@ export const actionLogin = (login, password) => async (dispatch, getState) => {
     const token = await dispatch(
         actionPromise(
             'login',
-            fetch(`/auth/token/`, {
+            fetch(`${backendURL}/auth/token/`, {
                 method: 'POST',
                 headers: {
                     ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),

+ 2 - 2
src/actions/actionOrderById.js

@@ -1,11 +1,11 @@
-import { mock, query } from '../helpers';
+import { backendURL, mock, query } from '../helpers';
 
 import { actionPromise } from '../reducers';
 
 export const actionOrderById = ({ _id, promiseName = 'orderById' }) =>
     actionPromise(
         promiseName,
-        fetch(`/orders/${_id}/`, {
+        fetch(`${backendURL}/orders/${_id}/`, {
             method: 'GET',
             headers: {
                 'Content-Type': 'application/json',

+ 2 - 1
src/actions/actionOrderUpsert.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionOrderUpsert = (order) => async (dispatch) => {
@@ -15,7 +16,7 @@ export const actionOrderUpsert = (order) => async (dispatch) => {
     dispatch(
         actionPromise(
             'orderUpsert',
-            fetch(`/order/`, {
+            fetch(`${backendURL}/order/`, {
                 method: 'POST',
                 headers: {
                     ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),

+ 2 - 2
src/actions/actionOrdersAll.js

@@ -1,5 +1,5 @@
 import { actionPromise } from '../reducers';
-import { gql } from '../helpers';
+import { backendURL, gql } from '../helpers';
 
 export const actionOrdersAll =
     ({ limit = 0, skip = 0, promiseName = 'adminOrdersAll', orderBy = '', status = 0 } = {}) =>
@@ -9,7 +9,7 @@ export const actionOrdersAll =
             actionPromise(
                 promiseName,
                 fetch(
-                    `/orders/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}${
+                    `${backendURL}/orders/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}${
                         status ? `&status=` + status : ''
                     }`,
                     {

+ 11 - 7
src/actions/actionOrdersFind.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionOrdersFind =
@@ -6,13 +7,16 @@ export const actionOrdersFind =
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/orders/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
-                    method: 'GET',
-                    headers: {
-                        'Content-Type': 'application/json',
-                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
-                    },
-                })
+                fetch(
+                    `${backendURL}/orders/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`,
+                    {
+                        method: 'GET',
+                        headers: {
+                            'Content-Type': 'application/json',
+                            ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                        },
+                    }
+                )
                     .then((res) => res.json())
                     .then((data) => {
                         if (data.errors) {

+ 2 - 2
src/actions/actionRootCats.js

@@ -1,4 +1,4 @@
-import { mock, query } from '../helpers';
+import { backendURL, mock, query } from '../helpers';
 
 import { actionPromise } from '../reducers';
 
@@ -6,7 +6,7 @@ export const actionRootCats = () => async (dispatch, getState) => {
     dispatch(
         actionPromise(
             'rootCats',
-            fetch(`/categories/?isRoot=1`, {
+            fetch(`${backendURL}/categories/?isRoot=1`, {
                 method: 'GET',
                 headers: {
                     'Content-Type': 'application/json',

+ 2 - 1
src/actions/actionUploadFile.js

@@ -1,3 +1,4 @@
+import { backendURL } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionUploadFile = (file) => {
@@ -5,7 +6,7 @@ export const actionUploadFile = (file) => {
     fd.append('photo', file);
     return actionPromise(
         'uploadFile',
-        fetch('/upload/', {
+        fetch(`${backendURL}/upload/`, {
             method: 'POST',
             headers: localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {},
             body: fd,