2015-11-04 11:36:42 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import requests from '../utils/requests';
|
|
|
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
|
|
|
|
2016-06-13 14:35:02 +02:00
|
|
|
import { getSubdomain } from '../utils/general';
|
2015-11-04 11:36:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
const WhitelabelSource = {
|
|
|
|
lookupWhitelabel: {
|
|
|
|
remote() {
|
2016-01-15 13:55:58 +01:00
|
|
|
return requests.get('whitelabel_settings', { 'subdomain': getSubdomain() });
|
2015-11-04 11:36:42 +01:00
|
|
|
},
|
2016-01-15 13:55:58 +01:00
|
|
|
|
2015-11-04 11:36:42 +01:00
|
|
|
local(state) {
|
2016-01-15 13:55:58 +01:00
|
|
|
return Object.keys(state.whitelabel).length ? state : {};
|
2015-11-04 11:36:42 +01:00
|
|
|
},
|
2016-01-15 13:55:58 +01:00
|
|
|
|
2015-11-04 11:36:42 +01:00
|
|
|
success: WhitelabelActions.successFetchWhitelabel,
|
2015-11-16 17:16:13 +01:00
|
|
|
error: WhitelabelActions.errorWhitelabel,
|
2016-01-15 13:55:58 +01:00
|
|
|
|
|
|
|
shouldFetch(state, invalidateCache) {
|
|
|
|
return invalidateCache || !Object.keys(state.whitelabel).length;
|
2015-11-04 11:36:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-15 13:55:58 +01:00
|
|
|
export default WhitelabelSource;
|