saleor-apps-redis_apl/apps/invoices/src/modules/app-configuration/fallback-app-config.ts
Lukasz Ostrowski 0219561dd9
Remove firstName and lastName from billing address of the company and form (#143)
* [Invoices] Remove firstName and lastName from billing address of the company and form

* Fix fixtures
2023-02-10 16:29:54 +01:00

29 lines
1.1 KiB
TypeScript

import { AppConfig } from "./app-config";
import { AppConfigContainer } from "./app-config-container";
import { ChannelFragment, ShopInfoFragment } from "../../../generated/graphql";
/**
* TODO Test
*/
export const FallbackAppConfig = {
createFallbackConfigFromExistingShopAndChannels(
channels: ChannelFragment[],
shopAddress: ShopInfoFragment | null
) {
return (channels ?? []).reduce<AppConfig>(
(state, channel) => {
return AppConfigContainer.setChannelAddress(state)(channel.slug)({
city: shopAddress?.companyAddress?.city ?? "",
cityArea: shopAddress?.companyAddress?.cityArea ?? "",
companyName: shopAddress?.companyAddress?.companyName ?? "",
country: shopAddress?.companyAddress?.country.country ?? "",
countryArea: shopAddress?.companyAddress?.countryArea ?? "",
postalCode: shopAddress?.companyAddress?.postalCode ?? "",
streetAddress1: shopAddress?.companyAddress?.streetAddress1 ?? "",
streetAddress2: shopAddress?.companyAddress?.streetAddress2 ?? "",
});
},
{ shopConfigPerChannel: {} }
);
},
};