Commit abebe294 authored by unknown's avatar unknown
Browse files

fix: rename the OrderService file and adding json-server

parent 36269ee0
Showing with 57 additions and 19 deletions
+57 -19
# Server-only variables (private, without NEXT_PUBLIC_ prefix)
SECRET_KEY=secret-key-example
API_URL=http://localhost:3000
# Client and server variables (public, always with NEXT_PUBLIC_ prefix)
NEXT_PUBLIC_PORT=9999
......@@ -52,6 +52,7 @@
"aos": "^3.0.0-beta.6",
"axios": "^1.7.7",
"cpplanta-frontend": "file:",
"json-server": "^1.0.0-beta.3",
"next": "^14.0.3",
"prettier-plugin-tailwindcss": "^0.6.5",
"react": "^18.3.1",
......
import axios, { AxiosInstance } from 'axios';
class OrderService {
api: AxiosInstance;
constructor() {
this.api = axios.create({
baseURL: process.env.API_URL,
withCredentials: true
});
}
}
const orderServiceInstance = new OrderService();
export default orderServiceInstance;
import axios, { AxiosInstance } from 'axios';
class OrderService {
api: AxiosInstance;
constructor() {
this.api = axios.create({
baseURL: process.env.API_URL,
});
}
async getRawMaterials() {
try {
return this.api.get('/products');
} catch (error) {
console.log(error);
return [];
}
}
async getCompositions() {
try {
return this.api.get('/compositions?orderBy=id');
} catch (error) {
console.log(error);
return [];
}
}
async getRawMaterialById(id: number) {
try {
return this.api.get(`products/${id}`);
} catch (error) {
console.log(error);
return {};
}
}
async createOrder(data: OrderDTO) {
try {
return this.api.post('/orders', data);
} catch (error) {
console.log(error);
return {};
}
}
//getEtapas
//getProductLines ?
//getNomeOrdem
}
const orderService = new OrderService();
export default new OrderService();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment