-
Notifications
You must be signed in to change notification settings - Fork 9
fix: updated logic for pay now button #332
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
Conversation
WalkthroughThe changes update the invoice view component by introducing two new variables: Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant InvoiceView
participant PaymentService
User->>InvoiceView: Load invoice view
InvoiceView->>InvoiceView: Evaluate initialPaymentCheck and showPaymentButton
alt Conditions met for payment
InvoiceView->>User: Render "Pay Now" button
else
InvoiceView->>User: Hide "Pay Now" button
end
User->>InvoiceView: Click "Pay Now" button
InvoiceView->>PaymentService: Process payment
PaymentService-->>InvoiceView: Confirm payment
InvoiceView->>InvoiceView: Set showPaymentButton = false
InvoiceView->>User: Update UI (hide button)
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 (1)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (1)
161-166: Consider optimizing the payment state evaluation.While the logic is correct, it can be simplified by grouping similar conditions.
- initialPaymentCheck = - request?.state === "paid" || - request?.state === "overpaid" || - status === "paid" || - status === "overpaid" || - request?.balance?.balance >= request?.expectedAmount; + initialPaymentCheck = + ["paid", "overpaid"].includes(request?.state) || + ["paid", "overpaid"].includes(status) || + request?.balance?.balance >= request?.expectedAmount;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte(5 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (1)
Learnt from: MantisClone
PR: RequestNetwork/web-components#141
File: packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte:0-0
Timestamp: 2024-11-12T14:52:33.204Z
Learning: In `packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte`, mapping payment network IDs to their respective approval functions in the `checkApproval` function is acceptable and can improve readability and maintainability.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (2)
103-105: LGTM! Clear and descriptive variable declarations.The new variables are well-named and appropriately initialized for their intended purposes.
871-872: LGTM! Comprehensive button visibility management.The visibility logic effectively addresses the PR objective by:
- Properly handling the button state after payment
- Consistently managing visibility based on user role and payment status
- Handling edge cases (network issues, signing state, etc.)
Also applies to: 934-934
Fixes: #321
Problem
The "Pay Now" button is missing in the Invoice View when attempting to pay a second invoice. This issue was observed when a user pays an invoice, then tries to pay a subsequent one—the button does not appear until the page is refreshed.
Changes
Summary by CodeRabbit