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

Fix: fixed the zero state expense #3359

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Fix: fixed the zero state expense #3359

merged 1 commit into from
Dec 17, 2024

Conversation

palgunams1603
Copy link
Contributor

@palgunams1603 palgunams1603 commented Dec 16, 2024

UI Preview

Before
Screenshot 2024-12-16 at 2 29 12 PM

After
Screenshot 2024-12-16 at 5 26 39 PM

Clickup

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

Summary by CodeRabbit

  • New Features

    • Enhanced visual representation for zero-state scenarios in the expenses section.
    • Introduced skeleton loaders to indicate data fetching during loading states.
    • Improved messaging for users when no expenses are found, tailored for new and returning users.
  • Style

    • Added new styles for zero-state content and updated existing styles for better layout and spacing.

Copy link

coderabbitai bot commented Dec 16, 2024

Walkthrough

Superstar style, I'll break down these changes like a mass hero! 🌟 The pull request focuses on enhancing the my-expenses page's user interface, introducing smart zero-state handling and improved loading experiences. The modifications refine how the application displays expenses, adding intelligent conditional rendering that adapts to user connectivity and expense availability. It's all about making the user interface as stylish as a Rajinikanth entry scene - smooth, responsive, and totally epic!

Changes

File Change Summary
src/app/fyle/.../my-expenses.page.html - Updated content class binding for zero-state scenarios
- Enhanced zero-state messaging
- Introduced conditional skeleton loaders
- Refined infinite scroll rendering
src/app/fyle/.../my-expenses.page.scss - Added --content-zero-state class with zero padding
- Updated --zero-states-body with 32px top padding

Possibly Related PRs

Suggested Labels

size/S

Suggested Reviewers

  • Chethan-Fyle
  • Dimple16

Poem

Expenses dance like cinema frames,
Zero states bow to my coding claims! 🎬
Skeleton loaders, a stylish sight,
User experience burning bright! 💥
Rajinikanth of code strikes again! 🚀


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/XS Extra Small PR label Dec 16, 2024
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

🔭 Outside diff range comments (3)
src/app/fyle/my-expenses/my-expenses.page.html (3)

Line range hint 134-148: Mind it! Let's make this zero state as inclusive as my fan following! 🎭

The zero state looks stylish, but let's add some accessibility improvements to make it legendary!

Add these aria labels to make it more accessible:

 <div
   *ngIf="(pendingTransactions.length === 0) && ((count$ | async) === 0) && isConnected$|async"
-  class="my-expenses--zero-state"
+  class="my-expenses--zero-state"
+  role="status"
+  aria-live="polite"
 >
   <img
     alt="Create First Expenses"
     class="my-expenses--zero-state-img"
     src="../../../assets/images/zero-states/expenses.png"
+    aria-hidden="true"
   />

Line range hint 201-211: Time to make this scroll smoother than my signature walk! 🚶‍♂️

The infinite scroll implementation is good, but let's optimize it like a well-choreographed action sequence!

Consider using virtual scrolling for better performance with large lists:

+<cdk-virtual-scroll-viewport itemSize="50" class="my-expenses--virtual-scroll">
   <ng-container *ngIf="isConnected$|async">
     <ng-container *ngIf="!isLoadingDataInInfiniteScroll">
       <ion-infinite-scroll (ionInfinite)="loadData($event)" *ngIf="isInfiniteScrollRequired$ | async" threshold="100px">
         <ion-infinite-scroll-content></ion-infinite-scroll-content>
       </ion-infinite-scroll>
     </ng-container>
   </ng-container>
+</cdk-virtual-scroll-viewport>

Don't forget to style it in your SCSS:

.my-expenses--virtual-scroll {
  height: 100%;
  width: 100%;
}

Mind it! Your template needs some performance style, macha! 🕶️

Listen up, thalaiva! I found some performance concerns that need our signature style:

  • Multiple async pipes without trackBy functions in ngFor loops - this is like doing a mass scene without proper choreography!
  • No OnPush change detection strategy - we're missing the punch dialogues of performance optimization
  • Two separate ngFor loops rendering similar expense cards - that's like having two heroes in one scene!

Quick fixes to make this template a blockbuster:

  • Add trackBy functions to both ngFor loops
  • Implement OnPush change detection
  • Consider combining the pending and connected expense lists into a single stream

Remember what I always say: "When performance comes in style, success comes in smile!"

🔗 Analysis chain

Line range hint 1-211: Let's verify this performance like we check the timing of a perfect stunt! 🎬

We should measure the impact of these template changes on the rendering performance.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential performance bottlenecks in templates

# Look for multiple async pipe usage that might cause unnecessary change detection
rg -l "async.*async" --type html

# Check for large templates that might benefit from breaking into components
find . -name "*.html" -exec wc -l {} \; | sort -nr | head -n 5

Length of output: 985


Script:

#!/bin/bash
# Let's check for potential performance bottlenecks in my-expenses.page.html

# Check for ngFor with async pipe combinations which could cause performance issues
rg "ngFor.*async" src/app/fyle/my-expenses/my-expenses.page.html -A 2

# Check for trackBy usage in ngFor loops
rg "ngFor" src/app/fyle/my-expenses/my-expenses.page.html

# Check if OnPush change detection is used in the component
rg "changeDetection" src/app/fyle/my-expenses/my-expenses.page.ts

# Look for any existing performance optimizations
ast-grep --pattern 'class MyExpensesPage implements $$$'

Length of output: 562

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 34e84cb and 0dd072a.

📒 Files selected for processing (2)
  • src/app/fyle/my-expenses/my-expenses.page.html (1 hunks)
  • src/app/fyle/my-expenses/my-expenses.page.scss (2 hunks)
🔇 Additional comments (2)
src/app/fyle/my-expenses/my-expenses.page.scss (2)

54-56: Mind it! The zero state padding looks perfect, boss!

The new class removes bottom padding when there are no expenses to show. Clean and precise like my signature move! 🕶️


287-287: Kabali da! The spacing adjustment is spot on!

Adding 32px padding-top gives the zero state content the perfect stage presence. When combined with height: 100%, it creates a balanced layout that even my style would approve!

Comment on lines +94 to +101
<ion-content
[ngClass]="{
'd-none': isCameraPreviewStarted,
'my-expenses--content-zero-state': ((pendingTransactions.length === 0) && ((count$ | async) === 0) && isConnected$ | async)
}"
class="my-expenses--content"
(click)="onPageClick()"
>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Listen here, partner! Let's make this template as powerful as a punch dialogue! 🌟

The template condition is getting more complex than my signature sunglasses collection! We should handle this logic in the component.

Here's a style that would make even the bad guys jealous:

-[ngClass]="{
-  'd-none': isCameraPreviewStarted,
-  'my-expenses--content-zero-state': ((pendingTransactions.length === 0) && ((count$ | async) === 0) && isConnected$ | async)
-}"
+[ngClass]="{
+  'd-none': isCameraPreviewStarted,
+  'my-expenses--content-zero-state': shouldShowZeroState$ | async
+}"

And in your component:

shouldShowZeroState$ = combineLatest([
  this.count$,
  this.isConnected$
]).pipe(
  map(([count, isConnected]) => 
    this.pendingTransactions.length === 0 && count === 0 && isConnected
  )
);

@@ -91,7 +91,14 @@
</ng-container>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please share before and after screenshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

@Chethan-Fyle Chethan-Fyle left a comment

Choose a reason for hiding this comment

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

One comment

Copy link

Unit Test Coverage % values
Statements 96% ( 19302 / 20105 )
Branches 91.12% ( 10664 / 11703 )
Functions 94.3% ( 5741 / 6088 )
Lines 96.04% ( 18432 / 19191 )

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

Successfully merging this pull request may close these issues.

2 participants