yazid138 3 éve
szülő
commit
c67d3f2a02
2 módosított fájl, 6 hozzáadás és 3 törlés
  1. 4 1
      controller/sanksi.controller.js
  2. 2 2
      utils/cekData.js

+ 4 - 1
controller/sanksi.controller.js

@@ -128,13 +128,16 @@ exports.getOne = handleError(async (req, res) => {
   const { sanksi_id } = req.params
 
   const w = {}
-  const { banding } = req.query
+  const { banding, aktif } = req.query
   if (banding === 'true') {
     w.banding = true
     w['pengajuan.keberatan'] = { $exists: true, $ne: null }
     w['jawaban.keberatan'] = { $exists: true, $ne: null }
     w['pengajuan.banding'] = { $exists: true, $ne: null }
   }
+  if (aktif && aktif === 'false') {
+    w.aktif = false
+  }
 
   const sanksi = await cekSatuDataSanksi(res, user, sanksi_id, w)
   if (!sanksi) return

+ 2 - 2
utils/cekData.js

@@ -89,9 +89,9 @@ exports.cekSatuDataSanksi = async (
   res,
   user,
   sanksi_id,
-  where = { banding: false }
+  where = { banding: false, aktif: true }
 ) => {
-  const w = { aktif: true }
+  const w = { aktif: where.aktif }
   switch (user.role.id) {
     case 2020:
       if (!where.banding) w.role_data = 'dikti'