FactoryFour Status Page is a React-based web application designed to monitor the health status of various FactoryFour APIs. The application provides a real-time display of API statuses, allowing users to stay informed about the health of critical services.
The StatusPage
component serves as the main application component. It manages the loading status, dark mode, and API status. Key features include:
- Loading Status: It displays a loading spinner when the application is fetching API statuses.
- Dark Mode: Users can toggle between light and dark modes for a personalized viewing experience.
- API Status Display: The
CardsGrid
component renders the health status of each API, and theCountdownTimer
ensures periodic updates. - Dark Mode Toggle: The
DarkModeToggle
component provides a button to switch between light and dark modes.
The useApiChecker
hook encapsulates the logic for fetching and updating API statuses. Key functionalities include:
- Asynchronous Fetching: It fetches the status of each API asynchronously using Axios.
- Periodic Updates: The hook employs
useEffect
to periodically update API statuses at a configurable interval. - Error Handling: Handles API deprecation and general errors gracefully, updating the status accordingly.
- Custom Hooks: The application utilizes custom hooks, such as
useApiChecker
, to encapsulate logic and enhance reusability. - Functional Components: React functional components are employed for a more modular and concise code structure.
- API Names: The list of API names to query for status is stored in the
API_NAMES
constant. - State Management: React
useState
is used for managing loading, dark mode, and API status states. - Fetch Timeout Interval: The interval for updating API statuses is defined as a constant (
API_CHECK_INTERVAL
) inApp.tsx
and passed to theuseApiChecker
hook.
Testing is implemented using the @testing-library/react
library. Test cases include:
- Renders API Status After Loading: Verifies that API statuses are rendered after the loading phase.
- Toggles Dark Mode: Checks whether dark mode toggles correctly when the
DarkModeToggle
component is clicked.
This project was bootstrapped with Create React App.
In the project directory, you can run:
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.
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.