diff --git a/db/user.db.js b/db/user.db.js index 28f152a..c8772b6 100644 --- a/db/user.db.js +++ b/db/user.db.js @@ -132,11 +132,12 @@ const updateUserDb = async (userId, data) => { return getUserByIdDb(userId); }; +// Approve user const approveUserDb = async (userId, approverId) => { const queryText = ` UPDATE m_users SET - is_approve = 1, + is_approve = 2, approved_by = $1, approved_at = CURRENT_TIMESTAMP, updated_by = $1, @@ -144,9 +145,24 @@ const approveUserDb = async (userId, approverId) => { WHERE user_id = $2 AND deleted_at IS NULL `; await pool.query(queryText, [approverId, userId]); - return true; // simple, cuma tanda berhasil + return true; }; +// Reject user +const rejectUserDb = async (userId, approverId) => { + const queryText = ` + UPDATE m_users + SET + is_approve = 0, + approved_by = $1, + approved_at = CURRENT_TIMESTAMP, + updated_by = $1, + updated_at = CURRENT_TIMESTAMP + WHERE user_id = $2 AND deleted_at IS NULL + `; + await pool.query(queryText, [approverId, userId]); + return true; +} // Change user password const changeUserPasswordDb = async (userId, newPassword) => { @@ -182,6 +198,7 @@ module.exports = { createUserDb, updateUserDb, approveUserDb, + rejectUserDb, changeUserPasswordDb, deleteUserDb, };