@logcomex/aylawc-core
Version:
An experimental library of web components
56 lines • 2.7 kB
JavaScript
import { useCore } from '..';
import { TranslationEvents } from '../translation';
export class Integration {
constructor(env) {
this._env = env;
const session = localStorage.getItem('session');
if (session)
this._session = JSON.parse(session);
}
loader() {
useCore().event.subscribe(TranslationEvents.OnLocaleChange, () => {
this.setGlobalLinks();
});
this.setGlobalLinks();
}
get env() {
return this._env;
}
set env(environment) {
this._env = environment;
}
get session() {
return this._session;
}
setGlobalLinks() {
var _a, _b;
const token = localStorage.getItem('token') || '';
// @TODO: precisa implementar um mecanismo de captura de cookies para colocar o real valor no attributo: cookiesHasBeenAccepted
const queryParamsDefault = `?token=${token}&email=${(_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.email}&cookiesHasBeenAccepted=true`;
const currentLanguage = useCore().translation.currentLanguage;
this._globalLinks = {
homol: {
profile: 'https://plataforma.homol.logcomex.io/profile/',
settings: `https://sistema.homol.logcomex.io/#/empresa${queryParamsDefault}`,
certificates: 'https://plataforma.homol.logcomex.io/certificates/',
termsOfUse: currentLanguage === 'pt-br' ? 'https://www.logcomex.com/terms' : 'https://en.logcomex.com/terms',
consumptionReport: `https://sistema.homol.logcomex.io/#/relatorio-consumo${queryParamsDefault}`,
accessReport: `https://sistema.homol.logcomex.io/#/relatorio-acesso${queryParamsDefault}`,
exit: 'https://plataforma.homol.logcomex.io/logout/'
},
production: {
profile: 'https://plataforma.logcomex.io/profile/',
settings: `https://sistema.logcomex.io/#/empresa${queryParamsDefault}`,
certificates: 'https://plataforma.logcomex.io/certificates/',
termsOfUse: currentLanguage === 'pt-br' ? 'https://www.logcomex.com/terms' : 'https://en.logcomex.com/terms',
consumptionReport: `https://sistema.logcomex.io/#/relatorio-consumo${queryParamsDefault}`,
accessReport: `https://sistema.logcomex.io/#/relatorio-acesso${queryParamsDefault}`,
exit: 'https://plataforma.logcomex.io/logout/'
}
};
}
getGlobalLink(slug) {
return this._globalLinks[this._env][slug] || '';
}
}
//# sourceMappingURL=integration.js.map