You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
842 B
JavaScript
43 lines
842 B
JavaScript
import moment from "moment";
|
|
|
|
export const statuses = [
|
|
{
|
|
key: 0,
|
|
value: 'Aktif',
|
|
color: 'green'
|
|
},
|
|
{
|
|
key: 1,
|
|
value: 'Update',
|
|
color: 'rgb(229, 195, 24)'
|
|
},
|
|
{
|
|
key: 2,
|
|
value: 'Expired',
|
|
color: 'red'
|
|
}
|
|
]
|
|
|
|
export const validateEmail = (email) => {
|
|
return String(email)
|
|
.toLowerCase()
|
|
.match(
|
|
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
);
|
|
};
|
|
|
|
export const formatDate = (stringDate) => {
|
|
return moment(stringDate).format('DD-MM-yyyy')
|
|
}
|
|
|
|
export const hasPermission = (permission, user) => {
|
|
if (+user.is_admin === 1) {
|
|
return true;
|
|
}
|
|
|
|
const allowed = user.role.permissions.find(i => i.name === permission)
|
|
if(allowed) {
|
|
return true
|
|
}
|
|
return false
|
|
} |