feat: enhance CSV import functionality, integrate react-query for data fetching, and refactor admin components
This commit is contained in:
@@ -40,8 +40,8 @@ app.get("/table-data", authenticate, async (req, res) => {
|
||||
});
|
||||
|
||||
app.post("/create-entry", async (req, res) => {
|
||||
const result = await createEntry(req.body);
|
||||
if (result.success) {
|
||||
const result = await createEntry(req.body.losnummer);
|
||||
if (result) {
|
||||
res.status(201).json({ success: true });
|
||||
} else {
|
||||
res.status(400).json({ success: false });
|
||||
|
@@ -51,18 +51,23 @@ export async function getTableData() {
|
||||
return { success: false };
|
||||
}
|
||||
|
||||
export async function createEntryCSV(file) {
|
||||
// Implement CSV creation logic here
|
||||
}
|
||||
// Create data from array not working !!!
|
||||
|
||||
export async function createEntry(data) {
|
||||
const [result] = await pool.query("INSERT INTO lose (losnummer) VALUES (?)", [
|
||||
data.losnummer,
|
||||
]);
|
||||
let { status } = { status: true };
|
||||
for (const item of data) {
|
||||
const [result] = await pool.query(
|
||||
"INSERT INTO lose (losnummer) VALUES (?)",
|
||||
[item]
|
||||
);
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
return { success: true };
|
||||
} else {
|
||||
return { success: false };
|
||||
if (result.affectedRows > 0) {
|
||||
status = true;
|
||||
} else {
|
||||
status = false;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user