wisdom #2

Merged
yogiedigital merged 126 commits from wisdom into main 2025-10-20 03:26:33 +00:00
Showing only changes of commit 7ad8c6b3fe - Show all commits

View File

@@ -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,
};