yazid138 %!s(int64=3) %!d(string=hai) anos
pai
achega
e85c23925f
Modificáronse 1 ficheiros con 6 adicións e 10 borrados
  1. 6 10
      utils/cekData.js

+ 6 - 10
utils/cekData.js

@@ -9,7 +9,7 @@ exports.cekSatuDataLaporan = async (
   laporan_id,
   where = { delegasi: false, aktif: true }
 ) => {
-  const w = { _id: laporan_id,...where }
+  const w = { _id: laporan_id, aktif: where.aktif || true, ...where }
   switch (user.role.id) {
     case 2020:
       if (!where.delegasi) w.role_data = 'dikti'
@@ -48,12 +48,8 @@ exports.cekSatuDataLaporan = async (
   return laporan
 }
 
-exports.cekBanyakDataLaporan = async (
-  user,
-  where = { delegasi: false, aktif: true }
-) => {
-  const w = { ...where }
-  if (where.aktif === false) w.aktif = false
+exports.cekBanyakDataLaporan = async (user, where = { delegasi: false }) => {
+  const w = { aktif: where.aktif || true, ...where }
   switch (user.role.id) {
     case 2020:
       if (!where.delegasi) w.role_data = 'dikti'
@@ -91,9 +87,9 @@ exports.cekSatuDataSanksi = async (
   res,
   user,
   sanksi_id,
-  where = { banding: false, aktif: true }
+  where = { banding: false }
 ) => {
-  const w = { aktif: where.aktif }
+  const w = { aktif: where.aktif || true }
   switch (user.role.id) {
     case 2020:
       if (!where.banding) w.role_data = 'dikti'
@@ -138,7 +134,7 @@ exports.cekBanyakDataSanksi = async (
   user,
   where = { banding: false, aktif: true }
 ) => {
-  const w = { aktif: where.aktif }
+  const w = { aktif: where.aktif || true }
   switch (user.role.id) {
     case 2020:
       if (!where.banding) {