import { MettaSvr_Common } from "./action-enums"
import moment from "moment"


export const UtilGenderToString = (genderEnum) => {
    if(!!genderEnum){
        const found = Object.keys(MettaSvr_Common.GenderEnum).filter(key => MettaSvr_Common.GenderEnum[key] === genderEnum)
        return found ?? "invalid"
    }
    return ""
}

export const UtilDateFormatter = dateString => {
    return !!dateString ? moment(dateString).format("DD MMM. YYYY") : ""
}

export const UtilityJsonArray = (sourceString, key) => {
    return JSON.parse(sourceString)[key] ?? []
}