@railzai/railz-visualizations
Version:
Railz.ai Visualizations
169 lines • 5.98 kB
JavaScript
/*!
* Accounting Data as a Service™ is the solution that makes sense of your business customers' financial data.
* Built with Stencil
* Copyright (c) FIS.
*/
/* eslint-disable max-len, @typescript-eslint/no-unused-vars */
import { Component, Prop, h, State, Watch } from '@stencil/core';
import { isEqual } from 'lodash-es';
import { isCreditScore, isIncomeStatements, isStatements, isTransactions, } from '../../helpers/utils';
import { RVReportTypes, } from '../../types';
import { getConfiguration, getFilter } from '../../helpers/chart.utils';
import { ConfigurationInstance } from '../../services/configuration';
export class Core {
constructor() {
this.propsUpdated = () => {
this.validateParams(this.configuration, this.filter);
};
/**
* Validates if configuration was passed correctly before setting filter
* @param configuration - Config for authentication
* @param filter - filter to decide chart type to show
*/
this.validateParams = (configuration, filter) => {
this._configuration = getConfiguration(configuration);
if (this._configuration) {
ConfigurationInstance.configuration = this._configuration;
this._filter = getFilter(filter);
if (!this._filter) {
this.errorStatusCode = 204;
}
}
else {
this.errorStatusCode = 0;
}
};
}
watchFilter(newValue, oldValue) {
if (newValue && oldValue && !isEqual(oldValue, newValue)) {
this.validateParams(this.configuration, newValue);
}
}
watchConfiguration(newValue, oldValue) {
if (newValue && oldValue && !isEqual(oldValue, newValue)) {
this.validateParams(newValue, this.filter);
}
}
componentDidLoad() {
this.propsUpdated && this.propsUpdated();
}
render() {
var _a;
if (this.errorStatusCode === 0) {
return null;
}
if (this.errorStatusCode !== undefined) {
return (h("div", { class: "rv-container" },
h("railz-error-image", { statusCode: this.errorStatusCode || 500 })));
}
const reportType = (_a = this._filter) === null || _a === void 0 ? void 0 : _a.reportType;
if (RVReportTypes.BANK_RECONCILIATION === reportType) {
return (h("railz-bank-reconciliation", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (RVReportTypes.BUSINESS_VALUATIONS === reportType) {
return (h("railz-business-valuations", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (RVReportTypes.BANK_ACCOUNT === reportType) {
return (h("railz-bank-accounts", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (RVReportTypes.FINANCIAL_RATIO === reportType) {
return (h("railz-financial-ratios", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (isCreditScore(reportType)) {
return (h("railz-credit-score", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (isIncomeStatements(reportType)) {
return (h("railz-income-statements", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (isStatements(reportType)) {
return (h("railz-statements-chart", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
if (isTransactions(reportType)) {
return (h("railz-transactions-control", { configuration: this.configuration, filter: this.filter, options: this.options }));
}
return h("span", null);
}
static get is() { return "railz-visualizations"; }
static get encapsulation() { return "shadow"; }
static get originalStyleUrls() { return {
"$": ["core.scss"]
}; }
static get styleUrls() { return {
"$": ["core.css"]
}; }
static get properties() { return {
"configuration": {
"type": "unknown",
"mutable": false,
"complexType": {
"original": "RVConfiguration",
"resolved": "RVConfiguration",
"references": {
"RVConfiguration": {
"location": "import",
"path": "../../types"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Configuration information like authentication configuration"
}
},
"filter": {
"type": "unknown",
"mutable": false,
"complexType": {
"original": "RVFilterAllReportTypes",
"resolved": "RVFilterBalanceSheet | RVFilterBankAccount | RVFilterBankReconciliation | RVFilterBills | RVFilterBusinessValuations | RVFilterCashflowStatements | RVFilterCreditScore | RVFilterDate | RVFilterExpenses | RVFilterFinancialRatio | RVFilterIncomeStatements | RVFilterInvoices | RVFilterRevenue",
"references": {
"RVFilterAllReportTypes": {
"location": "import",
"path": "../../types"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Filter information to query the backend APIs"
}
},
"options": {
"type": "unknown",
"mutable": false,
"complexType": {
"original": "RVOptions",
"resolved": "RVOptions",
"references": {
"RVOptions": {
"location": "import",
"path": "../../types"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "For whitelabeling styling"
}
}
}; }
static get states() { return {
"_filter": {},
"_configuration": {},
"errorStatusCode": {}
}; }
static get watchers() { return [{
"propName": "filter",
"methodName": "watchFilter"
}, {
"propName": "configuration",
"methodName": "watchConfiguration"
}]; }
}
//# sourceMappingURL=core.js.map