add: rejectuserdb + default approve 2
This commit is contained in:
@@ -132,11 +132,12 @@ const updateUserDb = async (userId, data) => {
|
|||||||
return getUserByIdDb(userId);
|
return getUserByIdDb(userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Approve user
|
||||||
const approveUserDb = async (userId, approverId) => {
|
const approveUserDb = async (userId, approverId) => {
|
||||||
const queryText = `
|
const queryText = `
|
||||||
UPDATE m_users
|
UPDATE m_users
|
||||||
SET
|
SET
|
||||||
is_approve = 1,
|
is_approve = 2,
|
||||||
approved_by = $1,
|
approved_by = $1,
|
||||||
approved_at = CURRENT_TIMESTAMP,
|
approved_at = CURRENT_TIMESTAMP,
|
||||||
updated_by = $1,
|
updated_by = $1,
|
||||||
@@ -144,9 +145,24 @@ const approveUserDb = async (userId, approverId) => {
|
|||||||
WHERE user_id = $2 AND deleted_at IS NULL
|
WHERE user_id = $2 AND deleted_at IS NULL
|
||||||
`;
|
`;
|
||||||
await pool.query(queryText, [approverId, userId]);
|
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
|
// Change user password
|
||||||
const changeUserPasswordDb = async (userId, newPassword) => {
|
const changeUserPasswordDb = async (userId, newPassword) => {
|
||||||
@@ -182,6 +198,7 @@ module.exports = {
|
|||||||
createUserDb,
|
createUserDb,
|
||||||
updateUserDb,
|
updateUserDb,
|
||||||
approveUserDb,
|
approveUserDb,
|
||||||
|
rejectUserDb,
|
||||||
changeUserPasswordDb,
|
changeUserPasswordDb,
|
||||||
deleteUserDb,
|
deleteUserDb,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user