Skip to content
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

feat: add new review-split-expense template #3463

Open
wants to merge 8 commits into
base: feat_split_expense
Choose a base branch
from

Conversation

Sishhhh
Copy link
Contributor

@Sishhhh Sishhhh commented Jan 31, 2025

Clickup

https://app.clickup.com/t/86cxube0g

UI Preview

Screenshot 2025-02-05 at 3 45 56 PM

Summary by CodeRabbit

  • New Features

    • Introduced an interactive modal for reviewing split expenses. Users can view a series of expense cards, select an expense to navigate to its detailed view, and easily close the modal using the header button.
  • Style

    • Enhanced the modal presentation with a full-height, modern layout for a more immersive and consistent user experience.
  • Tests

    • Added unit tests to ensure the functionality of the ReviewSplitExpenseComponent, covering component creation, handling of empty data, and modal dismissal actions.

@Sishhhh Sishhhh marked this pull request as draft January 31, 2025 04:40
Copy link

coderabbitai bot commented Jan 31, 2025

Walkthrough

This pull request introduces a new Angular component named ReviewSplitExpenseComponent used for reviewing split expenses. The component features an updated HTML layout with a header that includes a title and close button, and a content area that iterates over split expenses to render expense cards. Its logic, including event handling for navigating to a transaction and closing the modal, is implemented in the component’s TypeScript file. New SCSS styling is provided for the component and modal appearance, and unit tests are added to verify functionality. Additionally, the component is registered in the shared module.

Changes

File(s) Change Summary
src/app/shared/components/review-split-expense/... (HTML, SCSS, TS, spec) - HTML: New structure with an <ion-header>, close button (invoking close()) and an <ion-content> rendering expense cards with event binding.
- SCSS: Styles for the modal (.review-split-expense-modal), header, body, and divider.
- TS: New component with @Input() splitExpenses and methods goToExpense() & close(), utilizing ModalController for modal dismissal.
- Spec: Unit tests verifying component creation, property initialization, and modal dismissal behaviors.
src/app/shared/shared.module.ts Added the ReviewSplitExpenseComponent to the module’s declarations and exports.
src/global.scss Defined new CSS rules for ion-modal.review-split-expense-modal to allow full-height modal styling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as ReviewSplitExpenseComponent
    participant M as ModalController

    U->>C: Click on expense card (goToTransaction)
    C->>M: dismiss({ action: "goToTransaction", expense: selectedExpense })
    M-->>C: Modal dismissed

    U->>C: Click on close button
    C->>M: dismiss({ action: "close" })
    M-->>C: Modal dismissed
Loading

Suggested labels

size/L

Suggested reviewers

  • Dimple16
  • Chethan-Fyle

Poem

In a flash, the code’s transformed, my friend,
Modal magic in every blend.
A new component with Rajini flair,
Expenses reviewed with style so rare.
Tests run strong, dismissing barriers with might,
CodeRabbit’s code shines, lighting up the night!

🚀😎 Jai Ho to these changes!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the size/M Medium PR label Jan 31, 2025
Copy link

PR description must contain a link to a ClickUp (case-insensitive)

@Sishhhh Sishhhh requested review from arjunaj5 and removed request for arjunaj5 and Chethan-Fyle January 31, 2025 04:40
Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

@Sishhhh Sishhhh marked this pull request as ready for review February 5, 2025 05:36
Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

@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: 8

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 456ee36 and 0fa9224.

📒 Files selected for processing (7)
  • src/app/fyle/split-expense/split-expense.page.spec.ts (1 hunks)
  • src/app/fyle/split-expense/split-expense.page.ts (4 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.html (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.scss (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.spec.ts (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.ts (1 hunks)
  • src/app/shared/shared.module.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/fyle/split-expense/split-expense.page.ts

[error] 1141-1141: This let declares a variable that is only assigned once.

'category' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

🪛 ESLint
src/app/fyle/split-expense/split-expense.page.ts

[error] 1141-1141: 'category' is never reassigned. Use 'const' instead.

(prefer-const)

🪛 GitHub Check: Run linters
src/app/fyle/split-expense/split-expense.page.ts

[failure] 1121-1121:
Unsafe assignment of an any value


[failure] 1130-1130:
Unsafe array destructuring of a tuple element with an any value


[failure] 1133-1133:
Unsafe member access .action on an any value


[failure] 1139-1139:
Unsafe member access .action on an any value


[failure] 1140-1140:
Unsafe assignment of an any value


[failure] 1140-1140:
Unsafe member access .expense on an any value


[failure] 1141-1141:
Unsafe assignment of an any value


[failure] 1141-1141:
'category' is never reassigned. Use 'const' instead


[failure] 1141-1141:
Unsafe member access .category on an any value


[failure] 1141-1141:
Unsafe call of an any typed value

🪛 GitHub Actions: Lint
src/app/fyle/split-expense/split-expense.page.ts

[error] 1121-1121: Unsafe assignment of an any value

🔇 Additional comments (1)
src/app/fyle/split-expense/split-expense.page.spec.ts (1)

1949-1967: Hey, why you skipping this important test case, partner?

The test case for handling API failure in postSplitExpenseComments is marked as skipped. This test is crucial for ensuring proper error handling when the API fails.

Please enable this test case by removing the x prefix from xit to ensure robust error handling coverage.

@@ -249,6 +250,7 @@ import { CCExpenseMerchantInfoModalComponent } from './components/cc-expense-mer
FyPolicyViolationComponent,
PolicyViolationActionComponent,
SplitExpensePolicyViolationComponent,
ReviewSplitExpenseComponent,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Hey thalaiva, don't forget to export your powerful component!

The ReviewSplitExpenseComponent needs to be added to the exports array if it will be used in other modules.

Add the component to the exports array:

  exports: [
+   ReviewSplitExpenseComponent,
    // ... other exports
  ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ReviewSplitExpenseComponent,
@NgModule({
declarations: [
// ... other declarations
ReviewSplitExpenseComponent,
// ... possibly more declarations
],
exports: [
ReviewSplitExpenseComponent,
// ... other exports
],
imports: [
// ... imports
]
})
export class SharedModule { }

src/app/fyle/split-expense/split-expense.page.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

1 similar comment
Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa9224 and f0a8dac.

📒 Files selected for processing (1)
  • src/app/fyle/split-expense/split-expense.page.ts (4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/fyle/split-expense/split-expense.page.ts

[error] 1143-1143: This let declares a variable that is only assigned once.

'category' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

🪛 ESLint
src/app/fyle/split-expense/split-expense.page.ts

[error] 1143-1143: 'category' is never reassigned. Use 'const' instead.

(prefer-const)

🪛 GitHub Check: Run linters
src/app/fyle/split-expense/split-expense.page.ts

[failure] 1143-1143:
Unsafe assignment of an any value


[failure] 1143-1143:
'category' is never reassigned. Use 'const' instead


[failure] 1143-1143:
Unsafe member access .name on an any value


[failure] 1143-1143:
Unsafe call of an any typed value


[failure] 1146-1146:
Unsafe assignment of an any value


[failure] 1148-1148:
Unsafe assignment of an any value


[failure] 1150-1150:
Unsafe assignment of an any value

🪛 GitHub Actions: Lint
src/app/fyle/split-expense/split-expense.page.ts

[error] 1143-1143: Unsafe assignment of an any value

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (3)
src/app/fyle/split-expense/split-expense.page.ts (3)

53-54: Mind-blowing imports, thalaiva!

The imports are perfectly aligned with the new modal functionality.


699-699: Style ah irukku, thalaiva! Perfect timing for the modal!

The modal is shown right after the split expense operation succeeds, providing a smooth user experience.


1118-1154: 🛠️ Refactor suggestion

Time to add some superhero-level type safety to your code, thalaiva!

Let's make the code more robust with proper TypeScript types:

-  async openReviewSplitExpenseModal(expense: Expense): Promise<void> {
+  async openReviewSplitExpenseModal(expense: PlatformExpense[]): Promise<void> {
   const reviewModal = await this.modalController.create({
     component: ReviewSplitExpenseComponent,
     componentProps: {
-      splitExpenses: expense,
+      splitExpenses: expense as Expense[],
     },
     mode: 'ios',
     presentingElement: await this.modalController.getTop(),
     ...this.modalProperties.getModalDefaultProperties(),
   });

   await reviewModal.present();

-  const { data }: { data?: { dismissed: boolean; action: string; expense?: Expense } } =
+  interface ModalData {
+    action: 'close' | 'navigate';
+    expense?: Expense;
+  }
+
+  const { data } = await reviewModal.onWillDismiss<ModalData>();

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1143-1143: This let declares a variable that is only assigned once.

'category' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

🪛 ESLint

[error] 1143-1143: 'category' is never reassigned. Use 'const' instead.

(prefer-const)

🪛 GitHub Check: Run linters

[failure] 1143-1143:
Unsafe assignment of an any value


[failure] 1143-1143:
'category' is never reassigned. Use 'const' instead


[failure] 1143-1143:
Unsafe member access .name on an any value


[failure] 1143-1143:
Unsafe call of an any typed value


[failure] 1146-1146:
Unsafe assignment of an any value


[failure] 1148-1148:
Unsafe assignment of an any value


[failure] 1150-1150:
Unsafe assignment of an any value

🪛 GitHub Actions: Lint

[error] 1143-1143: Unsafe assignment of an any value

src/app/fyle/split-expense/split-expense.page.ts Outdated Show resolved Hide resolved
@Sishhhh Sishhhh marked this pull request as draft February 5, 2025 05:44
Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

github-actions bot commented Feb 5, 2025

PR description must contain a link to a ClickUp (case-insensitive)

@Sishhhh Sishhhh marked this pull request as ready for review February 5, 2025 10:23
Copy link

@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: 5

♻️ Duplicate comments (1)
src/app/shared/components/review-split-expense/review-split-expense.component.html (1)

16-25: 🧹 Nitpick (assertive)

Expense List – Time to supercharge your iteration!
My friend, while your expense list is working fine, the legendary coder in you can take it one step further by switching to semantic elements like <ul> and <li> and by using a trackBy function for the ngFor loop. This not only boosts performance but also adds clarity – a true signature move. Note: This suggestion echoes previous feedback, so it’s tagged as duplicate.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0a8dac and e9f9e31.

📒 Files selected for processing (6)
  • src/app/shared/components/review-split-expense/review-split-expense.component.html (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.scss (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.spec.ts (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.ts (1 hunks)
  • src/app/shared/shared.module.ts (3 hunks)
  • src/global.scss (1 hunks)
🔇 Additional comments (4)
src/app/shared/components/review-split-expense/review-split-expense.component.ts (2)

10-10: Mind-blowing input property, macha! But let's add some type safety!

The input property needs proper typing to ensure type safety.

-  @Input() splitExpenses: Expense[];
+  @Input() splitExpenses!: Expense[];

14-20: Your code style is as powerful as my punch dialogues, but let's make it even stronger!

The event parameter needs proper typing for better type safety and maintainability.

-  goToTransaction(event: { expense: Expense; expenseIndex: number }): void {
+  interface TransactionEvent {
+    expense: Expense;
+    expenseIndex: number;
+  }
+
+  goToTransaction(event: TransactionEvent): void {
src/app/shared/shared.module.ts (1)

120-120: Your module changes are as perfect as my style, macha!

The component is properly declared and exported in the shared module.

Also applies to: 253-253, 425-425

src/app/shared/components/review-split-expense/review-split-expense.component.scss (1)

3-27: 🧹 Nitpick (assertive)

Your styles are stylish, but let's make them legendary!

Consider using CSS custom properties for better maintainability.

 .review-split-expense-modal {
+  --review-modal-font-size: 18px;
+  --review-modal-line-height: 27px;
+  --review-modal-padding: 12px;
+  --review-modal-margin: 8px;
   border-bottom: 1px solid $grey;
-  margin-bottom: 8px;
+  margin-bottom: var(--review-modal-margin);

   &--header {
     display: flex;
     justify-content: flex-start;
     align-items: center;
-    font-size: 18px;
+    font-size: var(--review-modal-font-size);
     font-weight: 500;
-    line-height: 27px;
+    line-height: var(--review-modal-line-height);
-    padding-inline: 12px;
+    padding-inline: var(--review-modal-padding);
   }

Likely invalid or redundant comment.

Comment on lines +915 to +923
ion-modal.review-split-expense-modal {
&::part(content) {
border-radius: 0 !important;
max-height: 100% !important;
position: absolute;
top: 0 !important;
bottom: 0 !important;
}
}
Copy link

@coderabbitai coderabbitai bot Feb 5, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Modal Style – A blockbuster design!
My friend, the new styles for ion-modal.review-split-expense-modal are absolutely superstar—ensuring the modal spans the full height of the screen. Just double-check to ensure these overrides (with !important) play well with other modals in the app. Small tweaks now could save troubles later.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Sishhhh, can you check why there's some space at the bottom?

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Dimple, that was due to the showBackDrop set as true when we opened the modal from the split-expense page. Setting it to false will remove the extra space from the bottom.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-02-06 at 2 53 25 PM

Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

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

added comments

Comment on lines +915 to +923
ion-modal.review-split-expense-modal {
&::part(content) {
border-radius: 0 !important;
max-height: 100% !important;
position: absolute;
top: 0 !important;
bottom: 0 !important;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@Sishhhh, can you check why there's some space at the bottom?

@@ -0,0 +1,60 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the screenshot of the code coverage report?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-02-06 at 2 35 56 PM

Copy link

@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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9f9e31 and e6f9e05.

📒 Files selected for processing (4)
  • src/app/shared/components/review-split-expense/review-split-expense.component.html (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.scss (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.spec.ts (1 hunks)
  • src/app/shared/components/review-split-expense/review-split-expense.component.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (1)
src/app/shared/components/review-split-expense/review-split-expense.component.html (1)

1-12: 🧹 Nitpick (assertive)

Let's make this modal accessible to everyone, thalaiva!

Add ARIA attributes to improve accessibility for screen readers.

-<ion-header mode="md" class="review-split-expense-modal">
+<ion-header mode="md" class="review-split-expense-modal" role="dialog" aria-labelledby="modal-title">
   <ion-toolbar>
     <div class="review-split-expense-modal--header">
       <ion-buttons>
-        <ion-button (click)="close()">
+        <ion-button (click)="close()" aria-label="Close modal">
           <mat-icon class="fy-icon-close" svgIcon="cross"></mat-icon>
         </ion-button>
       </ion-buttons>
-      <ion-title>Review split expenses</ion-title>
+      <ion-title id="modal-title">Review split expenses</ion-title>
     </div>
   </ion-toolbar>
 </ion-header>

Likely invalid or redundant comment.

@Sishhhh Sishhhh requested a review from Dimple16 February 6, 2025 09:32
Copy link

github-actions bot commented Feb 6, 2025

Unit Test Coverage % values
Statements 96.08% ( 19757 / 20562 )
Branches 91.13% ( 10850 / 11906 )
Functions 94.38% ( 5871 / 6220 )
Lines 96.13% ( 18873 / 19631 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants