Skip to content

Commit

Permalink
Moved system name from env to theme. (#14)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8395f4a)
  • Loading branch information
kiran-rean authored Dec 27, 2023
1 parent 89b8c9a commit b1660ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/lib/themes/aha.theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ export const TickColorDark = '#DED6EC';
export const PUBLIC_LOGO_IMAGE_SOURCE='https://www.heart.org/-/media/Images/Logos/Global-Do-No-Edit/Header/AHA_Full.svg?h=256&iar=0&mw=960&w=426&hash=502DC0C0397CFBA7EA1142C51E062876';
export const PUBLIC_FOOTER_TEXT='American Heart Association'
export const PUBLIC_FOOTER_LINK='https://www.heart.org'
export const SYSTEM_NAME = 'American Heart Association';
1 change: 1 addition & 0 deletions src/lib/themes/rean.theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ export const TickColorDark = '#DED6EC';
export const PUBLIC_LOGO_IMAGE_SOURCE='https://www.reanfoundation.org/wp-content/uploads/2021/10/REAN-Foundation-brand-Logo.png';
export const PUBLIC_FOOTER_TEXT='REAN Foundation';
export const PUBLIC_FOOTER_LINK='https://www.reanfoundation.org';
export const SYSTEM_NAME = 'REAN Foundation';
14 changes: 14 additions & 0 deletions src/lib/themes/theme.selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TickColorDark as AHATickColorDark } from './aha.theme';
import { PUBLIC_LOGO_IMAGE_SOURCE as AHA_PUBLIC_LOGO_IMAGE_SOURCE } from './aha.theme';
import { PUBLIC_FOOTER_TEXT as AHA_PUBLIC_FOOTER_TEXT } from './aha.theme';
import { PUBLIC_FOOTER_LINK as AHA_PUBLIC_FOOTER_LINK } from './aha.theme';
import { SYSTEM_NAME as AHA_SYSTEM_NAME } from './aha.theme';

// REAN Theme imports
import { ThemeColors as REANThemeColors } from './rean.theme';
Expand All @@ -21,6 +22,7 @@ import { ThemeDarkColor as REANThemeDarkColor } from './rean.theme';
import { PUBLIC_LOGO_IMAGE_SOURCE as REAN_PUBLIC_LOGO_IMAGE_SOURCE } from './rean.theme';
import { PUBLIC_FOOTER_TEXT as REAN_PUBLIC_FOOTER_TEXT } from './rean.theme';
import { PUBLIC_FOOTER_LINK as REAN_PUBLIC_FOOTER_LINK } from './rean.theme';
import { SYSTEM_NAME as REAN_SYSTEM_NAME } from './rean.theme';

import { SYSTEM_ID } from '../constants';

Expand Down Expand Up @@ -133,3 +135,15 @@ export const getPublicFooterLink = () => {
return REAN_PUBLIC_FOOTER_LINK;
}
};

export const getSystemName = () => {
const systemType: SystemTypes = SYSTEM_ID as SystemTypes;
switch (systemType as SystemTypes) {
case SystemTypes.REAN:
return REAN_SYSTEM_NAME;
case SystemTypes.AHA:
return AHA_SYSTEM_NAME;
default:
return REAN_SYSTEM_NAME;
}
};
3 changes: 0 additions & 3 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ import type { PageServerLoad } from './$types';
import { SessionManager } from './api/session.manager';
import { login } from './api/services/user';
import { getUserRoles } from './api/services/types';
import { SYSTEM_NAME } from '$env/static/private';

////////////////////////////////////////////////////////////////

export const load: PageServerLoad = async (event: RequestEvent) => {
try {
const systemName = SYSTEM_NAME;
let roles: PersonRole[] = await getUserRoles();
if (!roles || roles.length === 0) {
roles = UserRoles;
}
return {
message: 'Common data successfully retrieved!',
roles,
systemName
};
} catch (error) {
console.error(`Error retrieving data : ${error.message}`);
Expand Down
5 changes: 3 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import {
getPublicLogoImageSource,
getPublicFooterText,
getPublicFooterLink
getPublicFooterLink,
getSystemName,
} from '$lib/themes/theme.selector';
const logoImageSource = getPublicLogoImageSource();
Expand All @@ -29,7 +30,7 @@
LocalStorageUtils.removeItem('prevUrl');
}
var systemName = data.systemName;
var systemName = getSystemName();
</script>

Expand Down

0 comments on commit b1660ac

Please sign in to comment.