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: autocoded msg and error msg align fix and separate autocoded msg #3418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Sishhhh
Copy link
Contributor

@Sishhhh Sishhhh commented Jan 12, 2025

Clickup

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

Code Coverage

Please add code coverage here

UI Preview

Previous UI :

Screenshot 2025-01-13 at 2 16 23 AM

Updated UI :

Screenshot 2025-01-13 at 2 07 49 AM Screenshot 2025-01-13 at 2 08 03 AM Screenshot 2025-01-13 at 2 09 09 AM

Summary by CodeRabbit

Release Notes

  • UI/UX Improvements

    • Enhanced currency input component with more detailed auto-coding messages.
    • Refined layout and spacing for currency and amount input fields, improving overall organization and clarity.
  • Bug Fixes

    • Improved handling of auto-coded currency and amount messages for better user feedback.
    • Adjusted input field positioning and alignment to enhance usability.

These updates aim to provide a clearer user experience and more precise input field styling.

Copy link

coderabbitai bot commented Jan 12, 2025

Walkthrough

Listen up, superstar! We’ve got a flashy update for the currency component that'll make your code shine! The changes involve restructuring the fy-currency component's layout and improving how we handle auto-coded messages. We’ve revamped the HTML, fine-tuned CSS margins and widths, and split the auto-code messages into distinct variables for currency and amount. It’s like giving your code a stylish makeover!

Changes

File Change Summary
src/app/fyle/add-edit-expense/add-edit-expense.page.scss Adjusted margin from -68px 4px 48px 33% to -73px 4px 48px 53%
src/app/shared/components/fy-currency/fy-currency.component.html Restructured input containers, added separate auto-coded message divs
src/app/shared/components/fy-currency/fy-currency.component.scss Modified flex alignment, adjusted block widths and margins
src/app/shared/components/fy-currency/fy-currency.component.ts Replaced autoCodeMessage with currencyAutoCodeMessage and amountAutoCodeMessage
src/app/shared/components/fy-currency/fy-currency.component.spec.ts Updated test cases to reflect new variable names for clarity

Possibly related PRs

Suggested Reviewers

  • Dimple16
  • arjunaj5
  • Chethan-Fyle

Poem

Behold, the code that dances bright,
Margins shift with Rajini might!
Currency flows like silver screen,
Auto-messages now sharp and clean!
Thalaiva's style in every line,
Code transformation - simply divine! 🔥💻

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 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 12, 2025
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 e4dd85f and d826ac6.

📒 Files selected for processing (4)
  • src/app/fyle/add-edit-expense/add-edit-expense.page.scss (1 hunks)
  • src/app/shared/components/fy-currency/fy-currency.component.html (1 hunks)
  • src/app/shared/components/fy-currency/fy-currency.component.scss (2 hunks)
  • src/app/shared/components/fy-currency/fy-currency.component.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (5)
src/app/shared/components/fy-currency/fy-currency.component.ts (2)

43-45: Mind it! This separation of messages is a superstar move!

Breaking down the auto-code message into separate variables for currency and amount improves code clarity and maintainability. That's the style, macha!


188-189: 🧹 Nitpick (assertive)

Simplicity is the ultimate sophistication, thalaiva!

The direct message assignments are clean and effective. But let's make it even more powerful with template literals!

-    this.currencyAutoCodeMessage = isCurrencyAutoCoded ? 'Currency is auto coded.' : '';
-    this.amountAutoCodeMessage = isAmountAutoCoded ? 'Amount is auto coded.' : '';
+    this.currencyAutoCodeMessage = isCurrencyAutoCoded ? `Currency is auto coded.` : '';
+    this.amountAutoCodeMessage = isAmountAutoCoded ? `Amount is auto coded.` : '';

Likely invalid or redundant comment.

src/app/shared/components/fy-currency/fy-currency.component.scss (2)

41-41: Kabali style alignment, perfect to the pixel!

The flex-start alignment ensures proper vertical positioning of form elements. When you show style, show it like this!


54-54: Perfect balance, like perfectly balanced dosa!

The 50-50 split between currency and amount blocks creates a harmonious layout. This is what I call pixel perfect design!

Also applies to: 59-59

src/app/fyle/add-edit-expense/add-edit-expense.page.scss (1)

650-650: Error message positioning with style, like my signature walk!

The margin adjustment perfectly aligns the error message with the new layout structure. That's what I call attention to detail!

Comment on lines +3 to 32
<div class="fy-currency--input-wrapper fy-currency--currency-block">
<div class="fy-currency--input-container">
<div class="fy-currency--label">
Currency
<span class="fy-currency--mandatory"> * </span>
</div>
<input
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
</div>
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ currencyAutoCodeMessage }}
</div>
<input
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
</div>
<div class="fy-currency--input-container fy-currency--amount-block" [ngClass]="{ 'fy-currency__invalid': !valid }">
<div class="fy-currency--label">
Amount
<span class="fy-currency--mandatory"> * </span>
<div class="fy-currency--input-wrapper fy-currency--amount-block">
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }">
<div class="fy-currency--label">
Amount
<span class="fy-currency--mandatory"> * </span>
</div>
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number>
</div>
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ amountAutoCodeMessage }}
</div>
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

This HTML structure is like a well-choreographed fight scene!

The restructuring improves both visual organization and semantic meaning. But let's make it even more powerful!

Add ARIA labels for better screen reader support:

-        <input
+        <input
+          aria-label="Currency input"
           class="fy-currency--input smartlook-show"
           (click)="openCurrencyModal()"
           formControlName="currency"
           (blur)="onBlur()"
         />
📝 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
<div class="fy-currency--input-wrapper fy-currency--currency-block">
<div class="fy-currency--input-container">
<div class="fy-currency--label">
Currency
<span class="fy-currency--mandatory"> * </span>
</div>
<input
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
</div>
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ currencyAutoCodeMessage }}
</div>
<input
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
</div>
<div class="fy-currency--input-container fy-currency--amount-block" [ngClass]="{ 'fy-currency__invalid': !valid }">
<div class="fy-currency--label">
Amount
<span class="fy-currency--mandatory"> * </span>
<div class="fy-currency--input-wrapper fy-currency--amount-block">
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }">
<div class="fy-currency--label">
Amount
<span class="fy-currency--mandatory"> * </span>
</div>
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number>
</div>
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ amountAutoCodeMessage }}
</div>
<div class="fy-currency--input-wrapper fy-currency--currency-block">
<div class="fy-currency--input-container">
<div class="fy-currency--label">
Currency
<span class="fy-currency--mandatory"> * </span>
</div>
<input
aria-label="Currency input"
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
</div>
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ currencyAutoCodeMessage }}
</div>
</div>
<div class="fy-currency--input-wrapper fy-currency--amount-block">
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }">
<div class="fy-currency--label">
Amount
<span class="fy-currency--mandatory"> * </span>
</div>
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number>
</div>
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ amountAutoCodeMessage }}
</div>

@Sishhhh Sishhhh marked this pull request as draft January 12, 2025 20:53
@Sishhhh Sishhhh marked this pull request as ready for review January 12, 2025 21:08
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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d826ac6 and 5a36390.

📒 Files selected for processing (1)
  • src/app/shared/components/fy-currency/fy-currency.component.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)

Comment on lines +496 to +504
it('should set currencyAutoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(200),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Currency is auto coded.');
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

These test cases are like my signature moves - precise and powerful! But let's add some style, thalaiva!

The test cases cover all scenarios perfectly, but we can make them more maintainable by extracting the message strings into constants.

Add these constants at the top of the describe block:

 describe('FyCurrencyComponent', () => {
+  const AUTO_CODED_MESSAGES = {
+    CURRENCY: 'Currency is auto coded.',
+    AMOUNT: 'Amount is auto coded.',
+    EMPTY: ''
+  };
   let component: FyCurrencyComponent;
   // ... rest of the code

Then update the test cases to use these constants:

-    expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
+    expect(component.currencyAutoCodeMessage).toBe(AUTO_CODED_MESSAGES.CURRENCY);

Also applies to: 507-515, 518-527

Comment on lines +484 to +527
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.');
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
});

it('should set autoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => {
it('should set currencyAutoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(200),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Currency is auto coded.');
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
});

it('should set autoCodeMessage to "Amount is auto coded." when only amount is auto coded', () => {
it('should set amountAutoCodeMessage to "Amount is auto coded." when only amount is auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('EUR'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Amount is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
});

it('should set autoCodeMessage to "" when neither currency nor amount is auto coded', () => {
it('should set currencyAutoCodeMessage and amountAutoCodeMessage to "" when neither currency nor amount is auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('EUR'),
amount: new FormControl(200),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('');
expect(component.currencyAutoCodeMessage).toBe('');
expect(component.amountAutoCodeMessage).toBe('');
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 up, all you test warriors! Here's a power-packed suggestion!

We should add one more test case to verify the component's behavior when autoCodedData is null or undefined, as this is a common edge case in real-world scenarios.

Add this test case:

it('should handle null autoCodedData gracefully', () => {
  component.autoCodedData = null;
  component.fg = new FormGroup({
    currency: new FormControl('USD'),
    amount: new FormControl(100),
    homeCurrencyAmount: new FormControl(null),
  });
  component.showAutoCodeMessage();
  expect(component.currencyAutoCodeMessage).toBe('');
  expect(component.amountAutoCodeMessage).toBe('');
});

Comment on lines +484 to +493
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.');
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Mind-blowing test coverage, macha! But let's make it even more powerful!

The test case for both auto-coded fields is solid, but we can enhance it further by verifying the initial state before calling showAutoCodeMessage().

 it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
   component.autoCodedData = { currency: 'USD', amount: 100 };
   component.fg = new FormGroup({
     currency: new FormControl('USD'),
     amount: new FormControl(100),
     homeCurrencyAmount: new FormControl(null),
   });
+  expect(component.currencyAutoCodeMessage).toBe('');
+  expect(component.amountAutoCodeMessage).toBe('');
   component.showAutoCodeMessage();
   expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
   expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
 });
📝 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
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.');
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
expect(component.currencyAutoCodeMessage).toBe('');
expect(component.amountAutoCodeMessage).toBe('');
component.showAutoCodeMessage();
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
});

Copy link

Unit Test Coverage % values
Statements 95.96% ( 19291 / 20102 )
Branches 91.1% ( 10656 / 11696 )
Functions 94.24% ( 5735 / 6085 )
Lines 96% ( 18417 / 19184 )

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.

1 participant