Integrated "created by" system
This commit is contained in:
@@ -56,9 +56,11 @@ eventRouter.get('/attendees/:id', async (req: Request, res: Response) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
eventRouter.post('/', async (req: Request, res: Response) => {
|
eventRouter.post('/', async (req: Request, res: Response) => {
|
||||||
|
const posterID: number = req.user.id;
|
||||||
try {
|
try {
|
||||||
console.log();
|
console.log();
|
||||||
const data: CourseEventDetails = req.body;
|
let data: CourseEventDetails = req.body;
|
||||||
|
data.created_by = posterID;
|
||||||
const id = await insertCourseEvent(data);
|
const id = await insertCourseEvent(data);
|
||||||
res.status(201).json(id);
|
res.status(201).json(id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -21,3 +21,14 @@ export async function setUserState(userID: number, state: MemberState) {
|
|||||||
WHERE id = ?;`;
|
WHERE id = ?;`;
|
||||||
return await pool.query(sql, [state, userID]);
|
return await pool.query(sql, [state, userID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Express {
|
||||||
|
interface Request {
|
||||||
|
user: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export async function postTrainingReport(report: CourseEventDetails) {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(report),
|
body: JSON.stringify(report),
|
||||||
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user