This repository contains the code for rendering a Google calendar's single column with scheduled meetings using ReactJS.
The task is to create a column representation of a Google calendar and render the scheduled meetings. The meetings are provided as an array, and there are four cases to handle:
- Only one meeting at a given start and end time.
- Two or more meetings that intersect but have different start and end times.
- Two or more meetings that start and end at the same time.
- Two or more meetings that start and end at the same time, and some meetings intersect but have different start and end times.
The problem can be solved by breaking it down into smaller parts and implementing them step by step. Here is an overview of the solution approach:
- Build a column component that renders the hours as cells.
- Perform necessary calculations on the meetings array to convert it into the required format.
- Use the converted meetings data to build the meetings layer and render it on top of the column component.
The folder structure of this repository is as follows:
![Screenshot 2023-06-27 at 11 06 46 PM](https://private-user-images.githubusercontent.com/72138429/249634748-23cac38d-b9d9-481e-b738-0c2a0b97669c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODQ4ODEsIm5iZiI6MTczOTA4NDU4MSwicGF0aCI6Ii83MjEzODQyOS8yNDk2MzQ3NDgtMjNjYWMzOGQtYjlkOS00ODFlLWI3MzgtMGMyYTBiOTc2NjljLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA3MDMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRhOTIxYzZkYjM0MDVkZjMwMTQxNWQ3Y2YxNjM1N2NhZGQ5ZGQ1MWVhMTMzNjhlMzU1OGFhNDE3MWI5NWU1YjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.4CrwwY9iTn4rv0QGMvkEBcGLrt4tdOPAHRWec7iAiYQ)
- The
src/components
directory contains the React components used in the application. - The
src/App.js
file is the main entry point of the application. - The
src/index.js
file is responsible for rendering the root component (App
) into the DOM. - The
src/data.js
file contains the sample meetings data provided by the interviewer.
![Screenshot 2023-06-29 at 4 48 03 AM](https://private-user-images.githubusercontent.com/72138429/249634876-4ee0c292-9d69-4e0b-8d70-340f6baf656f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODQ4ODEsIm5iZiI6MTczOTA4NDU4MSwicGF0aCI6Ii83MjEzODQyOS8yNDk2MzQ4NzYtNGVlMGMyOTItOWQ2OS00ZTBiLThkNzAtMzQwZjZiYWY2NTZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA3MDMwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI0N2I5ZThjMzJmZjc3ZWMwZGFmYjhlNjgxOTI3ZjAwZDZiYzA1NjMyMmVjOTY1MGU2M2U1NjgyN2E1MDk0YWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.-5ONuo6-qG-oclPgpFJ5caUKTxNaXk03q7whIl2rsP4)
To run the application locally, follow these steps:
- Clone this repository to your local machine.
- Navigate to the project directory.
- Install the dependencies by running the command:
npm install
. - Start the development server by running the command:
npm start
. - Open your browser and visit
http://localhost:3000
to see the Google calendar rendering with the scheduled meetings.
I have written a detailed blog post explaining the approach and implementation of this Google calendar's single column rendering solution using ReactJS. You can find the blog post here.
Feel free to explore the code, modify it according to your needs, and provide any feedback or suggestions.
Happy coding!