This project was bootstrapped with Create React App.
In the project directory, you can run:
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
cd <project-root-path>
docker build -t clinical-portal ./
You can start it using docker locally by :
docker run -p 3000:3000 clinical-portal
-nginx/
-src/
-components
-constants
-contexts
-modules
-pages
-services
-types
-utils
-global.d.ts
-Routers.tsx
-Dockerfile
this is the place where we put the pure UI components here, that means components in here are all controlled components with no dependencies about Global Store(React Context, Redux or Mobx) and Endpoint requests. We can easily test them.
this is the place where we put some common used constants here, like some storage keys, HTTP_ERROR_STATUSES and constant duration times.
this is the place where we put Global store.
this is the place where we put the Business components, which could related to the Global Context, history Or some global components Like Notification.
this is the place where we put the screens(pages) entry here.
this is the place where we put the interfaces and types which can be used by the whole project file.
this is the place where we put the common utils, like the MockedFetch function.
this is the entry of React Router.
this is the config of Docker, it will start with nginx
- Create React App
- React + Typescript
- Material UI
- React Router
- React Query
- React hook form
- React toastify
React Query is an awesome customer hooks(for server-state) library, can easily get data and manage the data in FE, including refresh, cache and so on.
We always need to manage forms in FE project, especially for admin portal. A good hook-form-manager-tools can help us to manage the submit, validation.
Material doesn't give us a global toast, of course we can manually create one just like this project previously, However, it is better if we pass this work developing this functionality to react-toastify, So we can focus on other higher level functionality.
Material UI is a commonly used UI Component library in many FE project. It provide many common used Component like Card, Menu, Tab, and Icons.
The reason I chose the React Context to be the Global Store rather than React-Redux is this is a small project which only contains 2 pages, it doesn't contains So much state we need to manage. React Context is the perfect one here, small and easy to understand. Keep it simple. It also will be easy to switch if we want the Redux in the future.
Of course, Javascript is well and can easily build this project as well, However, Typescript can help me developing this project more strictly and easier to find the bugs, wrong data format, or missing props. So the first things I did is create the types and interface I may needed.
This is a continuation of work habits. Pages or screens is the entry and layout of how we want to put in each screen. Modules are the exactly implement.
- 1 every Module could be used in different screens.
- 2 splitting to small Modules can make them focus on small functionality, more easy to upgrade and test.
- 1 Not all error message is suitable to show for our users. It will be better if we overwrite is in FE.
- 2 i18n. it will be easy to switch to different languages if we handle error message in FE rather than directly show out the error from BE.
- 1 of course we can directly use the origin fetch, however, that means we need to set the Authorization and handle fetch error in every request(service). It is a bad solution and will create so many duplicated codes.
- 2 we are using Mock endpoints right now, and it will be impossible if we want to hybrid use real endpoints and Mock endpoints. So I create a new Fetch, to make it easier to upgrade if we want switch to really endpoints.
- 3 I was trying to import Axios when I start this project. Fetch-mock only Observer native fetch request, However, Axios is based on XMLHttpRequest. That is way I give up Axios.
It is a very common functionality, and it didn't take too much time, So I add it.
Github home pages didn't support browser history.
It is a very common functionality, and it didn't take too much time, So I add it.
- (Optimize view experience in Mobile screen)
- (i18n)
- (add unit tests)
- (improve test coverage greater thant 90)
- (add gitHooks for eslint and prettier)
- (add gitActions for CI/CD)
- (Support Docker, add Dockerfile)