| | |
| | | // src/services/api.js
|
| | | import request from 'request';
|
| | |
|
| | | const BASE_URL = 'glassStorage/api/rawUsage'; // Replace with your actual backend base URL
|
| | |
|
| | | export const findTasks = (id, newState) => {
|
| | | // Function to find list of raw usages
|
| | |
|
| | |
|
| | | export const findTasks = () => {
|
| | | const url = `glassStorage/api/storageTask/findTasks`;
|
| | | const options = {
|
| | | method: 'POST',
|
| | | method: 'get',
|
| | | url,
|
| | | json: true,
|
| | | body: { id, enableState: newState }
|
| | | |
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | |
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | | export const findList = (params) => {
|
| | | const url = `${BASE_URL}/findList`;
|
| | | const options = {
|
| | | method: 'post',
|
| | | url,
|
| | | json: true,
|
| | | body: params
|
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | | request(options, (error, response, body) => {
|
| | | if (error) {
|
| | | reject(new Error(error.message));
|
| | | } else {
|
| | | resolve(body);
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | // Function to find raw usage by ID
|
| | | export const findById = (id) => {
|
| | | const url = `${BASE_URL}/${id}`;
|
| | | const options = {
|
| | | method: 'get',
|
| | | url,
|
| | | json: true
|
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | | request(options, (error, response, body) => {
|
| | | if (error) {
|
| | | reject(new Error(error.message));
|
| | | } else {
|
| | | resolve(body);
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | // Function to insert a new raw usage
|
| | | export const insertRawUsage = (rawUsage) => {
|
| | | const url = `${BASE_URL}`;
|
| | | const options = {
|
| | | method: 'post',
|
| | | url,
|
| | | json: true,
|
| | | body: rawUsage
|
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | | request(options, (error, response, body) => {
|
| | | if (error) {
|
| | | reject(new Error(error.message));
|
| | | } else {
|
| | | resolve(body);
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | // Function to update an existing raw usage
|
| | | export const updateRawUsage = (rawUsage) => {
|
| | | const url = `${BASE_URL}`;
|
| | | const options = {
|
| | | method: 'put',
|
| | | url,
|
| | | json: true,
|
| | | body: rawUsage
|
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | | request(options, (error, response, body) => {
|
| | | if (error) {
|
| | | reject(new Error(error.message));
|
| | | } else {
|
| | | resolve(body);
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | // Function to delete a raw usage by ID
|
| | | export const deleteRawUsage = (id) => {
|
| | | const url = `${BASE_URL}/${id}`;
|
| | | const options = {
|
| | | method: 'delete',
|
| | | url,
|
| | | json: true
|
| | | };
|
| | |
|
| | | return new Promise((resolve, reject) => {
|
| | | request(options, (error, response, body) => {
|
| | | if (error) {
|
| | | reject(new Error(error.message));
|
| | | } else {
|
| | | resolve(body);
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | |
|
| | | const API_URL = 'glassStorage/api/shelfRack'; // Adjust this based on your actual API URL
|
| | |
|
| | | export const shelfRackfindList = (params) => {
|
| | | return request.post(`${API_URL}/findList`, params)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error; // Handle errors appropriately in your frontend
|
| | | });
|
| | | };
|
| | |
|
| | | export const shelfRackfindById = (id) => {
|
| | | return request.get(`${API_URL}/${id}`)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error;
|
| | | });
|
| | | };
|
| | |
|
| | | export const insertShelfRack = (shelfRack) => {
|
| | | return request.post(`${API_URL}`, shelfRack)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error;
|
| | | });
|
| | | };
|
| | |
|
| | | export const updateShelfRack = (shelfRack) => {
|
| | | return request.put(`${API_URL}`, shelfRack)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error;
|
| | | });
|
| | | };
|
| | |
|
| | | export const shelfRackdeleteById = (id) => {
|
| | | return request.delete(`${API_URL}/${id}`)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error;
|
| | | });
|
| | | };
|
| | |
|
| | | export const findShelfRack = () => {
|
| | | return request.get(`${API_URL}/findshelfrack`)
|
| | | .then(response => response.data)
|
| | | .catch(error => {
|
| | | throw error;
|
| | | });
|
| | | }; |