implemented poi and mvi
This commit is contained in:
@ -55,40 +55,40 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// if (event.path.startsWith("/api/addMVTasd")) {
|
||||
// const body = await readBody(event)
|
||||
// // add the mvt in the backend
|
||||
// try {
|
||||
// let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/masterMaintenanceVisits`, body);
|
||||
// insertId = res.data.insertId
|
||||
// } catch (err) {
|
||||
// if (axios.isAxiosError(err)) {
|
||||
// const axiosError = err as AxiosError;
|
||||
if (event.path.startsWith("/api/addTodoPOI")) {
|
||||
const body = await readBody(event)
|
||||
// add the poi in the backend
|
||||
try {
|
||||
let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/productionOrderTodos`, body);
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
|
||||
// if (axiosError.response) {
|
||||
// // Axios error
|
||||
// console.error(axiosError.response.data.message);
|
||||
// errorMsg = axiosError.response.data.message;
|
||||
// } else if (axiosError.request) {
|
||||
// console.log(err)
|
||||
// // If error was caused by the request
|
||||
// console.error(axiosError.request);
|
||||
// } else {
|
||||
// // Other errors
|
||||
// console.error('Error', axiosError.message);
|
||||
// }
|
||||
// } else {
|
||||
// // No AxiosError
|
||||
// console.error('Error', err);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (axiosError.response) {
|
||||
// Axios error
|
||||
console.error(axiosError.response.data.message);
|
||||
errorMsg = axiosError.response.data.message;
|
||||
} else if (axiosError.request) {
|
||||
console.log(err)
|
||||
// If error was caused by the request
|
||||
console.error(axiosError.request);
|
||||
} else {
|
||||
// Other errors
|
||||
console.error('Error', axiosError.message);
|
||||
}
|
||||
} else {
|
||||
// No AxiosError
|
||||
console.error('Error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.path.startsWith("/api/addPOI")) {
|
||||
const body = await readBody(event)
|
||||
// add the poi todo in the backend
|
||||
try {
|
||||
let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/productionOrder`, body);
|
||||
insertId = res.data.insertId
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
@ -209,38 +209,6 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
|
||||
// if (event.path.startsWith("/api/getSelectedMITsByCustomer")) {
|
||||
// // get selected maintenance visit instances object by customer from backend
|
||||
// let filteredCustomer = null;
|
||||
// const path = event._path;
|
||||
// const pathSegments = path.split('/');
|
||||
// filteredCustomer = pathSegments[pathSegments.length - 1];
|
||||
|
||||
// try {
|
||||
// let res = await axiosInstance.get(`https://${serversideConfig.url}:${serversideConfig.port}/selectedMaintenanceVisitsByCustomer/${filteredCustomer}`);
|
||||
// selectedMITsByCustomer = res.data;
|
||||
// } catch (err) {
|
||||
// if (axios.isAxiosError(err)) {
|
||||
// const axiosError = err as AxiosError;
|
||||
|
||||
// if (axiosError.response) {
|
||||
// // Axios error
|
||||
// console.error(axiosError.response.data.message);
|
||||
// errorMsg = axiosError.response.data.message;
|
||||
// } else if (axiosError.request) {
|
||||
// // If error was caused by the request
|
||||
// console.error(axiosError.request);
|
||||
// } else {
|
||||
// // Other errors
|
||||
// console.error('Error', axiosError.message);
|
||||
// }
|
||||
// } else {
|
||||
// // No AxiosError
|
||||
// console.error('Error', err);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (event.path.startsWith("/api/getSelectedPOIsByUser")) {
|
||||
// get selected production order instances object by user from backend
|
||||
let filteredUser = null;
|
||||
@ -337,37 +305,37 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// if (event.path.startsWith("/api/getTodosMaintenanceVisitTemplateasd")) {
|
||||
// // get maintenance visit template todos object from backend
|
||||
// let itemId = null;
|
||||
// const path = event._path;
|
||||
// const pathSegments = path.split('/');
|
||||
// itemId = pathSegments[pathSegments.length - 1];
|
||||
if (event.path.startsWith("/api/getTodosProductionOrderInstance")) {
|
||||
// get maintenance visit instance todos object from backend
|
||||
let itemId = null;
|
||||
const path = event._path;
|
||||
const pathSegments = path.split('/');
|
||||
itemId = pathSegments[pathSegments.length - 1];
|
||||
|
||||
// try {
|
||||
// let res = await axiosInstance.get(`https://${serversideConfig.url}:${serversideConfig.port}/masterMaintenanceVisitTodos/${itemId}`);
|
||||
// mitTodosByTemplateId = res.data;
|
||||
// } catch (err) {
|
||||
// if (axios.isAxiosError(err)) {
|
||||
// const axiosError = err as AxiosError;
|
||||
try {
|
||||
let res = await axiosInstance.get(`https://${serversideConfig.url}:${serversideConfig.port}/productionOrderTodosByTemplateID/${itemId}`);
|
||||
poiTodosByTemplateId = res.data;
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
|
||||
// if (axiosError.response) {
|
||||
// // Axios error
|
||||
// console.error(axiosError.response.data.message);
|
||||
// errorMsg = axiosError.response.data.message;
|
||||
// } else if (axiosError.request) {
|
||||
// // If error was caused by the request
|
||||
// console.error(axiosError.request);
|
||||
// } else {
|
||||
// // Other errors
|
||||
// console.error('Error', axiosError.message);
|
||||
// }
|
||||
// } else {
|
||||
// // No AxiosError
|
||||
// console.error('Error', err);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (axiosError.response) {
|
||||
// Axios error
|
||||
console.error(axiosError.response.data.message);
|
||||
errorMsg = axiosError.response.data.message;
|
||||
} else if (axiosError.request) {
|
||||
// If error was caused by the request
|
||||
console.error(axiosError.request);
|
||||
} else {
|
||||
// Other errors
|
||||
console.error('Error', axiosError.message);
|
||||
}
|
||||
} else {
|
||||
// No AxiosError
|
||||
console.error('Error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.path.startsWith("/api/deleteTodosPOI")) {
|
||||
let poiId = null;
|
||||
@ -375,7 +343,7 @@ export default defineEventHandler(async (event) => {
|
||||
const pathSegments = path.split('/');
|
||||
poiId = pathSegments[pathSegments.length - 1];
|
||||
|
||||
// delete the mvt todos in the backend
|
||||
// delete the poi todos in the backend
|
||||
try {
|
||||
let res = await axiosInstance.delete(`https://${serversideConfig.url}:${serversideConfig.port}/productionOrderTodos/${poiId}`);
|
||||
} catch (err) {
|
||||
@ -461,65 +429,33 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// if (event.path.startsWith("/api/updateMVTTodoasd")) {
|
||||
// const body = await readBody(event)
|
||||
// // update the maintenance visit template todo in the backend
|
||||
// try {
|
||||
// let res = await axiosInstance.put(`https://${serversideConfig.url}:${serversideConfig.port}/masterMaintenanceVisitTodos`, body);
|
||||
// } catch (err) {
|
||||
// if (axios.isAxiosError(err)) {
|
||||
// const axiosError = err as AxiosError;
|
||||
if (event.path.startsWith("/api/updatePOITodo")) {
|
||||
const body = await readBody(event)
|
||||
// update the production order instance todo in the backend
|
||||
try {
|
||||
let res = await axiosInstance.put(`https://${serversideConfig.url}:${serversideConfig.port}/productionOrderTodos`, body);
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
|
||||
// if (axiosError.response) {
|
||||
// // Axios error
|
||||
// console.error(axiosError.response.data.message);
|
||||
// errorMsg = axiosError.response.data.message;
|
||||
// } else if (axiosError.request) {
|
||||
// console.log(err)
|
||||
// // If error was caused by the request
|
||||
// console.error(axiosError.request);
|
||||
// } else {
|
||||
// // Other errors
|
||||
// console.error('Error', axiosError.message);
|
||||
// }
|
||||
// } else {
|
||||
// // No AxiosError
|
||||
// console.error('Error', err);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (event.path.startsWith("/api/deleteMVTTodoasd")) {
|
||||
// let poiId = null;
|
||||
// const path = event._path;
|
||||
// const pathSegments = path.split('/');
|
||||
// poiId = pathSegments[pathSegments.length - 1];
|
||||
|
||||
// // delete the mvt in the backend
|
||||
// try {
|
||||
// let res = await axiosInstance.delete(`https://${serversideConfig.url}:${serversideConfig.port}/masterMaintenanceVisitTodos/${poiId}`);
|
||||
// } catch (err) {
|
||||
// if (axios.isAxiosError(err)) {
|
||||
// const axiosError = err as AxiosError;
|
||||
|
||||
// if (axiosError.response) {
|
||||
// // Axios error
|
||||
// console.error(axiosError.response.data.message);
|
||||
// errorMsg = axiosError.response.data.message;
|
||||
// } else if (axiosError.request) {
|
||||
// console.log(err)
|
||||
// // If error was caused by the request
|
||||
// console.error(axiosError.request);
|
||||
// } else {
|
||||
// // Other errors
|
||||
// console.error('Error', axiosError.message);
|
||||
// }
|
||||
// } else {
|
||||
// // No AxiosError
|
||||
// console.error('Error', err);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (axiosError.response) {
|
||||
// Axios error
|
||||
console.error(axiosError.response.data.message);
|
||||
errorMsg = axiosError.response.data.message;
|
||||
} else if (axiosError.request) {
|
||||
console.log(err)
|
||||
// If error was caused by the request
|
||||
console.error(axiosError.request);
|
||||
} else {
|
||||
// Other errors
|
||||
console.error('Error', axiosError.message);
|
||||
}
|
||||
} else {
|
||||
// No AxiosError
|
||||
console.error('Error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export { productionOrderInstances, selectedPOIsByState, selectedPOIsByUser, selectedPOIsByPOT, selectedPOIsByPOI, selectedPOIsByCustomer, poiTodosByTemplateId, poi, insertId, errorMsg };
|
||||
Reference in New Issue
Block a user