|
|
@@ -12,6 +12,8 @@
|
|
|
let token = null;
|
|
|
let company = null;
|
|
|
|
|
|
+ const API = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, '');
|
|
|
+
|
|
|
if (browser) {
|
|
|
token = localStorage.getItem('token');
|
|
|
company = Number(localStorage.getItem('company'));
|
|
|
@@ -85,7 +87,7 @@
|
|
|
redirect: 'follow'
|
|
|
};
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/product/create', requestOptions)
|
|
|
+ fetch(`${API}/product/create`, requestOptions)
|
|
|
.then((response) => response.json())
|
|
|
.then((res) => {
|
|
|
if (res.status === 'ok') {
|
|
|
@@ -102,7 +104,7 @@
|
|
|
description_text: productFormData.description
|
|
|
};
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/description/create', {
|
|
|
+ fetch(`${API}/description/create`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -176,7 +178,7 @@
|
|
|
|
|
|
try {
|
|
|
const response = await fetch(
|
|
|
- 'https://bartender.mixtab.com.br/product/update',
|
|
|
+ `${API}/product/update`,
|
|
|
requestOptions
|
|
|
);
|
|
|
const result = await response.json();
|
|
|
@@ -190,7 +192,7 @@
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
- const descRes = await fetch('https://bartender.mixtab.com.br/description/update', {
|
|
|
+ const descRes = await fetch(`${API}/description/update`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -246,7 +248,7 @@
|
|
|
redirect: 'follow'
|
|
|
};
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/category/create', requestOptions)
|
|
|
+ fetch(`${API}/category/create`, requestOptions)
|
|
|
.then((response) => response.json())
|
|
|
.then((res) => {
|
|
|
if (res.status === 'ok') {
|
|
|
@@ -272,7 +274,7 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/category/delete', {
|
|
|
+ fetch(`${API}/category/delete`, {
|
|
|
method: 'POST',
|
|
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
|
body: JSON.stringify({
|
|
|
@@ -307,7 +309,7 @@
|
|
|
redirect: 'follow'
|
|
|
};
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/product/delete', requestOptions)
|
|
|
+ fetch(`${API}/product/delete`, requestOptions)
|
|
|
.then((response) => response.json())
|
|
|
.then((res) => {
|
|
|
if (res.status === 'ok') {
|
|
|
@@ -333,7 +335,7 @@
|
|
|
body: JSON.stringify({ company_id: company })
|
|
|
};
|
|
|
|
|
|
- fetch('https://bartender.mixtab.com.br/category/get', requestOptions)
|
|
|
+ fetch(`${API}/category/get`, requestOptions)
|
|
|
.then((response) => response.json())
|
|
|
.then((res) => {
|
|
|
if (res.status === 'ok') {
|
|
|
@@ -342,7 +344,7 @@
|
|
|
name: categorie.category_name
|
|
|
}));
|
|
|
|
|
|
- return fetch('https://bartender.mixtab.com.br/product/get', requestOptions);
|
|
|
+ return fetch(`${API}/product/get`, requestOptions);
|
|
|
} else {
|
|
|
throw new Error(`Erro ao carregar categorias: ${res.msg}`);
|
|
|
}
|