diff --git a/src/app/components/contact-form/contact-form.html b/src/app/components/contact-form/contact-form.html
index 42c2ada..4aaca9c 100644
--- a/src/app/components/contact-form/contact-form.html
+++ b/src/app/components/contact-form/contact-form.html
@@ -3,19 +3,19 @@
{
let languageManager: jasmine.SpyObj;
beforeEach(async () => {
- languageManager = jasmine.createSpyObj(LanguageManager.name, [], { strings: strings.en });
+ languageManager = jasmine.createSpyObj(LanguageManager.name, [], {
+ strings: strings.en,
+ selectedLanguage$: () => 'en',
+ });
await TestBed.configureTestingModule({
imports: [ContactForm],
diff --git a/src/app/components/form-field/form-field.html b/src/app/components/form-field/form-field.html
index 5b4370e..6478cef 100644
--- a/src/app/components/form-field/form-field.html
+++ b/src/app/components/form-field/form-field.html
@@ -12,7 +12,7 @@
@for(error of errorsDictionary()|keyvalue; track error.key) {
@if(control.hasError(error.key) && isDirty){
-
• {{error.value}}
+
• {{error.value|upperfirst}}
}
}
diff --git a/src/app/components/form-field/form-field.ts b/src/app/components/form-field/form-field.ts
index 969457d..e57f6f7 100644
--- a/src/app/components/form-field/form-field.ts
+++ b/src/app/components/form-field/form-field.ts
@@ -1,10 +1,11 @@
import { KeyValuePipe } from '@angular/common';
import { Component, computed, input, Optional, Self, signal } from '@angular/core';
import { ControlValueAccessor, NgControl, ReactiveFormsModule } from '@angular/forms';
+import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
@Component({
selector: 'app-form-field',
- imports: [ReactiveFormsModule, KeyValuePipe],
+ imports: [ReactiveFormsModule, KeyValuePipe, UpperfirstPipe],
templateUrl: './form-field.html',
styleUrl: './form-field.scss',
})
diff --git a/src/app/errors-dictionaries/name-and-company-field.ts b/src/app/errors-dictionaries/name-and-company-field.ts
index ce4da5c..8d04095 100644
--- a/src/app/errors-dictionaries/name-and-company-field.ts
+++ b/src/app/errors-dictionaries/name-and-company-field.ts
@@ -1,18 +1,17 @@
-import { inject } from '@angular/core';
+import { computed, inject, Signal, signal } from '@angular/core';
import { Dictionary } from '../interfaces/dictionary.interface';
import { LanguageManager } from '../services/language-manager';
export class NameAndCompanyFieldsErrorsDictionary implements Dictionary {
private readonly languageManager = inject(LanguageManager);
- private readonly maxlen: string;
- private readonly required = this.languageManager.strings.errorMessageRequired;
- constructor() {
- this.maxlen = this.languageManager.strings.errorMessageMaxLength(120);
- }
-
- getDictionary(): { [key: string]: string } {
- const { maxlen, required } = this;
- return { maxlen, required };
+ getDictionary(): Signal<{ [key: string]: string }> {
+ return computed(
+ () =>
+ this.languageManager.selectedLanguage$() && {
+ maxlen: this.languageManager.strings.errorMessageMaxLength(120),
+ required: this.languageManager.strings.errorMessageRequired,
+ }
+ );
}
}
diff --git a/src/app/errors-dictionaries/phone-field.ts b/src/app/errors-dictionaries/phone-field.ts
index b283f22..88efa10 100644
--- a/src/app/errors-dictionaries/phone-field.ts
+++ b/src/app/errors-dictionaries/phone-field.ts
@@ -1,14 +1,17 @@
-import { inject } from '@angular/core';
+import { computed, inject, Signal } from '@angular/core';
import { Dictionary } from '../interfaces/dictionary.interface';
import { LanguageManager } from '../services/language-manager';
export class PhoneFieldErroresDictionary implements Dictionary {
languageManager = inject(LanguageManager);
- pattern = this.languageManager.strings.errorMessagePhonePattern;
- required = this.languageManager.strings.errorMessageRequired;
- getDictionary(): { [key: string]: string } {
- const { required, pattern } = this;
- return { required, pattern };
+ getDictionary(): Signal<{ [key: string]: string }> {
+ return computed(
+ () =>
+ this.languageManager.selectedLanguage$() && {
+ pattern: this.languageManager.strings.errorMessagePhonePattern,
+ required: this.languageManager.strings.errorMessageRequired,
+ }
+ );
}
}
diff --git a/src/app/interfaces/dictionary.interface.ts b/src/app/interfaces/dictionary.interface.ts
index de4b5b5..14ec5ed 100644
--- a/src/app/interfaces/dictionary.interface.ts
+++ b/src/app/interfaces/dictionary.interface.ts
@@ -1,3 +1,5 @@
+import { Signal } from '@angular/core';
+
export interface Dictionary {
- getDictionary(): { [key: string]: string };
+ getDictionary(): Signal<{ [key: string]: string }>;
}
diff --git a/src/app/pages/edit/edit.spec.ts b/src/app/pages/edit/edit.spec.ts
index 198c0b2..c067e97 100644
--- a/src/app/pages/edit/edit.spec.ts
+++ b/src/app/pages/edit/edit.spec.ts
@@ -26,7 +26,10 @@ describe('Edit', () => {
data: of({ contact: CONTACT_MOCK }),
});
contactService = jasmine.createSpyObj(ContactService.name, ['update']);
- languageManager = jasmine.createSpyObj(LanguageManager.name, [], { strings: strings.en });
+ languageManager = jasmine.createSpyObj(LanguageManager.name, [], {
+ strings: strings.en,
+ selectedLanguage$: () => 'en',
+ });
router = jasmine.createSpyObj(Router.name, ['navigate']);
await TestBed.configureTestingModule({
diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts
index 3ef919a..ffec01f 100644
--- a/src/environments/environment.development.ts
+++ b/src/environments/environment.development.ts
@@ -1,4 +1,4 @@
export const environment = {
prod: false,
- apiUrl: 'http://192.168.1.3:4444',
+ apiUrl: 'http://192.168.1.3:8080',
};