fixed backend imports

This commit is contained in:
2024-02-16 19:00:30 +01:00
parent 5ca56d36cf
commit 5242d4a3af
26 changed files with 195 additions and 279 deletions

View File

@ -3,7 +3,7 @@ import ownConn from "../dbConfig.js";
//get all maintenance visits
export const getMaintenanceVisits = async (result) => {
try {
let sql = `SELECT * FROM maintenanceVisits ORDER BY name ASC`;
let sql = `SELECT * FROM maintenancevisits ORDER BY name ASC`;
const results = await ownConn.execute(sql)
result(null, results);
}
@ -17,7 +17,7 @@ export const getMaintenanceVisits = async (result) => {
//get all selected maintenance visits by checklistname
export const getSelectedMaintenanceVisitsByChecklistname = async (selected, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE name LIKE '%${selected}%' ORDER BY name ASC`;
let sql = `SELECT * FROM maintenancevisits WHERE name LIKE '%${selected}%' ORDER BY name ASC`;
const results = await ownConn.execute(sql)
result(null, results);
}
@ -31,7 +31,7 @@ export const getSelectedMaintenanceVisitsByChecklistname = async (selected, resu
//get all selected maintenance visits by customer
export const getSelectedMaintenanceVisitsByCustomer = async (selected, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE customer LIKE '%${selected}%' ORDER BY customer ASC`;
let sql = `SELECT * FROM maintenancevisits WHERE customer LIKE '%${selected}%' ORDER BY customer ASC`;
const results = await ownConn.execute(sql)
result(null, results);
}
@ -45,7 +45,7 @@ export const getSelectedMaintenanceVisitsByCustomer = async (selected, result) =
//get all selected maintenance visits by date
export const getSelectedMaintenanceVisitsByDate = async (selected, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE creationDate LIKE '%${selected}%' ORDER BY creationDate ASC`;
let sql = `SELECT * FROM maintenancevisits WHERE creationDate LIKE '%${selected}%' ORDER BY creationDate ASC`;
const results = await ownConn.execute(sql);
result(null, results);
}
@ -59,7 +59,7 @@ export const getSelectedMaintenanceVisitsByDate = async (selected, result) => {
//get all selected maintenance visits by state
export const getSelectedMaintenanceVisitsByState = async (selected, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE state LIKE '%${selected}%' ORDER BY state ASC`;
let sql = `SELECT * FROM maintenancevisits WHERE state LIKE '%${selected}%' ORDER BY state ASC`;
const results = await ownConn.execute(sql)
result(null, results);
}
@ -73,7 +73,7 @@ export const getSelectedMaintenanceVisitsByState = async (selected, result) => {
// Delete maintenance visit to Database
export const deleteMaintenanceVisitById = async (id, result) => {
try {
let sql = `DELETE FROM maintenanceVisits WHERE primaryID = ?`;
let sql = `DELETE FROM maintenancevisits WHERE primaryID = ?`;
const results = await ownConn.query(sql, [id])
result(null, results);
}
@ -87,7 +87,7 @@ export const deleteMaintenanceVisitById = async (id, result) => {
//insert maintenance visit to databased
export const insertMaintenanceVisit = async (data, result) => {
try {
const results = await ownConn.query(`INSERT INTO maintenanceVisits(name, templateID, maintenanceType, state, creationDate, completionDate, user, customer, customerID, templateNotes, type, timeSpent, notes) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [data.name, data.templateID, data.maintenanceType, data.state, data.creationDate, data.completionDate, data.user, data.customer, data.customerID, data.templateNotes, data.type, data.timeSpent, data.notes])
const results = await ownConn.query(`INSERT INTO maintenancevisits(name, templateID, maintenanceType, state, creationDate, completionDate, user, customer, customerID, templateNotes, type, timeSpent, notes) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [data.name, data.templateID, data.maintenanceType, data.state, data.creationDate, data.completionDate, data.user, data.customer, data.customerID, data.templateNotes, data.type, data.timeSpent, data.notes])
result(null, results);
}
catch (err) {
@ -100,7 +100,7 @@ export const insertMaintenanceVisit = async (data, result) => {
//get single maintenance visit by name
export const getMaintenanceVisitByName = async (id, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE name = ?`;
let sql = `SELECT * FROM maintenancevisits WHERE name = ?`;
const results = await ownConn.execute(sql, [id])
result(null, results[0]);
}
@ -114,7 +114,7 @@ export const getMaintenanceVisitByName = async (id, result) => {
//get single maintenance visit by id
export const getMaintenanceVisitById = async (id, result) => {
try {
let sql = `SELECT * FROM maintenanceVisits WHERE primaryID = ?`;
let sql = `SELECT * FROM maintenancevisits WHERE primaryID = ?`;
const results = await ownConn.execute(sql, [id])
result(null, results[0]);
}
@ -129,7 +129,7 @@ export const getMaintenanceVisitById = async (id, result) => {
export const updateMaintenanceVisitStateById = async (data, result) => {
try {
const id = data.primaryID;
let sql = `UPDATE maintenanceVisits SET state = ? WHERE primaryID = ?`;
let sql = `UPDATE maintenancevisits SET state = ? WHERE primaryID = ?`;
const results = await ownConn.query(sql, [data.state, id])
result(null, results);
}