saleor-apps-redis_apl/apps/emails-and-messages/src/modules/app-configuration/fallback-app-config.ts
Krzysztof Wolski 1af3996e39
Add emails and messages app (#236)
* Add emails and messages app
2023-03-09 09:14:29 +01:00

22 lines
689 B
TypeScript

import { AppConfig } from "./app-config";
import { AppConfigContainer, getDefaultEmptyAppConfiguration } from "./app-config-container";
import { ChannelFragment, ShopInfoFragment } from "../../../generated/graphql";
/**
* TODO Test
*/
export const FallbackAppConfig = {
createFallbackConfigFromExistingShopAndChannels(
channels: ChannelFragment[],
shopAppConfiguration: ShopInfoFragment | null
) {
return (channels ?? []).reduce<AppConfig>(
(state, channel) => {
return AppConfigContainer.setChannelAppConfiguration(state)(channel.slug)(
getDefaultEmptyAppConfiguration()
);
},
{ configurationsPerChannel: {} }
);
},
};