feat: add user confirmation functionality and dynamic table creation; enhance MainForm with user selection and next ID display
This commit is contained in:
@@ -3,7 +3,7 @@ import dotenv from "dotenv";
|
||||
const router = express.Router();
|
||||
dotenv.config();
|
||||
|
||||
import { getUser, confirmData } from "./frontend.data.js";
|
||||
import { getUser, confirmData, confirmUser } from "./frontend.data.js";
|
||||
|
||||
router.post("/frontend", async (req, res) => {
|
||||
const result = await confirmData(req.body);
|
||||
@@ -11,7 +11,6 @@ router.post("/frontend", async (req, res) => {
|
||||
return res.status(500).json({ message: "Form Data Invalid" });
|
||||
}
|
||||
console.log(req.body);
|
||||
const user = await getUser(req.body.code);
|
||||
console.log(user);
|
||||
res.sendStatus(204);
|
||||
});
|
||||
@@ -21,4 +20,16 @@ router.get("/users", async (req, res) => {
|
||||
res.json(users);
|
||||
});
|
||||
|
||||
router.get("/confirm-user", async (req, res) => {
|
||||
const username = req.query.username;
|
||||
if (!username) {
|
||||
return res.status(400).json({ message: "Username is required" });
|
||||
}
|
||||
const user = await confirmUser(username);
|
||||
if (!user) {
|
||||
return res.status(404).json({ message: "User not found" });
|
||||
}
|
||||
res.json(user);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user