Commit 093a632e authored by Maksym Tishchenko's avatar Maksym Tishchenko
Browse files

Added configuration class for showGenesysUI

parent 7f9973fa
import { showGenesysUI } from 'genesys';
// For testing purposes
const { API_URL, CLIENT_ID, CLIENT_SECRET } = {
CLIENT_ID: 'defaultclient@localhost',
CLIENT_SECRET: 'changeme',
API_URL: 'http://localhost:8080',
};
const queryLang = document.location.search && document.location.search.substr(1) || undefined;
showGenesysUI(API_URL, CLIENT_ID, CLIENT_SECRET, document.getElementById('genesys'), { institute: { code: [ 'COL003', 'BEL084', 'ETH013' ] } }, queryLang);
showGenesysUI(document.getElementById('genesys'),
{
clientId: 'defaultclient@localhost',
clientKey: 'changeme',
apiUrl: 'http://localhost:8080',
filter: { institute: { code: [ 'COL003', 'BEL084', 'ETH013' ] } },
}, queryLang);
......@@ -41,13 +41,19 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin
return appLogin;
};
class Config {
public apiUrl: string = 'https://api.sandbox.genesys-pgr.org';
public clientId: string = 'clientid@genesys';
public clientKey: string = 'changeme';
public filter: object = {};
}
export function showGenesysUI(apiUrl: string, clientId: string, clientSecret: string, holdingNode: HTMLElement, filter: object = {}, language: string = "en") {
export function showGenesysUI(holdingNode: HTMLElement, { apiUrl, clientId, clientKey, filter }: Config, language: string = "en") {
reconfigureServiceAxios({ apiUrl });
initI18n(language);
checkAccessTokens(apiUrl, clientId, clientSecret).then( (result) => {
checkAccessTokens(apiUrl, clientId, clientKey).then( (result) => {
ReactDOM.render(
<App filter={ filter } apiUrl={ apiUrl } />,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment