Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend setup & UI Implementation. #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hopansh
Copy link

@hopansh hopansh commented Feb 10, 2024

  • Frontent Project Setup Created frontend folder and implemented basic UI based on current functionality
  • Components: Added new components in the frontend/src/components/ directory, including Button.jsx, ErrorBoundary.jsx, Header.jsx, Input.jsx, and Welcome.jsx.
  • Views: Created new views in the frontend/src/View/ directory, including Home.jsx, Logs.jsx, and Submission.jsx.
  • Service Layer: Implemented a new service layer with apiService.js in the frontend/src/service/ directory for handling API requests.
  • Package Dependencies:
    The frontend project uses the following dependencies:
    • React for building the UI.
    • Vite for building the project and providing a development server.
    • Axios for making HTTP requests.
    • Socket.io-client for real-time communication with the server.
    • @emotion/react and @emotion/styled for styling components.

Future Scope:

  • API Integration API integration is yet to be done.
  • Remove code redundancy Code Redundancy can be removed like input component error message.

For More Info: Please refer to Readme.md

@hopansh
Copy link
Author

hopansh commented Feb 10, 2024

Implemented UI Screenshots
image
image
image

import React from "react";

class ErrorBoundary extends React.Component {
constructor(props) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is this ErrorBoundary alone using class component?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although a functional component could handle this task, I chose to implement it using a class component for simplicity and to utilize lifecycle methods like componentDidCatch and getDerivedStateFromError. While functional component solutions exist, such as those involving third-party libraries like 'react-error-boundary' or utilizing hooks like useEffect and event listeners, I find the class component approach simpler and more straightforward for error boundary management.

@piyushgarg-dev
Copy link
Owner

Great Work 🎉 - @hopansh

@hopansh
Copy link
Author

hopansh commented Feb 11, 2024

Great Work 🎉 - @hopansh

Thanks @piyushgarg-dev 🫠🤗

@piyushgarg-dev
Copy link
Owner

@hopansh Can you please add the API and Socket Integration as well?

You can use this code for reference https://github.com/piyushgarg-dev/vercel-clone/blob/8a69988450aefef68ebf8704caa6718ec666d3b4/frontend-nextjs/app/page.tsx

Deployment Trigger Code

const handleClickDeploy = useCallback(async () => {
setLoading(true);
const { data } = await axios.post(`http://localhost:9500/project`, {
gitURL: repoURL,
slug: projectId,
});
if (data && data.data) {
const { projectSlug, url } = data.data;
setProjectId(projectSlug);
setDeployPreviewURL(url);
console.log(`Subscribing to logs:${projectSlug}`);
socket.emit("subscribe", `logs:${projectSlug}`);
}
}, [projectId, repoURL]);

Here is the video that might help you https://imgur.com/I6KgmNR

Thanks :)

@hopansh
Copy link
Author

hopansh commented Feb 12, 2024

@hopansh Can you please add the API and Socket Integration as well?

You can use this code for reference https://github.com/piyushgarg-dev/vercel-clone/blob/8a69988450aefef68ebf8704caa6718ec666d3b4/frontend-nextjs/app/page.tsx

Deployment Trigger Code

const handleClickDeploy = useCallback(async () => {
setLoading(true);
const { data } = await axios.post(`http://localhost:9500/project`, {
gitURL: repoURL,
slug: projectId,
});
if (data && data.data) {
const { projectSlug, url } = data.data;
setProjectId(projectSlug);
setDeployPreviewURL(url);
console.log(`Subscribing to logs:${projectSlug}`);
socket.emit("subscribe", `logs:${projectSlug}`);
}
}, [projectId, repoURL]);

Here is the video that might help you https://imgur.com/I6KgmNR

Thanks :)

Sure. 🫡 Will push the changes.

@hopansh
Copy link
Author

hopansh commented Feb 12, 2024

Changes:

  • API Integration: The frontend now communicates with the backend API, allowing for full functionality of the application.
  • README.md Update: The README.md file has been updated with new sections detailing the usage information.

Known Issues and Future Scope:

  • CORS Issue: During development, a CORS issue was encountered and resolved by adding CORS to the API server. However, these changes have not been pushed as they were made in the backend, which is outside the scope of this PR. This will need to be addressed in a future update.

  • About/How to Use Section: In a future update, an "About" or "How to Use" section can be introduced to the web page to provide users with information on how to use the application.

@piyushgarg-dev @rohitkrishna094

@hopansh
Copy link
Author

hopansh commented Feb 12, 2024

image
image

@piyushgarg-dev
Copy link
Owner

Awesome @hopansh 🎉

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we shouldn't wrap whole application in a single ErrorBoundary, instead chunks of components should be wrapped in them. @hopansh

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion! It's indeed a valid consideration to implement error boundaries at the component level, especially when dealing with multiple components on the screen where the failure of one doesn't significantly affect the overall product value. However, in our specific scenario where only a limited number of components are present at any given time and the failure of any of them results in the failure of the entire flow or product, wrapping the entire application in a single ErrorBoundary offers a more comprehensive approach to error handling.

While implementing component-level error boundaries is a valid approach in certain scenarios, in this context, a holistic error boundary strategy at the application is more effective solution for ensuring the stability and reliability of our product in my view.

Copy link

@Zaid-maker Zaid-maker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants