Skip to content

Conversation

@elhalj
Copy link
Owner

@elhalj elhalj commented Sep 4, 2025

Summary

Enforce validation rules on user and room creation endpoints, refactor and enhance front-end components for consistent error handling and user feedback, and streamline mobile header drawer logic.

Bug Fixes:

  • Fix CSS classname in UtilsBar to restore intended background styling
  • Update task creation link path in Tasks component

Enhancements:

  • Refactor Header component to render mobile drawer via early return and unify transition styling
  • Standardize API error handling with ApiError type and show detailed error messages in CreateTask, RoomUI, CreateRoom, AddMember, and Login components
  • Add toast notifications for success and failure events during task creation, room deletion, member addition, and login
  • Replace Link with NavLink for consistent active link highlighting in AddPage and UpdateTask

@elhalj elhalj added the Refactor Modify things label Sep 4, 2025
@netlify
Copy link

netlify bot commented Sep 4, 2025

Deploy Preview for colab-flow ready!

Name Link
🔨 Latest commit 603a8d8
🔍 Latest deploy log https://app.netlify.com/projects/colab-flow/deploys/68ba16ea71510a00098fddc4
😎 Deploy Preview https://deploy-preview-30--colab-flow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 4, 2025

Reviewer's Guide

This PR introduces client- and server-side input validations with typed error handling, integrates toast notifications for user feedback, refactors the mobile drawer UI in the Header, and includes various UI navigation and styling fixes.

File-Level Changes

Change Details Files
Centralized error handling and toast notifications across UI components
  • Imported react-hot-toast and defined ApiError type for structured error parsing
  • Parsed API response errors in catch blocks and set error state accordingly
  • Displayed toast.success or toast.error on successful or failed operations
frontend/src/ui/CreateTask.tsx
frontend/src/ui/room/AddMember.tsx
frontend/src/ui/room/CreateRoom.tsx
frontend/src/ui/login.tsx
frontend/src/context/RoomProvider.tsx
Added input validations on server routes for users and rooms
  • Validated userName presence and minimum length in authRoute
  • Enforced minimum lengths for room_name and description in roomRoutes
  • Returned HTTP 401 codes with descriptive error messages on validation failure
src/routes/user.route.js
src/routes/room.route.js
Refactored and styled mobile drawer in Header component
  • Extracted drawer markup into an early return when showMenu is true to remove duplication
  • Updated backdrop blur, background opacity, and transition classes on the drawer and header
  • Cleaned up conditional rendering and button interactions for opening/closing the menu
frontend/src/components/Header.tsx
Refined RoomUI to manage delete loading and error states
  • Introduced local loading and error state for deleteRoom operations
  • Wrapped deleteRoom call in try/catch/finally to set loading flags and capture errors
  • Displayed Loader and inline error messages within the room list
frontend/src/ui/room/Room.tsx
Minor UI tweaks and navigation updates
  • Replaced Link with NavLink in AddPage and UpdateTask for active styling
  • Fixed className typos in UtilsBar and added link transition duration in Header
  • Updated Tasks component link path from '/dashboard/tasks/create' to '/dashboard/add/task'
frontend/src/pages/AddPage.tsx
frontend/src/ui/UpdateTask.tsx
frontend/src/ui/UtilsBar.tsx
frontend/src/ui/Tasks.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@elhalj
Copy link
Owner Author

elhalj commented Sep 4, 2025

@sourcery-ai title

@sourcery-ai sourcery-ai bot changed the title add verification typed on back and front Enforce validation, enhance error handling, and refactor UI Sep 4, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • You’ve duplicated the ApiError type and error‐message extraction in multiple components—consider centralizing this logic in a shared utility to DRY up your code.
  • The mobile drawer JSX in Header.tsx is quite large—extract it into its own component to keep the Header component concise and improve readability.
  • There are several commented–out functions and stray empty fragments (e.g., handleRoomChange, {} around icons)—remove or implement these to clean up dead code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You’ve duplicated the ApiError type and error‐message extraction in multiple components—consider centralizing this logic in a shared utility to DRY up your code.
- The mobile drawer JSX in Header.tsx is quite large—extract it into its own component to keep the Header component concise and improve readability.
- There are several commented–out functions and stray empty fragments (e.g., `handleRoomChange`, `{}` around icons)—remove or implement these to clean up dead code.

## Individual Comments

### Comment 1
<location> `frontend/src/components/Header.tsx:22` </location>
<code_context>
+          <h2 className="text-xl font-bold">
+            <NavLink to="/">TaskFlow</NavLink>
+          </h2>
+          <button
+            type="button"
+            onClick={() => setShowMenu(false)}
+            className="p-2 text-slate-300 hover:text-white transition-colors"
+          >
+            <X className="w-6 h-6" />
+            {}
+          </button>
</code_context>

<issue_to_address>
Empty curly braces `{}` remain after icon components in several places.

Removing these unused braces will improve code clarity and reduce potential confusion.
</issue_to_address>

### Comment 2
<location> `frontend/src/context/RoomProvider.tsx:226` </location>
<code_context>
         apiError.message ||
         "Failed to delete room";
       setErrors(`Error: ${errorMessage}`);
+      toast.error(errorMessage)
       console.error("Error deleting room:", error);
       throw error;
</code_context>

<issue_to_address>
Error toast added for room deletion failures.

Please review the error message to confirm it is clear and easily understood by end users.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
      const apiError = error as ApiError;
        apiError.message ||
        "Failed to delete room";
      setErrors(`Error: ${errorMessage}`);
      toast.error(errorMessage)
      console.error("Error deleting room:", error);
      throw error;
=======
      const apiError = error as ApiError;
      const errorMessage =
        apiError.message && typeof apiError.message === "string"
          ? `Impossible de supprimer la salle : ${apiError.message}`
          : "Impossible de supprimer la salle. Veuillez réessayer ou contacter le support.";
      setErrors(`Error: ${errorMessage}`);
      toast.error(errorMessage);
      console.error("Error deleting room:", error);
      throw error;
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +22 to +27
<button
type="button"
onClick={() => setShowMenu(false)}
className="p-2 text-slate-300 hover:text-white transition-colors"
>
<X className="w-6 h-6" />
Copy link

Choose a reason for hiding this comment

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

nitpick: Empty curly braces {} remain after icon components in several places.

Removing these unused braces will improve code clarity and reduce potential confusion.

Comment on lines 223 to 228
apiError.message ||
"Failed to delete room";
setErrors(`Error: ${errorMessage}`);
toast.error(errorMessage)
console.error("Error deleting room:", error);
throw error;
Copy link

Choose a reason for hiding this comment

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

suggestion: Error toast added for room deletion failures.

Please review the error message to confirm it is clear and easily understood by end users.

Suggested change
apiError.message ||
"Failed to delete room";
setErrors(`Error: ${errorMessage}`);
toast.error(errorMessage)
console.error("Error deleting room:", error);
throw error;
const apiError = error as ApiError;
const errorMessage =
apiError.message && typeof apiError.message === "string"
? `Impossible de supprimer la salle : ${apiError.message}`
: "Impossible de supprimer la salle. Veuillez réessayer ou contacter le support.";
setErrors(`Error: ${errorMessage}`);
toast.error(errorMessage);
console.error("Error deleting room:", error);
throw error;

@elhalj elhalj merged commit 82cddca into main Sep 4, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Modify things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants