diff --git a/src/config-schema.ts b/src/config-schema.ts index 818fc68..9179933 100644 --- a/src/config-schema.ts +++ b/src/config-schema.ts @@ -49,4 +49,30 @@ export const configSchema = { _description: "Alt text, shown on hover", }, }, + loginBackgroundUrl: { + src: { + _type: Type.String, + _description: + "A path or URL to an image. If null, will use the OpenMRS SVG sprite.", + _validators: [validators.isUrl], + }, + alt: { + _type: Type.String, + _default: "Background", + _description: "Alt text, shown on hover", + }, + }, + loginLogoUrl: { + src: { + _type: Type.String, + _description: + "A path or URL to an image. If null, will use the OpenMRS SVG sprite.", + _validators: [validators.isUrl], + }, + alt: { + _type: Type.String, + _default: "OpenMRS Logo", + _description: "Alt text, shown on hover", + }, + }, }; diff --git a/src/index.ts b/src/index.ts index 94b82de..872c061 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { getAsyncLifecycle, defineConfigSchema } from "@openmrs/esm-framework"; -import { configSchema } from "./config-schema"; +import { configSchema } from "./config-schema"; const moduleName = "@ugandaemr/esm-login-app"; diff --git a/src/login/login.background.component.tsx b/src/login/login.background.component.tsx new file mode 100644 index 0000000..f8ebe8e --- /dev/null +++ b/src/login/login.background.component.tsx @@ -0,0 +1,22 @@ +import { type ConfigSchema, useConfig } from "@openmrs/esm-framework"; +import React from "react"; + +const LoginBackground = () => { + const { loginBackgroundUrl } = useConfig(); + + return loginBackgroundUrl.src ? ( + {loginBackgroundUrl.alt} + ) : ( + UgandaEMR+ Background + ); +}; + +export default LoginBackground; diff --git a/src/login/login.component.tsx b/src/login/login.component.tsx index 27c381f..f1b6452 100644 --- a/src/login/login.component.tsx +++ b/src/login/login.component.tsx @@ -263,7 +263,6 @@ const Login: React.FC = () => { ); } - return null; }; diff --git a/src/login/login.test.tsx b/src/login/login.test.tsx index 1cdc3ff..09a21e1 100644 --- a/src/login/login.test.tsx +++ b/src/login/login.test.tsx @@ -34,11 +34,6 @@ jest.mock("./login.resource", () => ({ performLogin: jest.fn(), })); -const loginLocations = [ - { uuid: "111", display: "Earth" }, - { uuid: "222", display: "Mars" }, -]; - mockedUseSession.mockReturnValue({ authenticated: false }); mockedUseConfig.mockReturnValue(mockConfig); diff --git a/src/login/logo.component.tsx b/src/login/logo.component.tsx index 470490f..865a56c 100644 --- a/src/login/logo.component.tsx +++ b/src/login/logo.component.tsx @@ -1,50 +1,62 @@ import React from "react"; +import { useConfig } from "@openmrs/esm-framework"; -const Logo = (props) => ( - - - - - - - - - +const Logo = (props) => { + const { loginLogoUrl } = useConfig(); + return loginLogoUrl.src ? ( + {loginLogoUrl.alt} + ) : ( + + + + + + + + + + + + + + + - - - - - - - -); + + ); +}; + export default Logo;