This project is a web application that displays product information in a table format. The table is built using AG Grid and styled with Material UI and Tailwind CSS. The application fetches product data from a GraphQL server and includes user authentication functionalities.
The task required developing a web application that:
- Displays product information in a table format: The table should include product ID, name, company name, default buy price, and default sell price.
- Handles user authentication: The application should support user login and registration.
- Fetches data from a server: The application should retrieve product data from a GraphQL API.
- Uses the following technologies:
- React
- TypeScript
- Material UI
- AG Grid
- Apollo GraphQL
src/components: React componentssrc/pages: Page componentssrc/hooks: Custom hookssrc/graphql: GraphQL queries, mutations and clientsrc/state: Recoil state managementsrc/types: TypeScript types
-
Product Table
- Implemented a
ProductsTablecomponent using AG Grid to display product information. - Integrated GraphQL to fetch data from the server with the
GET_PRODUCTSquery. - Configured AG Grid to display product ID, name, company name, default buy price, and default sell price.
- Added a loading spinner to indicate data fetching status.
- Implemented a
-
Authentication
- Set up Apollo Client for managing GraphQL requests and authentication.
- Implemented GraphQL mutations for user login, registration, and logout.
- Used Recoil for state management to handle authentication and product data.
-
UI Components
- Developed a
TopBarcomponent for user authentication status and logout functionality. - Created
PrivateRouteandPublicRoutecomponents to manage access to different routes based on authentication state. - Added a
NotFoundPagecomponent to handle 404 errors. - Implemented a
LoginPagecomponent with form handling for user authentication.
- Developed a
-
Styling and Dependencies
- Utilized Tailwind CSS for modern styling and layout.
- Incorporated AG Grid community package for table functionalities.
- Added TypeScript interfaces for type safety.
To set up and run the project locally, follow these steps:
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open the application: Navigate to
http://localhost:your_portin your web browser.
- Apollo Client: Configured with HTTP and authentication links to handle GraphQL queries and mutations.
- Recoil State Management: Used for managing authentication and product state.
- Login: Access the login page from the top bar to authenticate users.
- View Products: Once logged in, navigate to the dashboard to view the product table.
- Logout: Use the logout button in the top bar to end the session.
- CORS Issues: Ensure CORS is disabled in your browser or configure your server to handle CORS for development purposes.
- Error Handling: The application includes basic error handling and loading states.
Feel free to contribute to the project by opening issues or submitting pull requests. Ensure to follow the coding guidelines and provide clear descriptions of any changes made.
This project is licensed under the MIT License. See the LICENSE file for more details.