//This file is used to store function that help translate MariaDB data to Typescript manipulation requirements for the type "boolean". import { PhoneAddrEnhancedCapable } from "src/customer-support/phones/phone.dto"; //From MariaDB to Frontend export const fromTinyIntToBoolean = async (tinyInt: number): Promise => { let booleanValue = true; if ((tinyInt = 0) || (tinyInt = -1)) return booleanValue = false; return booleanValue; } //From Frontend to MariaDB TinyInt boolean 1 - 0 export const fromBooleanToTinyInt = async (boolean: boolean): Promise => { return boolean ? 1 : 0; } //From Frontend to MariaDB TinyInt boolean -1 - 1 export const fromBooleanToTinyIntNegative = async (boolean: boolean): Promise => { return boolean ? 1 : -1; } //From MariaDB to Frontend String boolean yes - no / Y - N / etc... export const fromStringToBoolean = async (string: string): Promise => { let booleanValue = true; let stringValue = string.toLowerCase(); if ((stringValue = "n") || (stringValue = "no") || (stringValue = "non")) { return booleanValue = false; } return booleanValue; } export const fromBooleanToEnum = async (boolean: boolean): Promise => { return boolean ? PhoneAddrEnhancedCapable.Y : PhoneAddrEnhancedCapable.N; } export const fromEnumToBoolean = async (enumValue: PhoneAddrEnhancedCapable): Promise => { return enumValue ? true : false; }