/** filters */
import moment from 'moment'

export const dictFilter = dictTypeId => {
	return val => {
		return JSON.parse(localStorage.getItem('dictList'))[dictTypeId].find(item => item.dictValue === val)?.dictLabel || '-'
	}
}

export const timeFilter = (val) => {
	return moment(val).format('YYYY-MM-DD HH:mm:ss')
}

export const pick = (obj, paths) => {
	let result = {}
	paths.forEach(key => {
		if (obj.hasOwnProperty(key)) {
			result[key] = obj[key];
		} else {
			result[key] = null
		}
	})
	return result
}