Merge remote-tracking branch 'Origin/main' into promotions
This commit is contained in:
@@ -32,6 +32,8 @@ export async function getApplicationByID(appID: number): Promise<ApplicationRow>
|
||||
}
|
||||
|
||||
export async function getApplicationList(page: number = 1, pageSize: number = 25): Promise<ApplicationListRow[]> {
|
||||
const offset = (page - 1) * pageSize;
|
||||
|
||||
const sql = `SELECT
|
||||
member.name AS member_name,
|
||||
app.id,
|
||||
@@ -44,7 +46,7 @@ export async function getApplicationList(page: number = 1, pageSize: number = 25
|
||||
ORDER BY app.submitted_at DESC
|
||||
LIMIT ? OFFSET ?;`
|
||||
|
||||
const rows: ApplicationListRow[] = await pool.query(sql, [pageSize, page]);
|
||||
const rows: ApplicationListRow[] = await pool.query(sql, [pageSize, offset]);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@@ -71,7 +73,6 @@ export async function approveApplication(id: number, approver: number) {
|
||||
`;
|
||||
|
||||
const result = await pool.execute(sql, [approver, id]);
|
||||
console.log(result);
|
||||
if (result.affectedRows == 1) {
|
||||
return
|
||||
} else {
|
||||
@@ -89,7 +90,6 @@ export async function denyApplication(id: number, approver: number) {
|
||||
`;
|
||||
|
||||
const result = await pool.execute(sql, [approver, id]);
|
||||
console.log(result);
|
||||
if (result.affectedRows == 1) {
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -126,6 +126,5 @@ export async function getEventAttendance(eventID: number): Promise<CalendarSignu
|
||||
|
||||
const sql = "CALL `sp_GetCalendarEventSignups`(?)"
|
||||
const res = await pool.query(sql, [eventID]);
|
||||
console.log(res[0]);
|
||||
return res[0];
|
||||
}
|
||||
@@ -36,7 +36,10 @@ export async function getAllLOA(page = 1, pageSize = 10): Promise<PagedData<LOAR
|
||||
return output;
|
||||
}
|
||||
|
||||
export async function getUserLOA(userId: number): Promise<LOARequest[]> {
|
||||
export async function getUserLOA(userId: number, page = 1, pageSize = 10): Promise<PagedData<LOARequest>> {
|
||||
|
||||
const offset = (page - 1) * pageSize;
|
||||
|
||||
const result: LOARequest[] = await pool.query(`
|
||||
SELECT loa.*, members.name, t.name AS type_name
|
||||
FROM leave_of_absences AS loa
|
||||
@@ -53,8 +56,12 @@ export async function getUserLOA(userId: number): Promise<LOARequest[]> {
|
||||
WHEN loa.closed IS NOT NULL THEN 4
|
||||
END,
|
||||
loa.start_date DESC
|
||||
`, [userId])
|
||||
return result;
|
||||
LIMIT ? OFFSET ?;`, [userId, pageSize, offset])
|
||||
|
||||
let loaCount = Number((await pool.query(`SELECT COUNT(*) as count FROM leave_of_absences WHERE member_id = ?;`, [userId]))[0].count);
|
||||
let pageCount = loaCount / pageSize;
|
||||
let output: PagedData<LOARequest> = { data: result, pagination: { page: page, pageSize: pageSize, total: loaCount, totalPages: pageCount } }
|
||||
return output;
|
||||
}
|
||||
|
||||
export async function getUserActiveLOA(userId: number): Promise<LOARequest[]> {
|
||||
@@ -82,13 +89,11 @@ export async function closeLOA(id: number, closer: number) {
|
||||
ended_at = NOW()
|
||||
WHERE leave_of_absences.id = ?`;
|
||||
let out = await pool.query(sql, [closer, id]);
|
||||
console.log(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
export async function getLOAbyID(id: number): Promise<LOARequest> {
|
||||
let res = await pool.query(`SELECT * FROM leave_of_absences WHERE id = ?`, [id]);
|
||||
console.log(res);
|
||||
if (res.length != 1)
|
||||
throw new Error(`LOA with id ${id} not found`);
|
||||
return res[0];
|
||||
|
||||
@@ -34,7 +34,6 @@ export async function setUserSettings(id: number, settings: memberSettings) {
|
||||
displayName = ?
|
||||
WHERE id = ?;`;
|
||||
let result = await pool.query(sql, [settings.displayName, id])
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
export async function getMembersLite(ids: number[]): Promise<MemberLight[]> {
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function getUserRoles(userID: number): Promise<Role[]> {
|
||||
const sql = `SELECT r.id, r.name
|
||||
FROM members_roles mr
|
||||
INNER JOIN roles r ON mr.role_id = r.id
|
||||
WHERE mr.member_id = 190;`;
|
||||
WHERE mr.member_id = ?;`;
|
||||
|
||||
return await pool.query(sql, [userID]);
|
||||
}
|
||||
Reference in New Issue
Block a user