import { capitalizeEachWord } from '@pos/base';

export enum ACCESS_CONTROL_ROLE {
  SYSTEM = 'System',
  GLOBAL = 'Global',
  ORGANIZATION = 'Organization',
  CONTACT_LEVEL = 'Contact Level',
  ACCESS_TO_CONTACT = 'Access to Contact',
  SUPER_ADMIN = 'Super Admin',
}

export enum ACCESS_TO_CONTACT_TYPE {
  RESTRICTED = 'Restricted',
  ADDITIONAL = 'Additional',
}

export enum PRIVILEGE_ACTION {
  VIEW = 'VIEW',
  CREATE = 'CREATE',
  EDIT = 'EDIT',
  DELETE = 'DELETE',
  CHANGE_STATUS = 'CHANGE_STATUS',
  CONFIRM = 'CONFIRM',
  VIEW_EXTERNAL_LINK = 'VIEW_EXTERNAL_LINK',
  DOWNLOAD = 'DOWNLOAD',
  CANCEL = 'CANCEL',
}

export enum PRIVILEGE_CONDITION {
  ORGANIZATION = 'ORGANIZATION',
  DEPARTMENT = 'DEPARTMENT',
  MINISTRY_POSITION = 'MINISTRY_POSITION',
  TEAM = 'TEAM',
  CARE_GROUP = 'CARE_GROUP',
  TASK = 'TASK',
  EVENT = 'EVENT',
  ONLY_OWN = 'ONLY_OWN',
}

export enum PRIVILEGE_CONDITION_VALUE {
  OWN = 'OWN',
  ALL = 'ALL',
  WITH_CHILD = 'WITH_CHILD',
  TRUE = 'TRUE',
  FALSE = 'FALSE',
  PIC = 'PIC',
  COORDINATOR = 'COORDINATOR',
}

export function generatePrivilegeValueOptions() {
  const options = {};
  Object.values(PRIVILEGE_CONDITION_VALUE).forEach((el) => {
    Object.assign(options, {
      [`${el}`]: {
        label: capitalizeEachWord(el.split('_').join(' ').toLowerCase()),
        value: el,
      },
    });
  });
  return options;
}

export const AccessControlRoleOpt: any = {
  [`${ACCESS_CONTROL_ROLE.SUPER_ADMIN}`]: {
    label: 'Super Admin',
    value: ACCESS_CONTROL_ROLE.SUPER_ADMIN,
  },
  [`${ACCESS_CONTROL_ROLE.SYSTEM}`]: {
    label: 'System Admin',
    value: ACCESS_CONTROL_ROLE.SYSTEM,
  },
  [`${ACCESS_CONTROL_ROLE.GLOBAL}`]: {
    label: 'Global Officer',
    value: ACCESS_CONTROL_ROLE.GLOBAL,
  },
  [`${ACCESS_CONTROL_ROLE.ORGANIZATION}`]: {
    label: 'Organization Officer',
    value: ACCESS_CONTROL_ROLE.ORGANIZATION,
  },
};
