feat: add entry removal and row saving functionality, enhance admin components with localization
This commit is contained in:
@@ -51,8 +51,6 @@ export async function getTableData() {
|
||||
return { success: false };
|
||||
}
|
||||
|
||||
// Create data from array not working !!!
|
||||
|
||||
export async function createEntry(data) {
|
||||
let { status } = { status: true };
|
||||
for (const item of data) {
|
||||
@@ -71,3 +69,42 @@ export async function createEntry(data) {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
export async function removeEntries(losnummern) {
|
||||
let { status } = { status: true };
|
||||
|
||||
for (const losnummer of losnummern) {
|
||||
const [result] = await pool.query("DELETE FROM lose WHERE losnummer = ?", [
|
||||
losnummer,
|
||||
]);
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
status = true;
|
||||
} else {
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
export async function saveRow(payload) {
|
||||
const [result] = await pool.query(
|
||||
"UPDATE lose SET vorname = ?, nachname = ?, adresse = ?, plz = ?, email = ? WHERE losnummer = ?",
|
||||
[
|
||||
payload.vorname,
|
||||
payload.nachname,
|
||||
payload.adresse,
|
||||
payload.plz,
|
||||
payload.email,
|
||||
payload.losnummer,
|
||||
]
|
||||
);
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
return { success: true };
|
||||
} else {
|
||||
return { success: false };
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user