updated absensi lunch_in in API history and admin
This commit is contained in:
@@ -3,13 +3,14 @@ const router = express.Router()
|
|||||||
const controller = require('../controllers/absensi.controller')
|
const controller = require('../controllers/absensi.controller')
|
||||||
const apiKey = require('../../../middlewares/apiKey')
|
const apiKey = require('../../../middlewares/apiKey')
|
||||||
const jwt = require('../../../middlewares/authentication')
|
const jwt = require('../../../middlewares/authentication')
|
||||||
|
const checkRole = require('../../../middlewares/checkRole')
|
||||||
const upload = require('../../../middlewares/upload')
|
const upload = require('../../../middlewares/upload')
|
||||||
|
|
||||||
router.get('/history', apiKey, jwt, (req, res) => {
|
router.get('/history', apiKey, jwt, (req, res) => {
|
||||||
controller.history(req, res);
|
controller.history(req, res);
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/', apiKey, (req, res) => {
|
router.get('/', apiKey, jwt, checkRole('admin'), (req, res) => {
|
||||||
controller.getAll(req, res)
|
controller.getAll(req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ const history = async (req, res) => {
|
|||||||
const result = attendances.map(a => {
|
const result = attendances.map(a => {
|
||||||
let duration = null;
|
let duration = null;
|
||||||
|
|
||||||
if (a.clock_in && a.clock_out) {
|
if (a.clock_in && a.clock_out && a.lunch_in) {
|
||||||
const diffMs = new Date(a.clock_out) - new Date(a.clock_in);
|
const diffMs = new Date(a.clock_out) - new Date(a.clock_in);
|
||||||
const totalMinutes = Math.floor(diffMs / 60000);
|
const totalMinutes = Math.floor(diffMs / 60000);
|
||||||
const hours = Math.floor(totalMinutes / 60);
|
const hours = Math.floor(totalMinutes / 60);
|
||||||
@@ -283,6 +283,9 @@ const history = async (req, res) => {
|
|||||||
clock_out: a.clock_out
|
clock_out: a.clock_out
|
||||||
? moment(a.clock_out).tz('Asia/Jakarta').format('YYYY-MM-DD HH:mm:ss')
|
? moment(a.clock_out).tz('Asia/Jakarta').format('YYYY-MM-DD HH:mm:ss')
|
||||||
: '-',
|
: '-',
|
||||||
|
lunch_in: a.lunch_in
|
||||||
|
? moment(a.lunch_in).tz('Asia/Jakarta').format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
: '-',
|
||||||
duration: duration || '-',
|
duration: duration || '-',
|
||||||
type: a.type,
|
type: a.type,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user