2022-10-13 08:26:28 +00:00
|
|
|
import { APP_WILL_MOUNT } from '../base/app/actionTypes';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
2021-09-10 07:00:54 +00:00
|
|
|
|
2021-11-15 08:37:54 +00:00
|
|
|
import { SET_DYNAMIC_BRANDING_DATA } from './actionTypes';
|
2022-05-23 15:02:14 +00:00
|
|
|
import { fetchCustomBrandingData } from './actions.any';
|
2021-11-16 21:16:18 +00:00
|
|
|
import { createMuiBrandingTheme } from './functions.web';
|
2021-09-10 07:00:54 +00:00
|
|
|
|
2022-05-23 15:02:14 +00:00
|
|
|
|
2021-09-10 07:00:54 +00:00
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
switch (action.type) {
|
|
|
|
case APP_WILL_MOUNT: {
|
|
|
|
|
|
|
|
store.dispatch(fetchCustomBrandingData());
|
|
|
|
break;
|
|
|
|
}
|
2021-11-15 08:37:54 +00:00
|
|
|
case SET_DYNAMIC_BRANDING_DATA: {
|
|
|
|
const { customTheme } = action.value;
|
|
|
|
|
|
|
|
if (customTheme) {
|
|
|
|
action.value.muiBrandedTheme = createMuiBrandingTheme(customTheme);
|
|
|
|
}
|
|
|
|
}
|
2021-09-10 07:00:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|