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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/fyle/add-edit-expense/add-edit-expense.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@
}

&--orig-amount-error {
margin: -68px 4px 48px 33%;
margin: -73px 4px 48px 53%;
Copy link
Contributor

Choose a reason for hiding this comment

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

why -ve value?

}

&--mandatory {
Expand Down
46 changes: 27 additions & 19 deletions src/app/shared/components/fy-currency/fy-currency.component.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
<div class="fy-currency">
<form [formGroup]="fg" class="fy-currency--form">
<div class="fy-currency--input-container fy-currency--currency-block">
<div class="fy-currency--label">
Currency
<span class="fy-currency--mandatory"> * </span>
<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">
Copy link
Contributor

Choose a reason for hiding this comment

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

use ngIF at the beginning, improves readability. Fix everywhere

<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>
Comment on lines +3 to 32
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>

<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number>
</div>
</form>
</div>
<div class="fy-currency__auto-coded" *ngIf="autoCodeMessage">
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon>
{{ autoCodeMessage }}
</div>
<ng-container *ngIf="value?.currency && value?.orig_currency">
<div class="fy-currency--exchange-rate-container" [ngClass]="{ expanded: expanded }">
<mat-icon class="fy-currency--exchange-rate-icon" svgIcon="info-circle-fill"></mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

&--form {
display: flex;
align-items: center;
align-items: flex-start;
height: 70px;
}

Expand All @@ -51,19 +51,20 @@

&--currency-block {
margin-right: 8px;
width: 30%;
width: 50%;
}

&--amount-block {
margin-left: 8px;
width: 70%;
width: 50%;
}

&__auto-coded {
display: flex;
align-items: center;
height: 12px;
font-size: 12px;
margin-top: 5px;
color: $black-light;
}

Expand Down
15 changes: 5 additions & 10 deletions src/app/shared/components/fy-currency/fy-currency.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export class FyCurrencyComponent implements ControlValueAccessor, OnInit, OnChan

@Input() autoCodedData: ParsedResponse;

autoCodeMessage = '';
currencyAutoCodeMessage = '';

amountAutoCodeMessage = '';

exchangeRate = 1;

Expand Down Expand Up @@ -183,15 +185,8 @@ export class FyCurrencyComponent implements ControlValueAccessor, OnInit, OnChan
const isCurrencyAutoCoded = currency && currency === formCurrency;
const isAmountAutoCoded = amount && amount === formAmount;

if (isCurrencyAutoCoded && isAmountAutoCoded) {
this.autoCodeMessage = 'Currency and Amount are auto coded.';
} else if (isCurrencyAutoCoded) {
this.autoCodeMessage = 'Currency is auto coded.';
} else if (isAmountAutoCoded) {
this.autoCodeMessage = 'Amount is auto coded.';
} else {
this.autoCodeMessage = '';
}
this.currencyAutoCodeMessage = isCurrencyAutoCoded ? 'Currency is auto coded.' : '';
this.amountAutoCodeMessage = isAmountAutoCoded ? 'Amount is auto coded.' : '';
}

convertInnerValueToFormValue(innerVal: CurrencyObj): CurrencyAmountFormValues {
Expand Down
Loading