Bona Iqiniso Application Board

V3BiAlertBase

Specification for V3BiAlertBase

Attributes

AttributeTypeDescription
referencestringUnique identifier for the alert
statestringState of the alert, must be one of ['error', 'warning', 'info', 'success']
translationsV3BiTranslationBase[]Array of translations for different languages

Methods

MethodDescription
constructorInitializes a new instance of V3BiAlertBase with the provided reference, state, and translations.
getAlertReturns the alert message in the specified language, or ‘unknown alert’ if the translation is not found.

Constructor

Signature:

constructor(reference: string, state: string, translations: V3BiTranslationBase[])

Parameters:

  • reference (string): Unique identifier for the alert.
  • state (string): State of the alert.
  • translations (V3BiTranslationBase[]): Array of translations for different languages.

Description:
The constructor initializes the V3BiAlertBase instance with the provided reference, state, and translations. Throws an error if state is not one of ['error', 'warning', 'info', 'success'].

Method: getAlert

Signature:

getAlert(language: string): string

Parameters:

  • language (string): The language code for which the alert message is requested.

Description:
Returns the alert message in the specified language, or ‘unknown alert’ if the translation is not found.

Example Usage

const translations = [
  new V3BiTranslationBase('en', 'Error occurred'),
  new V3BiTranslationBase('es', 'Ocurrió un error')
];
const alert = new V3BiAlertBase('alert1', 'error', translations);
console.log(alert.getAlert('en')); // Output: Error occurred
console.log(alert.getAlert('fr')); // Output: unknown alert