2024-10-20 20:12:27 +02:00
|
|
|
import {Cookies} from "react-cookie";
|
|
|
|
|
2024-10-20 17:54:38 +02:00
|
|
|
export default interface IFrontendSettings {
|
|
|
|
jobInterval: Date;
|
2024-10-20 20:12:27 +02:00
|
|
|
apiUri: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function FrontendSettingsWith(settings: IFrontendSettings | undefined, jobInterval: Date | undefined, apiUri: string | undefined): IFrontendSettings {
|
|
|
|
const cookies = new Cookies();
|
|
|
|
let transform : IFrontendSettings;
|
|
|
|
if(settings === undefined) {
|
|
|
|
transform = {
|
|
|
|
apiUri: apiUri === undefined
|
|
|
|
? cookies.get('apiUri') === undefined
|
|
|
|
? `${window.location.protocol}//${window.location.host}/api`
|
|
|
|
: cookies.get('apiUri')
|
|
|
|
: apiUri,
|
|
|
|
jobInterval: jobInterval === undefined
|
|
|
|
? cookies.get('jobInterval') === undefined
|
|
|
|
? new Date(0,0,0,3)
|
|
|
|
: cookies.get('jobInterval')
|
|
|
|
: jobInterval
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
transform = {
|
|
|
|
apiUri: apiUri === undefined ? settings.apiUri : apiUri,
|
|
|
|
jobInterval: jobInterval === undefined ? settings.jobInterval : jobInterval,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.debug(settings);
|
|
|
|
console.debug(transform);
|
|
|
|
return transform;
|
2024-10-20 17:54:38 +02:00
|
|
|
}
|