feat: add user confirmation functionality and dynamic table creation; enhance MainForm with user selection and next ID display
This commit is contained in:
@@ -22,4 +22,59 @@ export const getUser = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const confirmUser = async (username) => {
|
||||
const [rows] = await pool.query("SELECT * FROM usersNEW WHERE username = ?", [
|
||||
username,
|
||||
]);
|
||||
|
||||
if (rows.length > 0) {
|
||||
// creating userTicketTable
|
||||
const d = new Date();
|
||||
|
||||
const day = d.getDate();
|
||||
const month = d.getMonth() + 1;
|
||||
const year = d.getFullYear();
|
||||
const date = `${day}_${month}_${year}`;
|
||||
const tableName = `${username}_${date}`;
|
||||
|
||||
console.log(tableName);
|
||||
|
||||
const [createTable] = await pool.query(
|
||||
`CREATE TABLE IF NOT EXISTS ${tableName} (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Vorname VARCHAR(100) NOT NULL,
|
||||
Nachname Varchar(100) NOT NULL,
|
||||
EMail Varchar(100) NOT NULL,
|
||||
Telefonnummer Varchar(100) NOT NULL,
|
||||
Lose INT NOT NULL,
|
||||
Firmenname Varchar(100),
|
||||
Vorname_Geschaeftlich Varchar(100),
|
||||
Nachname_Geschaeftlich Varchar(100),
|
||||
EMail_Geschaeftlich Varchar(100),
|
||||
Telefonnummer_Geschaeftlich Varchar(100),
|
||||
Strasse_Hausnr Varchar(100),
|
||||
Plz_Ort Varchar(100),
|
||||
Zahlungsmethode Varchar(100),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)`
|
||||
);
|
||||
|
||||
if (createTable) {
|
||||
let nextID;
|
||||
const getNextID = async () => {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT id FROM ${tableName} ORDER BY id DESC LIMIT 1`
|
||||
);
|
||||
nextID = rows.length > 0 ? rows[0].id + 1 : 1;
|
||||
};
|
||||
await getNextID();
|
||||
return { success: true, nextID };
|
||||
} else {
|
||||
return { success: false, message: "Table creation failed" };
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const confirmData = async (data) => {};
|
||||
|
||||
Reference in New Issue
Block a user