This repository contains the internal UI for the Hearing Portal. The repository is part of the overall solution, which also consists of another frontend and a backend.
Hearing Portal Public UI is located here: Github Hearing Portal API is located here: Github
The following technologies have been used to build the solution.
The following tools are required to run and work with the solution.
The solution can be run locally both inside a Docker container and in regular fashion using Node. For local development, it is recommended that the solution is executed using Node. Both guides assume that the tools from the Required tools
section are installed on the machine.
The application requires a minimum of configuration before it runs. Configuration is done using environment variables. Due to the nature of how webpack handles process.env, some functionality exists to push some environment variables to the browser.
The general rule is that variables named with a prefix REACT_APP_EXT
are delivered to the browser in window.__ENV
.
This functionality relies on the npm package @beam-australia/react-env
.
Provide the variable REACT_APP_EXT_BASE_API_URL
to the container once it starts. This has to point to the base api address, for instance https://dhp-intern.balk.dk/api
.
The @beam-australia/react-env
is based on converting .env
files, so it looks for these and picks up any environment variables it sees. To provide for the application during development, create a .env.local
file in the app
folder with the following content.
REACT_APP_EXT_BASE_API_URL=https://localhost:5001/api
REACT_APP_EXT_TARGET_ENV=development
REACT_APP_EXT_X_API_HEADER=<KEY_HERE>
Note that this assumes the api is running on https://localhost:5001
which is only the case if it runs from Visual Studio. Further, only the base api url is strictly necessary. The remaining variables are for file download functionality if not going through the proxy provided by docker.
-
Download solution from Github
-
In the
/app
folder, run one of the following commands to install the required dependenciesyarn yarn install
NB if step 2 fails, with a node-gyp error, you might need to install a different version of node for it to work, and some other things. See the section about fixing node-gyp errors below.
-
From the project root, navigate to
/docker/environments/
and add the required environment variables todocker_development.env
. The environment variables can be found in/docker/environments/example.env
-
Start the application using the following command
yarn start
-
Using a browser, navigate to http://localhost:4000 and validate that the site is up and running
- Uninstall chocolatey (deleting the folder C:\ProgramData\chocolatey)
- Resetting config (only if you've made changes like:
npm config set <something>
eg:npm config set python C:\Python27\python.exe
)npm config edit
brings up a text file in which you can delete the config changes you've made followed by saving the file and closing it.
- Uninstall Node
- Remove any npm/node folders in %AppData% (press windows button and type %AppData% followed by "Enter")
- Check all 3 AppData folders (Local, LocalLow and Roaming)
- Install Node 4.17.6 (https://nodejs.org/en/blog/release/v14.17.6/) with dependencies for node (ticked on during install)
- Having VS Build Tools 2017 installed
- Got installed by running
npm install --global windows-build-tools
- Initially this command hung, but the installer was fetched and placed in
C:\Users\<username>\.windows-build-tools
namedvs_BuildTools.exe
.
- Got installed by running
-
Download solution from Github
-
From the project root, navigate to
/docker/environments/
and add required the environments variables todocker_development.env
. The environment variables can be found in/docker/environments/example.env
-
In the
/docker
folder, run the following command to build a docker image of the solution$ docker-compose -f docker-compose.development.yml build
*Starting this solution in Docker requires the backend project to be up and running, as this uses a shared network that is defined in the backend Docker setup.
-
In the
/docker
folder, run the following command in WSL2 to start the docker container of the solution$ docker-compose -f docker-compose.development.yml up
-
Using a browser, navigate to http://localhost:4000 and validate that the site is up and running
-
If your API is running in Docker you will need to alter a file called
bootstrapSlice.js
. It is located in src/features. You need to change thebaseUrlConfiguration.development
url to use port 8080, if you have the api proxy running on port 8080.
This project was bootstrapped with Create React App, using the Redux and Redux Toolkit template.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:4000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify