Skip to content

Tejaswi/9 UI confirmation modal - #21

Merged
yash-pouranik merged 11 commits into
geturbackend:mainfrom
tejaavula076:tejaswi/9-ui-confirmation-modal
Jan 12, 2026
Merged

Tejaswi/9 UI confirmation modal#21
yash-pouranik merged 11 commits into
geturbackend:mainfrom
tejaavula076:tejaswi/9-ui-confirmation-modal

Conversation

@tejaavula076

@tejaavula076 tejaavula076 commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

🚀 Pull Request Description

Fixes # (issue number)

🛠️ Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 UI/UX improvement (Frontend only)
  • ⚙️ Refactor / Chore

🧪 Testing & Validation

Backend Verification:

  • I have run npm test in the backend/ directory and all tests passed.
  • I have verified the API endpoints using Postman/Thunder Client.
  • New unit tests have been added (if applicable).

Frontend Verification:

  • I have run npm run lint in the frontend/ directory.
  • Verified the UI changes on different screen sizes (Responsive).
  • Checked for any console errors in the browser dev tools.

📸 Screenshots / Recordings (Optional)

✅ Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings or errors.
  • I have updated the documentation (README/Docs) accordingly.

Built with ❤️ for urBackend.

Summary by CodeRabbit

  • New Features

    • Confirmation modals for delete actions across the app
    • Modal-driven "Add Document" workflow with field-specific inputs
    • Project rename flow and guarded project deletion
    • Improved database and storage configuration management UI
  • Style

    • Integrated Tailwind CSS for updated styling utilities
  • Other

    • Minor HTML/formatting and markup cleanups (doctype, spacing, newline fixes)

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercel Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

@tejaavula076 is attempting to deploy a commit to the Yash Pouranik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds Tailwind CSS to the frontend build and introduces a reusable ConfirmationModal component; replaces inline browser confirms with modal-driven flows and refactors Database and ProjectSettings pages to use modal confirmations and reorganized state/components.

Changes

Cohort / File(s) Summary
Tailwind CSS setup
frontend/package.json, frontend/vite.config.js, frontend/src/index.css, frontend/index.html
Adds Tailwind/Vite plugin and imports; updates Vite plugins; global CSS imports Tailwind utilities; minor HTML formatting/doctype normalization.
Confirmation modal component
frontend/src/pages/ConfirmationModal.jsx
New reusable modal component exposing open, onConfirm, onCancel; renders overlay, icon, title, message, Cancel/Delete buttons.
Database page refactor & integration
frontend/src/pages/Database.jsx
Replaces window.confirm with ConfirmationModal for deletions; adds modal-driven add-document workflow, per-collection form rendering, reorganized UI (Sidebar, TableView, JsonView), expanded state (showModal, selectedId, isSidebarOpen) and error handling.
ProjectSettings refactor & integration
frontend/src/pages/ProjectSettings.jsx
Replaces inline delete with ConfirmationModal; adds rename flow, optimistic state updates, fetch-on-mount, DatabaseConfigForm and StorageConfigForm subcomponents, and guarded delete/navigation on confirm.
Backend formatting
backend/package.json
End-of-file newline formatting only; no functional changes.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as App Page\n(Database / ProjectSettings)
    participant Modal as ConfirmationModal
    participant API as Backend API

    User->>UI: Click "Delete" on item
    UI->>UI: set showModal=true, selectedId=itemId
    UI->>Modal: render(open=true)
    Modal->>User: show overlay with Cancel/Delete

    User->>Modal: Click Cancel
    Modal->>UI: onCancel()
    UI->>UI: set showModal=false

    alt User confirms deletion
        User->>Modal: Click Delete
        Modal->>UI: onConfirm()
        UI->>API: DELETE /resource/:id
        API-->>UI: 200 OK
        UI->>UI: remove item from state, set showModal=false
        UI->>User: show success toast / refresh view
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
A click, a twitch, a gentle thump,
A modal blooms to guard the stump.
Buttons aligned, decisions clear,
Tailwind trims the UI near.
I hop away — changes safe and dear.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Tejaswi/9 UI confirmation modal' directly relates to the main changes in the PR, which introduce a ConfirmationModal component and integrate it throughout the frontend for delete confirmations.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @frontend/src/pages/Database.jsx:
- Around line 303-315: The ConfirmationModal is currently rendered as a child of
the <table>, which is invalid HTML; move the conditional rendering of
ConfirmationModal (the block using showModal, ConfirmationModal, onConfirm
calling handleDelete(selectedId) and setShowModal(false), and onCancel calling
setShowModal(false)) so it is placed immediately after the closing </table> (or
elsewhere outside the table wrapper) while keeping the same props and state
references (showModal, handleDelete, selectedId, setShowModal) to preserve
behavior.
🧹 Nitpick comments (9)
frontend/src/index.css (1)

523-529: Consider using Tailwind utility classes directly in JSX.

These custom CSS classes define simple padding and width values that could be expressed using Tailwind utilities directly on the component elements (e.g., p-4, p-1, w-20). This would improve consistency with the Tailwind-first approach being adopted.

Additionally, the .confirmationModalBtn class has inconsistent indentation.

🔧 Suggested formatting fix if keeping custom classes
 .confirmationModal{
   padding: 1rem;
 }
 .confirmationModalBtn{
-      padding: 5px;
-    width: 5rem;
-
+  padding: 5px;
+  width: 5rem;
 }
frontend/package.json (1)

13-13: Consider moving Tailwind packages to devDependencies.

@tailwindcss/vite (4.1.18) is introduced as a new runtime integration for Tailwind with Vite, and tailwindcss (4.1.18) is added as a styling framework dependency. Both packages are build-time tools that process CSS during development and build phases—they don't run in the browser. Moving them to devDependencies would better reflect their purpose and reduce production bundle analysis noise.

♻️ Suggested fix
   "dependencies": {
-    "@tailwindcss/vite": "^4.1.18",
     "axios": "^1.13.2",
     "lucide-react": "^0.554.0",
     "react": "^19.2.0",
     "react-dom": "^19.2.0",
     "react-hot-toast": "^2.6.0",
     "react-router-dom": "^7.9.6",
-    "recharts": "^3.5.1",
-    "tailwindcss": "^4.1.18"
+    "recharts": "^3.5.1"
   },
   "devDependencies": {
     "@eslint/js": "^9.39.1",
+    "@tailwindcss/vite": "^4.1.18",
     "@types/react": "^19.2.5",
     "globals": "^16.5.0",
+    "tailwindcss": "^4.1.18",
     "vite": "^7.2.4"
   }

Also applies to: 20-21

frontend/src/pages/ConfirmationModal.jsx (2)

7-47: Add accessibility attributes for screen readers.

The modal has id="modal-title" and id="modal-description" but they're not connected via ARIA attributes. This impacts screen reader users.

♿ Proposed accessibility improvements
     <div
       className="fixed inset-0 bg-black/50 flex items-center justify-center"
       onClick={onCancel}
+      role="dialog"
+      aria-modal="true"
+      aria-labelledby="modal-title"
+      aria-describedby="modal-description"
     >

38-43: Consider making confirm button text configurable.

The button text is hardcoded as "Delete", limiting reusability for non-delete confirmations. Consider adding a confirmText prop with a default value.

♻️ Proposed change
-function ConfirmationModal({ open, title, message, onConfirm, onCancel }) {
+function ConfirmationModal({ open, title, message, onConfirm, onCancel, confirmText = "Delete" }) {
           <button
             onClick={onConfirm}
             className="btn btn-danger confirmationModalBtn"
           >
-            Delete
+            {confirmText}
           </button>
frontend/src/pages/Database.jsx (3)

42-45: Consider renaming fetchShowModal for clarity.

The name fetchShowModal implies it fetches data, but it only sets state to show the modal. A clearer name like openDeleteModal or showDeleteConfirmation would better convey the intent.

♻️ Proposed rename
-  const fetchShowModal = (id) => {
+  const openDeleteModal = (id) => {
     setShowModal(true);
     setSelectedId(id);
   };

Then update the usage on line 295:

-                  onClick={() => fetchShowModal(row._id)}
+                  onClick={() => openDeleteModal(row._id)}

65-67: Consider capturing the error for debugging.

The catch block discards the error object. Capturing it would help with debugging failed requests.

♻️ Proposed change
-      } catch {
+      } catch (err) {
+        console.error(err);
         toast.error("Failed to load project");
       }

188-250: Inner function components recreate on each render.

Sidebar, TableView, JsonView, and SkeletonLoader are defined inside the parent component, causing them to be recreated on every render. This breaks referential equality and can cause unnecessary re-renders of child components.

For this use case with simple UI components, the impact is minimal, but for better performance and testability, consider extracting them outside Database or memoizing them.

frontend/src/pages/ProjectSettings.jsx (2)

69-72: Remove commented-out dead code.

This commented-out confirmation logic is no longer needed since the modal now handles confirmation. Remove it to keep the codebase clean.

🧹 Proposed cleanup
   const handleDeleteProject = async () => {
     if (deleteConfirm !== project.name)
       return toast.error("Project name does not match");

-    // // if (
-    // //   !confirm("Final warning: This will delete the project and all its data.")
-    // // )
-    //   return;
-
     try {

326-331: Project data not refreshed after config update.

After successful configuration, isConfigured won't reflect the new state until the page is refreshed. The UI masks this by hiding the form, but the underlying project state is stale.

Consider accepting an onSuccess callback prop to trigger a project refresh from the parent, or update the local project prop optimistically.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c975d8a and 8e0b66b.

⛔ Files ignored due to path filters (2)
  • backend/package-lock.json is excluded by !**/package-lock.json
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • backend/package.json
  • frontend/index.html
  • frontend/package.json
  • frontend/src/index.css
  • frontend/src/pages/ConfirmationModal.jsx
  • frontend/src/pages/Database.jsx
  • frontend/src/pages/ProjectSettings.jsx
  • frontend/vite.config.js
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/pages/Database.jsx (5)
frontend/src/pages/ProjectDetails.jsx (3)
  • useParams (13-13)
  • useAuth (15-15)
  • project (17-17)
frontend/src/context/AuthContext.jsx (3)
  • useAuth (38-38)
  • useAuth (38-38)
  • token (6-6)
frontend/src/components/Layout/Header.jsx (1)
  • useAuth (5-5)
frontend/src/components/Layout/MainLayout.jsx (1)
  • isSidebarOpen (9-9)
frontend/src/config.js (2)
  • API_URL (2-2)
  • API_URL (2-2)
🔇 Additional comments (7)
backend/package.json (1)

31-31: LGTM!

The trailing newline ensures POSIX compliance and is a good formatting practice.

frontend/src/index.css (1)

2-2: LGTM!

The @import "tailwindcss"; directive is the correct Tailwind CSS v4 syntax, replacing the legacy @tailwind base; @tailwind components; @tailwind utilities; approach.

frontend/vite.config.js (1)

3-3: LGTM!

The Tailwind CSS v4 Vite plugin is correctly imported and registered. This is the recommended integration approach for Tailwind v4 with Vite, replacing the need for PostCSS configuration.

Also applies to: 6-6

frontend/index.html (1)

1-1: LGTM!

Good HTML formatting improvements:

  • Uppercase <!DOCTYPE html> follows the standard convention
  • Self-closing tags (/>) provide consistency with JSX syntax used elsewhere in the project
  • Multi-line formatting for the Google Fonts link improves readability

Also applies to: 9-14

frontend/src/pages/Database.jsx (1)

99-115: LGTM!

The delete handler correctly integrates with the confirmation modal flow, updates local state optimistically after deletion, and provides appropriate error handling with toast notifications.

frontend/src/pages/ProjectSettings.jsx (2)

286-297: LGTM!

The confirmation modal integration for project deletion is well-implemented. The flow properly guards against accidental deletion by requiring name confirmation before enabling the button, then showing the modal for final confirmation.


45-63: LGTM!

The rename handler has proper validation, loading state management, and optimistically updates local state after a successful API call. The button's disabled state (line 177) correctly prevents unnecessary requests.

Comment thread frontend/src/pages/Database.jsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (9)
frontend/src/pages/Database.jsx (9)

14-18: Unused imports detected.

The Search and MoreVertical icons are imported from lucide-react but do not appear to be used anywhere in the component. Consider removing them to keep the imports clean.

🧹 Suggested cleanup
 import {
   Database as DbIcon,
   Plus,
   Trash2,
   RefreshCw,
   Code,
   Table as TableIcon,
-  Search,
   Menu,
   X,
   ChevronRight,
-  MoreVertical,
   FileText,
 } from "lucide-react";

42-45: Consider renaming fetchShowModal for clarity.

The function name fetchShowModal suggests it fetches data, but it only sets state to show the modal. A name like openDeleteModal or showDeleteConfirmation would better convey its purpose.

✏️ Suggested rename
-  const fetchShowModal = (id) => {
+  const openDeleteModal = (id) => {
     setShowModal(true);
     setSelectedId(id);
   };

65-67: Error details are discarded.

The catch block shows a toast but discards the error object, making debugging harder. Consider logging the error.

🔍 Suggested improvement
-      } catch {
+      } catch (err) {
+        console.error("Failed to load project:", err);
         toast.error("Failed to load project");
       }

99-115: Clear selectedId after deletion to prevent stale state.

After a successful delete, selectedId still holds the deleted document's ID. While not immediately problematic, clearing it maintains cleaner state management.

🧹 Suggested improvement
       setData((prev) => prev.filter((item) => item._id !== id));
+      setSelectedId(null);
       toast.success("Document deleted");

188-250: Inner component definitions cause unnecessary re-renders.

Sidebar, TableView, JsonView, and SkeletonLoader are defined inside the Database component, meaning they are recreated on every render. This defeats React's reconciliation and can cause performance issues or loss of local state.

Consider either:

  1. Moving these to separate files or outside the component
  2. Converting them to inline JSX if they're simple enough
  3. Using useMemo to memoize them (less ideal)

304-315: Modal placement may cause unexpected dismissal.

The ConfirmationModal is rendered inside TableView, which only renders when viewMode === "table". If a user opens the delete modal and somehow switches to JSON view, the modal will unmount unexpectedly.

Consider moving the modal to the main return block alongside the "Add Document" modal for consistent behavior.

♻️ Suggested approach

Move the confirmation modal outside of TableView to the main JSX, similar to how isAddModalOpen modal is handled at lines 457-495:

{/* At the end of the main return, alongside the Add Document modal */}
{showModal && (
  <ConfirmationModal
    open={showModal}
    title="Delete Record"
    message="Are you sure you want to delete this record? This action cannot be undone."
    onConfirm={() => {
      handleDelete(selectedId);
      setShowModal(false);
    }}
    onCancel={() => setShowModal(false)}
  />
)}

456-495: Consider adding accessibility attributes to the modal.

The "Add Document" modal lacks focus trapping, Escape key handling, and proper ARIA attributes. While not blocking, these improvements would enhance accessibility.

Key additions to consider:

  • role="dialog" and aria-modal="true" on modal content
  • aria-labelledby pointing to the modal title
  • Escape key handler to close modal
  • Focus trap to keep keyboard navigation within modal

353-358: Add accessible labels to icon-only buttons.

The menu trigger button and other icon-only buttons lack accessible labels for screen reader users.

♿ Suggested improvement
                 <button
                   className="btn-icon hide-desktop menu-trigger"
                   onClick={() => setIsSidebarOpen(true)}
+                  aria-label="Open sidebar menu"
                 >
                   <Menu size={20} />
                 </button>

Apply similar aria-label attributes to other icon-only buttons like the delete button, refresh button, and close buttons.


497-861: Consider extracting styles to a separate CSS file or using Tailwind classes.

The 350+ lines of inline CSS embedded in the JSX impacts maintainability and causes the styles to be re-parsed on every render. Since Tailwind CSS is already a project dependency, consider:

  1. Moving styles to a dedicated CSS file (e.g., Database.css or Database.module.css)
  2. Replacing custom styles with Tailwind utility classes where applicable

Note that some utility classes defined here (.mb-4, .text-muted, .opacity-20) duplicate Tailwind's built-in utilities.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e0b66b and 580d354.

📒 Files selected for processing (1)
  • frontend/src/pages/Database.jsx
🔇 Additional comments (4)
frontend/src/pages/Database.jsx (4)

91-97: LGTM!

The effect correctly handles collection changes with proper dependency management. The mobile sidebar auto-close on selection is a good UX touch.


146-164: LGTM!

The dynamic input rendering based on field types is well-structured. The Boolean select with an empty default option works well with the required attribute for validation.


319-336: LGTM!

The JsonView and SkeletonLoader components are simple and functional. The skeleton provides good loading UX feedback.


117-144: No changes needed. The datetime-local input type already returns ISO 8601 formatted strings, which the backend correctly validates using Date.parse(). The frontend and backend are consistent in handling Date fields as strings, so explicit conversion is unnecessary.

Likely an incorrect or invalid review comment.

@yash-pouranik
yash-pouranik self-requested a review January 12, 2026 17:31
@vercel

vercel Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ur-backend Ready Ready Preview, Comment Jan 12, 2026 5:33pm

@yash-pouranik yash-pouranik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanku for the PR @tejaavula076 , it works well, merging it.
for more - join discord - https://discord.gg/CXJjvJkNWn

@yash-pouranik
yash-pouranik merged commit 63d271a into geturbackend:main Jan 12, 2026
4 of 6 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 4, 2026
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.

2 participants