-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why ? Features Email update Add/Edit shipping address Profile Password change This change addresses the need by: Now user able to see above mention features in his/her profile. User can change his/her own password, update email address & edit the shipping/delivery address if already exist or can add new one. [delivers #158933531]
- Loading branch information
1 parent
d790555
commit 1778cdd
Showing
33 changed files
with
729 additions
and
39 deletions.
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
src/app/checkout/address/add-address/add-address.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
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
19 changes: 19 additions & 0 deletions
19
src/app/shared/custom-validator/password-match-validator.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,19 @@ | ||
import { FormGroup } from '@angular/forms'; | ||
|
||
export class PasswordMatchValidator { | ||
static validate(passwordFormGroup: FormGroup) { | ||
const password = passwordFormGroup.controls.password.value; | ||
const repeatPassword = passwordFormGroup.controls.password_confirmation.value; | ||
|
||
if (repeatPassword.length <= 0) { | ||
return null; | ||
} | ||
|
||
if (repeatPassword !== password) { | ||
return { | ||
doesMatchPassword: true | ||
}; | ||
} | ||
return null; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/app/user/components/addresses/add-edit-address/add-edit-address.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,65 @@ | ||
<form class="form" [formGroup]="addressForm" (ngSubmit)="onSubmit()"> | ||
<div class="row"> | ||
<div class="form-group col-sm-6"> | ||
<label>Pin Code | ||
<span class="required">*</span> | ||
</label> | ||
<input type="tel" class="form-control" formControlName="zipcode"> | ||
<p *ngIf="addressForm.get('zipcode').hasError('required') && addressForm.get('zipcode').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="form-group col-sm-6"> | ||
<label> Locality / Town | ||
<span class="required">*</span> | ||
</label> | ||
<input type="text" class="form-control" formControlName="address2"> | ||
<p *ngIf="addressForm.get('address2').hasError('required') && addressForm.get('address2').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="form-group col-sm-6"> | ||
<label>City / District | ||
<span class="required">*</span> | ||
</label> | ||
<input type="text" class="form-control" formControlName="city"> | ||
<p *ngIf="addressForm.get('city').hasError('required') && addressForm.get('city').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="form-group col-sm-6"> | ||
<label> State </label> | ||
<select class="form-control" formControlName="state_name"> | ||
<option *ngIf="addressParams">{{addressParams.user.ship_address.state.name}} | ||
<option *ngFor="let state of states">{{state.name}}</option> | ||
</select> | ||
</div> | ||
|
||
<div class="form-group col-sm-6"> | ||
<label>First Name | ||
<span class="required">*</span> | ||
</label> | ||
<input type="text" class="form-control" formControlName="firstname"> | ||
<p *ngIf="addressForm.get('firstname').hasError('required') && addressForm.get('firstname').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="form-group col-sm-6"> | ||
<label> Last Name | ||
<span class="required">*</span> | ||
</label> | ||
<input type="text" class="form-control" formControlName="lastname"> | ||
<p *ngIf="addressForm.get('lastname').hasError('required') && addressForm.get('lastname').touched" class="value- text-danger show">This is a mandatory field</p> | ||
</div> | ||
|
||
<div class="form-group col-sm-6"> | ||
<label>Address | ||
<span class="required">*</span> | ||
</label> | ||
<textarea type="text" class="form-control" formControlName="address1"></textarea> | ||
<p *ngIf="addressForm.get('address1').hasError('required') && addressForm.get('address1').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="form-group col-sm-6"> | ||
<label>Mobile No | ||
<span class="required">*</span> | ||
</label> | ||
<input type="tel" class="form-control" formControlName="phone"> | ||
<p *ngIf="addressForm.get('phone').hasError('required') && addressForm.get('phone').touched" class="value-err text-danger show">This is a mandatory field</p> | ||
</div> | ||
<div class="save-button col-12 col-sm-6"> | ||
<button class="btn themebtnprimary">SAVE</button> | ||
</div> | ||
</div> | ||
</form> |
51 changes: 51 additions & 0 deletions
51
src/app/user/components/addresses/add-edit-address/add-edit-address.component.scss
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,51 @@ | ||
// @import './../../shared/scss/selected_theme_variables'; | ||
// .form { | ||
// .half-width { | ||
// width: 190px; | ||
// } | ||
// .full-width { | ||
// width: 400px; | ||
// } | ||
// .value-err { | ||
// height: 18px; | ||
// padding-top: 2px; | ||
// } | ||
// .readonly { | ||
// border: 1px solid $gray-10 !important; | ||
// } | ||
// } | ||
|
||
// .email { | ||
// padding-bottom: 10px; | ||
// padding-top: 15px; | ||
// label { | ||
// top: 4px; | ||
// } | ||
// } | ||
|
||
// .pincode { | ||
// padding-top: 15px; | ||
// label { | ||
// top: 4px; | ||
// } | ||
// } | ||
|
||
// .city, | ||
// .state, | ||
// .first-name, | ||
// .last-name { | ||
// display: inline-block; | ||
// vertical-align: top; | ||
// } | ||
|
||
// .state, | ||
// .last-name { | ||
// padding-left: 7px; | ||
// } | ||
|
||
// .address { | ||
// textarea { | ||
// height: 70px; | ||
// padding: 10px; | ||
// } | ||
// } |
25 changes: 25 additions & 0 deletions
25
src/app/user/components/addresses/add-edit-address/add-edit-address.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AddEditAddressComponent } from './add-edit-address.component'; | ||
|
||
describe('AddEditAddressComponent', () => { | ||
let component: AddEditAddressComponent; | ||
let fixture: ComponentFixture<AddEditAddressComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AddEditAddressComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AddEditAddressComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
83 changes: 83 additions & 0 deletions
83
src/app/user/components/addresses/add-edit-address/add-edit-address.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,83 @@ | ||
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; | ||
import { FormGroup, FormBuilder } from '@angular/forms'; | ||
import { AddressService } from '../../../../checkout/address/services/address.service'; | ||
import { ToastrService } from 'ngx-toastr'; | ||
import { UserService } from '../../../services/user.service'; | ||
|
||
@Component({ | ||
selector: 'app-add-edit-address', | ||
templateUrl: './add-edit-address.component.html', | ||
styleUrls: ['./add-edit-address.component.scss'] | ||
}) | ||
export class AddEditAddressComponent implements OnInit { | ||
addressForm: FormGroup; | ||
states: any; | ||
@Input() isEditAddrPressed: boolean; | ||
@Input() addressParams: any; | ||
@Output() isAddressEdited: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
|
||
constructor(private fb: FormBuilder, | ||
private addrService: AddressService, | ||
private toastrService: ToastrService, | ||
private userService: UserService, | ||
) { | ||
this.addressForm = addrService.initAddressForm(); | ||
|
||
this.addrService.getAllStates().subscribe(data => { | ||
this.states = data.states; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
if (this.isEditAddrPressed) { | ||
this.fillAddress(this.addressForm); | ||
} | ||
} | ||
|
||
onSubmit() { | ||
const address = this.addressForm.value; | ||
for (const state of this.states) { | ||
if (state.name === address.state_name) { | ||
address['state_id'] = state.id; | ||
address['country_id'] = state.country_id; | ||
address['state_name'] = state.name; | ||
break; | ||
} | ||
} | ||
if (this.addressForm.valid) { | ||
if (this.isEditAddrPressed) { | ||
this.addressParams.user.ship_address = address; | ||
this.userService.updateUserAddress(this.addressParams) | ||
.subscribe((res: any) => { | ||
this.navigatePage(); | ||
this.toastrService.success(res.status, 'Success!') | ||
}) | ||
|
||
} else { | ||
this.addressParams.user.ship_address = address; | ||
this.userService.createUserAddress(this.addressParams) | ||
.subscribe((res: any) => { | ||
this.navigatePage(); | ||
this.toastrService.success(res.status, 'Success!') | ||
}) | ||
} | ||
} else { | ||
this.toastrService.error('Some fields are blank!', 'Unable to save address!'); | ||
} | ||
} | ||
|
||
fillAddress(addressForm) { | ||
const existingAddress = this.addressParams.user.ship_address; | ||
addressForm.get('zipcode').setValue(existingAddress.zipcode); | ||
addressForm.get('address2').setValue(existingAddress.address2); | ||
addressForm.get('city').setValue(existingAddress.city); | ||
addressForm.get('state_name').setValue(existingAddress.state.name); | ||
addressForm.get('firstname').setValue(existingAddress.firstname); | ||
addressForm.get('lastname').setValue(existingAddress.lastname); | ||
addressForm.get('address1').setValue(existingAddress.address1); | ||
addressForm.get('phone').setValue(existingAddress.phone); | ||
} | ||
navigatePage() { | ||
this.isAddressEdited.emit(true) | ||
} | ||
} |
20 changes: 17 additions & 3 deletions
20
src/app/user/components/addresses/addresses.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 |
---|---|---|
@@ -1,3 +1,17 @@ | ||
<p> | ||
addresses works! | ||
</p> | ||
<div *ngIf="userDetails$ | async; let userDetails"> | ||
<div *ngIf="userDetails.ship_address!=null"> | ||
<span *ngIf="!isEditAddrPressed; else elseBlock" class='reviewlink pl-1' (click)="editAddress()">Edit</span> | ||
<ng-template #elseBlock> | ||
<span class='reviewlink pl-1' (click)="cancelAddressEdit()">Cancel</span> | ||
</ng-template> | ||
<app-saved-address *ngIf="!isEditAddrPressed" [userDetails]="userDetails"></app-saved-address> | ||
<div *ngIf="isEditAddrPressed"> | ||
<strong>Edit Address</strong> | ||
<app-add-edit-address [isEditAddrPressed]="isEditAddrPressed" [addressParams]="buildAddressParams(userDetails)" (isAddressEdited)="addressEditedDone($event)"></app-add-edit-address> | ||
</div> | ||
</div> | ||
<div *ngIf="userDetails?.ship_address===null"> | ||
<strong>Add Address</strong> | ||
<app-add-edit-address [isEditAddrPressed]="false" (isAddressEdited)="addressEditedDone($event)" [addressParams]="buildAddressParams(userDetails)"></app-add-edit-address> | ||
</div> | ||
</div> |
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,6 @@ | ||
.reviewlink { | ||
cursor: pointer; | ||
&:hover { | ||
text-decoration: underline | ||
} | ||
} |
Oops, something went wrong.