-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change and display an anonymous user`s email during the checkout…
… process (#1312)
- Loading branch information
Showing
20 changed files
with
191 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rms/components/formly-address-extension-form/formly-address-extension-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<formly-form [form]="form" [fields]="fields" [model]="model"></formly-form> |
53 changes: 53 additions & 0 deletions
53
.../components/formly-address-extension-form/formly-address-extension-form.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormBuilder } from '@angular/forms'; | ||
|
||
import { FormlyTestingModule } from 'ish-shared/formly/dev/testing/formly-testing.module'; | ||
|
||
import { FormlyAddressExtensionFormComponent } from './formly-address-extension-form.component'; | ||
|
||
describe('Formly Address Extension Form Component', () => { | ||
let component: FormlyAddressExtensionFormComponent; | ||
let fixture: ComponentFixture<FormlyAddressExtensionFormComponent>; | ||
let element: HTMLElement; | ||
let fb: FormBuilder; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [FormlyAddressExtensionFormComponent], | ||
imports: [FormlyTestingModule.withPresetMocks(['taxationID'])], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FormlyAddressExtensionFormComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
|
||
fb = TestBed.inject(FormBuilder); | ||
|
||
component.form = fb.group({}); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
|
||
it('should always set input field for email', () => { | ||
fixture.detectChanges(); | ||
expect(component.form.value).toContainKey('email'); | ||
}); | ||
|
||
it('should set input field for taxation-id, when businessCustomerRegistration feature is enabled', () => { | ||
component.businessCustomer = true; | ||
fixture.detectChanges(); | ||
expect(component.form.value).toContainKey('taxationID'); | ||
}); | ||
|
||
it('should not set input field for taxation-id, when businessCustomerRegistration feature is disabled', () => { | ||
component.businessCustomer = false; | ||
fixture.detectChanges(); | ||
expect(component.form.value).not.toContainKey('taxationID'); | ||
}); | ||
}); |
55 changes: 55 additions & 0 deletions
55
...forms/components/formly-address-extension-form/formly-address-extension-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; | ||
import { FormGroup } from '@angular/forms'; | ||
import { FormlyFieldConfig } from '@ngx-formly/core'; | ||
|
||
/** | ||
* Sub form with additional fields like email address and taxation id to extend the anonymous invoice address form. | ||
*/ | ||
@Component({ | ||
selector: 'ish-formly-address-extension-form', | ||
templateUrl: './formly-address-extension-form.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class FormlyAddressExtensionFormComponent implements OnInit { | ||
@Input() form: FormGroup; | ||
@Input() businessCustomer: boolean; | ||
@Input() model: Partial<{ email: string; taxationId: string }> = {}; // model with data for the update mode. | ||
|
||
fields: FormlyFieldConfig[]; | ||
|
||
ngOnInit() { | ||
this.fields = [ | ||
{ | ||
type: 'ish-fieldset-field', | ||
fieldGroup: [ | ||
{ | ||
key: 'email', | ||
type: 'ish-email-field', | ||
templateOptions: { | ||
required: true, | ||
label: 'checkout.addresses.email.label', | ||
customDescription: { | ||
key: 'account.address.email.hint', | ||
}, | ||
postWrappers: [{ wrapper: 'description', index: -1 }], | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
if (this.businessCustomer) { | ||
this.fields = [this.createTaxationIDField(), ...this.fields]; | ||
} | ||
} | ||
|
||
private createTaxationIDField(): FormlyFieldConfig { | ||
return { | ||
type: 'ish-fieldset-field', | ||
fieldGroup: [ | ||
{ | ||
type: '#taxationID', | ||
}, | ||
], | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.