input-output-hk / dapps-certification-web

Certification as a service for the Cardano dApps platform
Apache License 2.0
5 stars 0 forks source link

fix: display Payment Details verification modal when profile already has balance in it #78

Open amnambiar opened 5 months ago

amnambiar commented 5 months ago

Pull request template

Description

https://input-output.atlassian.net/browse/PLT-9671

Checklist

Summary by CodeRabbit

coderabbitai[bot] commented 5 months ago

Walkthrough

The updates across several files primarily focus on enhancing the payment and registration processes within an application. Changes include the restructuring of data handling in payment details, modifications in registration logic to incorporate fee calculations, and updates to state management in Redux slices. The modifications aim to streamline user interactions and backend processes related to user registration and payment verification.

Changes

File Path Change Summary
README.md Updated shields percentage values in the project documentation.
src/.../PaymentDetailsVerification.tsx Modified data object structure in Props and updated display logic for payment details.
src/.../RegisterSection.tsx
src/pages/landing/index.tsx
Updated registration logic, replaced onSubmit with onClickPay, added new state variables and props related to payment and form submission.
src/store/slices/auth.slice.ts
src/store/slices/profile.slice.ts
Enhanced profile management by fetching and handling profile balance.
src/store/slices/register.slice.ts Revised fee calculation logic, removed redundant functions, and adjusted registration payment handling.
src/store/slices/tiers.slice.ts Extended the Tier interface with new properties for better tier management.

Recent Review Details **Configuration used: .coderabbit.yaml**
Commits Files that changed from the base of the PR and between db7c63f43697895498ad6f929dcf462146a8d16c and 1861909936029fd20d025344ec5c5b5546766308.
Files selected for processing (8) * README.md (1 hunks) * src/components/PaymentConfirmation/PaymentDetailsVerification.tsx (2 hunks) * src/pages/landing/components/RegisterSection.tsx (2 hunks) * src/pages/landing/index.tsx (4 hunks) * src/store/slices/auth.slice.ts (2 hunks) * src/store/slices/profile.slice.ts (4 hunks) * src/store/slices/register.slice.ts (3 hunks) * src/store/slices/tiers.slice.ts (1 hunks)
Additional comments not posted (18)
src/store/slices/tiers.slice.ts (1)
`15-17`: Added properties `type`, `duration`, and `description` to the `Tier` interface enhance the data structure and provide more detailed information about each tier. Ensure that these new fields are properly utilized wherever the `Tier` type is used throughout the application.
README.md (1)
`5-5`: Updated coverage percentages in the testing tool section. Ensure these values are accurate and reflect the current state of the codebase's test coverage.
src/store/slices/auth.slice.ts (2)
`4-4`: Imported `fetchProfileBalance` from `profile.slice.ts`. Verify that this function is used appropriately within this slice and that there are no unresolved dependencies. --- `22-22`: Dispatched `fetchProfileBalance({})` after fetching active subscriptions. This ensures that the profile balance is updated immediately after checking for active subscriptions, which is crucial for maintaining accurate state information.
src/components/PaymentConfirmation/PaymentDetailsVerification.tsx (2)
`14-15`: Modified the `data` object in the `Props` interface to include `balance: number` instead of `fee: BigNum`. This change aligns with the new requirements to handle user balances directly in the payment details verification. --- `49-50`: Updated display logic for payment details to show amounts in USD and ADA differently based on the new structure of the `data` object. This enhancement improves the clarity of payment information presented to the user.
src/pages/landing/index.tsx (5)
`12-12`: Imported `calculateFee` from `store/slices/register.slice` along with other functions. Ensure that `calculateFee` is used appropriately within this component to handle fee calculations accurately. --- `38-47`: Added new state variables `price`, `profileBalance`, `detailsToBeVerified`, `submitForm`, and `form`. These variables are essential for managing the state related to user registration and payment processes. Verify that they are used consistently and correctly throughout the component. --- `61-76`: Updated `handleRegistration` function to include logic for calculating fees and setting verification details based on the selected tier and user input. This update is crucial for handling the registration process accurately and efficiently. --- `82-89`: Updated `onPaymentDetailsVerified` function to handle payment registration and form submission. This function now correctly handles the workflow of verifying payment details and proceeding with user registration. --- `103-103`: Included a new prop `onClickPay` in the `RegisterSection` component call. This change ensures that the custom payment handling function is used, which is important for integrating the new payment logic.
src/pages/landing/components/RegisterSection.tsx (2)
`19-20`: Replaced the `onSubmit` function with `onClickPay` in the `Props` interface and added a new boolean property `submitForm`. These changes are crucial for integrating the new payment handling logic into the registration process. --- `69-69`: Updated the `onSubmit` function within the `RegisterSection` component to call `onClickPay` instead of `onSubmit`. This update ensures that the custom payment handling function is used, which is important for the new payment logic.
src/store/slices/register.slice.ts (3)
`67-70`: Modified the `calculateFee` function to accept two `number` parameters instead of `BigNum`. This change simplifies the function's interface and aligns with the new requirements for handling fees based on numerical values directly. --- `129-136`: Updated the `register` function to use `profileBalance` directly and pass it along with `subscription.price` to `calculateFee`. This update is crucial for integrating the new payment logic into the registration process. --- `151-159`: Updated the `payForRegister` function to include a `balance` parameter and handle payment based on the balance status. This function now correctly handles the workflow of making payments based on the user's balance, which is important for the new payment logic.
src/store/slices/profile.slice.ts (2)
`87-87`: Added a `profileBalance` field to the `ProfileState` interface. This field is essential for keeping track of the user's profile balance, which is crucial for the new payment handling logic. --- `240-248`: Introduced the `fetchProfileBalance` async thunk to fetch profile balance data. This function is crucial for updating the user's profile balance in the state, which is important for the new payment logic.
--- 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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` 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 as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 5 months ago

Coverage Report

Summary

Lines Statements Branches Functions
Coverage: 6%
6.34% (149/2350) 1.39% (19/1361) 4.43% (22/496)

JUnit

Tests Skipped Failures Errors Time
6 0 :zzz: 0 :x: 0 :fire: 18.408s :stopwatch:
Coverage (6%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files6.341.394.436.03 
src010000 
   index.tsx0100002–78
src/app0000 
   App.tsx00001–136
src/components/Avatar90.940100100 
   index.tsx90.94010010014–24
src/components/CertificationMetadataForm0000 
   index.tsx00001–177
src/components/CertificationMetadataForm/components0000 
   AuditReportForm.tsx0100003–66
   FeedbackModal.tsx00003–44
   ReportScriptForm.tsx00001–158
   ReportScriptFormConfirmModal.tsx0100003–31
src/components/CreateCertificate0000 
   CreateCertificate.tsx00001–196
src/components/CustomSwitch0000 
   CustomSwitch.tsx00001–53
src/components/LogsView0000 
   LogsView.tsx00001–107
   LogsViewEntry.tsx0100001–15
src/components/PaymentConfirmation0000 
   PaymentDetailsVerification.tsx00002–71
src/components/ProgressCard0000 
   CircularProgressBar.tsx00001–40
   ProgressCard.tsx00001–44
src/components/ReconnectWallet010000 
   ReconnectWallet.tsx0100001–31
src/components/RepoAccessStatus0000 
   RepoAccessStatus.tsx00002–28
src/components/Snackbar0000 
   index.tsx00001–56
src/components/StatusIcon0000 
   StatusIcon.tsx00004–18
src/components/Table0000 
   Table.tsx00001–216
src/components/Table/components/ColViz0000 
   ColViz.tsx00001–112
src/components/charts/PieChart0000 
   PieChart.tsx00002–32
src/compositions/InputGroup0000 
   index.tsx00003–35
src/compositions/InputGroup/components0000 
   Container.tsx00003–19
   Input.tsx00003–59
src/compositions/Timeline010000 
   Timeline.tsx0100003–23
src/compositions/Timeline/components/TimelineItem12.38009.41 
   TimelineItem.tsx00003–70
   timeline.helper.tsx16.040011.7620, 32, 36–57, 64–74, 79–142
src/pages/certification21.950016.16 
   Certification.helper.tsx27.830020.5195–100, 104–112, 116–128, 135, 145, 149–150, 154, 158–162, 167–168, 173–174, 183–227
   Certification.tsx00002–81
src/pages/certification/certification-result0000 
   CertificationResult.tsx00001–153
   FullReportTable.tsx00001–61
   fullReportTable.helper.tsx00001–126
src/pages/certification/components0000 
   FailedStatus.tsx00001–41
   FileCoverageContainer.tsx00002–96
   ResultContainer.tsx00002–114
   SuccessCard.tsx00001–89
   UnitTestFailureCard.tsx00001–35
src/pages/certification/components/AuditorRunTestForm0000 
   AuditorRunTestForm.tsx00001–312
src/pages/certification/components/DownloadResult010000 
   DownloadResult.tsx0100001–20
src/pages/certification/components/TimelineView0000 
   TimelineView.tsx00001–235
src/pages/home0000 
   index.tsx00001–195
src/pages/landing0000 
   index.tsx00001–99
src/pages/landing/components48.3819.3546.4247.95 
   ConnectSection.tsx76505073.6846, 70–71, 75–76, 80, 85–94, 125–129
   RegisterModal.tsx00003–43
   RegisterSection.tsx00001–161
   SubscriptionSection.tsx100100100100 
src/pages/metrics0000 
   index.tsx00001–112
src/pages/metrics/components0000 
   AuditorReportsChart.tsx00002–73
   MetricWidget.tsx0100003–37
   RunTimesChart.tsx00002–78
   SubscriptionsChart.tsx0100002–59
src/pages/profile0000 
   index.tsx00001–103
src/pages/reportUpload010000 
   index.tsx0100003–19
src/pages/session0000 
   index.tsx00001–54
src/pages/session/components29.262.715.3829.41 
   AppBar.tsx88.885057.1486.9525, 29, 33
   AppLayout.tsx00002–44
   NavBar.tsx00002–115
src/pages/support-commands0000 
   config.tsx010010001–72
   index.tsx00001–177
src/pages/support-commands/components0000 
   Card.tsx00001–32
   DeleteUserModal.tsx0100003–60
   UserDetailsModal.tsx00001–112
src/pages/support-commands/details0000 
   index.tsx00001–200
src/pages/testingHistory010000 
   index.tsx0100001–37
src/pages/testingHistory/components0000 
   AppTable.tsx00001–269
   HistoryContainer.tsx00001–64
src/utils10080100100 
   test-utils.tsx1008010010022