Skip to content

fix(transactions): remove duplicate close button on transaction detai…#65

Open
Atharva0506 wants to merge 2 commits into
DjedAlliance:mainfrom
Atharva0506:fix/transaction-modal-duplicate-close-button
Open

fix(transactions): remove duplicate close button on transaction detai…#65
Atharva0506 wants to merge 2 commits into
DjedAlliance:mainfrom
Atharva0506:fix/transaction-modal-duplicate-close-button

Conversation

@Atharva0506
Copy link
Copy Markdown

@Atharva0506 Atharva0506 commented Mar 17, 2026

Addressed Issues:

Fixes #64

Screenshots/Recordings:

Before — Two overlapping x buttons on modal:
564693316-a8aa2771-235f-4874-b236-f3e032b28f17

After — Single close button, modal behaves correctly.
image

Additional Notes:

The modal was rendering two overlapping X close buttons:

  • One from shadcn/ui's built-in <DialogClose /> (inside <DialogHeader>)
  • One manually added <Button> with <X /> from lucide-react

Fix: Removed the manual <Button onClick={() => setIsModalOpen(false)}> and the now-unused X lucide import. The Dialog primitive handles close natively.

Refactor — Badge Risk Level Logic

getRiskLevel(transaction.amountSC) was being called 3–4 times per table row inside inline ternary chains — redundant function calls on every render.

Fix:

  • Added RiskLevel TypeScript type ("high" | "medium" | "low") and updated getRiskLevel return type accordingly
  • Extracted a static riskStyles Record map at module scope (zero re-allocation per render)
  • Inside .map(), computed const riskLevel = getRiskLevel(transaction.amountSC) once per row
  • Badge now uses riskStyles[riskLevel] — clean, readable, and performant

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.

AI Usage Disclosure

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Summary by CodeRabbit

  • Bug Fixes

    • Removed the modal's close (X) button for a cleaner header.
  • Refactor

    • Consistent risk badges: risk label and styling are now unified across the transactions list and detail modal.
    • Improved risk determination so the selected transaction's risk is shown reliably in the modal.

…l modal

- Remove redundant manual × button conflicting with DialogClose primitive

- Refactor Badge risk level logic: extract getRiskLevel() call into const riskLevel

- Replace ternary chain with static riskStyles Record map at module scope

Closes DjedAlliance#64
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ba6155b-6cb5-4412-b038-da80083f1fa7

📥 Commits

Reviewing files that changed from the base of the PR and between 9883c3c and bfbd817.

📒 Files selected for processing (1)
  • dashboard/app/transactions/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • dashboard/app/transactions/page.tsx

📝 Walkthrough

Walkthrough

Introduces a typed RiskLevel and riskStyles mapping in the transactions page, computes risk once per transaction for table rows, uses the same computed risk in the detail modal, and removes the duplicate "X" close button from the dialog header.

Changes

Cohort / File(s) Summary
Risk Modeling & Modal Fix
dashboard/app/transactions/page.tsx
Added RiskLevel type and riskStyles map; changed getRiskLevel to return RiskLevel; compute riskLevel per transaction and apply riskStyles to table badges and modal; replaced inline risk-class logic with riskStyles; removed duplicate X close button and its import from the dialog header.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble on code with a twitch of my nose,
Risk levels aligned in tidy rows,
One little X now sits alone at the top,
No doubled escape—what a hop! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes refactored risk-level styling logic beyond the scope of simply removing the duplicate close button, introducing a new RiskLevel type and riskStyles mapping. Consider separating the risk-level refactoring into a separate PR or clarify in the PR description why this additional change is necessary for the duplicate button fix.
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 (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(transactions): remove duplicate close button on transaction detai…' directly addresses the main change—removing a duplicate close button from the transaction detail modal.
Linked Issues check ✅ Passed The PR successfully addresses issue #64 by removing the duplicate close button and refactoring risk-level logic to use a typed RiskLevel and riskStyles map, meeting all coding requirements.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dashboard/app/transactions/page.tsx`:
- Around line 31-35: The modal uses selectedTransaction?.risk while the list
derives risk from amountSC, causing inconsistent styling; refactor to compute
the same risk level used by the list and reuse the riskStyles mapping for the
dialog. Locate where amountSC→risk is calculated (the same logic used when
rendering rows) and extract or call it from the detail modal so you compute a
riskLevel (e.g., getRiskLevel(selectedTransaction.amountSC) or reuse the
existing expression) and replace branches that inspect selectedTransaction?.risk
with using riskStyles[riskLevel] for the modal’s className and any conditional
UI. Ensure all places that currently branch on selectedTransaction?.risk (the
detail modal rendering) use the unified riskLevel and the riskStyles constant so
list and modal styling are consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e79bd332-591e-4fd0-8081-cb50fc48f574

📥 Commits

Reviewing files that changed from the base of the PR and between c86e6f1 and 9883c3c.

📒 Files selected for processing (1)
  • dashboard/app/transactions/page.tsx

Comment thread dashboard/app/transactions/page.tsx
Use getRiskLevel(amountSC) for modal badge styling and label to match table behavior.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the duplicate close button on the transaction detail modal by removing the manual <Button>/<X> close control (the shadcn <DialogClose /> already provides one), and refactors the risk-level rendering to compute getRiskLevel once per row and look up styles from a static riskStyles map. The modal's risk badge is also switched from selectedTransaction?.risk to a derived selectedRiskLevel, unifying risk display logic between the table and the modal.

Changes:

  • Remove redundant manual close button and unused X lucide-react import in the transaction detail modal.
  • Introduce RiskLevel type and module-scope riskStyles map; consume them in the table row Badge with a memoized per-row riskLevel.
  • Use a derived selectedRiskLevel (from selectedTransaction.amountSC) for the modal's risk badge instead of selectedTransaction?.risk.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[BUG]: Duplicate close button (×) on Transaction Detail modal

2 participants