Skip to content

Commit

Permalink
fix(project): error when assets.banner is null (#180)
Browse files Browse the repository at this point in the history
Fixes #179
  • Loading branch information
ChristiaanScheermeijer authored Oct 11, 2022
1 parent ef57976 commit cd80916
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type TypeHeader = 'static' | 'fixed';
type Props = {
headerType?: TypeHeader;
onMenuButtonClick: () => void;
logoSrc?: string;
logoSrc?: string | null;
searchBarProps: SearchBarProps;
searchEnabled: boolean;
searchActive: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/services/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const configSchema: SchemaOf<Config> = object({
analyticsToken: string().nullable(),
adSchedule: string().nullable(),
assets: object({
banner: string().notRequired(),
banner: string().notRequired().nullable(),
}).notRequired(),
content: array().of(contentSchema),
menu: array().of(menuSchema),
Expand Down
9 changes: 8 additions & 1 deletion src/utils/configLoad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const defaultConfig: Config = {
siteName: '',
description: '',
player: '',
assets: {},
assets: {
banner: '/images/logo.png',
},
content: [],
menu: [],
integrations: {
Expand Down Expand Up @@ -90,6 +92,11 @@ export const loadAndValidateConfig = async (
.then(async (configValidated) => {
const configWithDefaults = merge({}, defaultConfig, configValidated);

// make sure the banner always defaults to the JWP banner when not defined in the config
if (!configWithDefaults.assets.banner) {
configWithDefaults.assets.banner = defaultConfig.assets.banner;
}

const accessModel = calculateAccessModel(configWithDefaults);

useConfigStore.setState({
Expand Down
2 changes: 1 addition & 1 deletion types/Config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Config = {
integrations: {
cleeng?: Cleeng;
};
assets: { banner?: string };
assets: { banner?: string | null };
content: Content[];
menu: Menu[];
styling: Styling;
Expand Down

0 comments on commit cd80916

Please sign in to comment.