-
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.
1. Changed tosty notification timeout
2. added method to submit review 3. Added componant & rating plugin 4. Added routes for review 5. Added tosty for favorite product
- Loading branch information
1 parent
474656f
commit 270c1c4
Showing
12 changed files
with
184 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
"@ngrx/effects": "^6.0.1", | ||
"@ngrx/router-store": "^6.0.1", | ||
"@ngrx/store": "^6.0.1", | ||
"@ngx-lite/input-star-rating": "^0.1.5", | ||
"@ngx-progressbar/core": "^5.0.1", | ||
"@ngx-progressbar/http": "^5.0.1", | ||
"bootstrap": "^4.1.1", | ||
|
@@ -89,4 +90,4 @@ | |
"main": "index.js", | ||
"repository": "[email protected]:aviabird/angularspree.git", | ||
"author": "Pankaj Rawat <[email protected]>" | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...t/components/product-detail-page/write-product-review/write-product-review.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,31 @@ | ||
<br> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8" *ngIf="!showThanks"> | ||
<h3>Write Review</h3> | ||
<form [formGroup]="reviewForm" (ngSubmit)="onSubmit()" data-toggle="validator"> | ||
<div class="form-group"> | ||
<label for="exampleInputEmail1">Rate this product</label> | ||
<ngx-input-star-rating formControlName="rating" class="form-control" required></ngx-input-star-rating> | ||
</div> | ||
<div class="form-group"> | ||
<label for="exampleInputEmail1">Title</label> | ||
<input type="text" class="form-control" aria-describedby="emailHelp" placeholder="Headline for your review" formControlName="title" | ||
required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="exampleFormControlTextarea1">Content</label> | ||
<textarea class="form-control" rows="3" placeholder="Your review" formControlName="review" required></textarea> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Submit Review</button> | ||
</form> | ||
</div> | ||
<div class="col-md-8" *ngIf="showThanks"> | ||
<h3>Thanks for your review!</h3> | ||
<i class="fa fa-check-circle fa-3x"></i> | ||
<p>Your review has been submitted.Please note that your review may take up to 48 hours to appear.</p> | ||
<button type="normal" class="btn btn-primary" (click)="goToProduct()">Continew Shopping</button> | ||
</div> | ||
</div> | ||
</div> | ||
<br> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...omponents/product-detail-page/write-product-review/write-product-review.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 { WriteProductReviewComponent } from './write-product-review.component'; | ||
|
||
describe('WriteProductReviewComponent', () => { | ||
let component: WriteProductReviewComponent; | ||
let fixture: ComponentFixture<WriteProductReviewComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ WriteProductReviewComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WriteProductReviewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
...uct/components/product-detail-page/write-product-review/write-product-review.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,73 @@ | ||
import { ToastrService } from 'ngx-toastr'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { ProductService } from './../../../../core/services/product.service'; | ||
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-write-product-review', | ||
templateUrl: './write-product-review.component.html', | ||
styleUrls: ['./write-product-review.component.scss'] | ||
}) | ||
export class WriteProductReviewComponent implements OnInit { | ||
|
||
reviewForm: FormGroup; | ||
queryParams: any | ||
showThanks = false | ||
constructor(private fb: FormBuilder, | ||
private productService: ProductService, | ||
private activeRoute: ActivatedRoute, | ||
private toastrService: ToastrService, | ||
private router: Router) { | ||
this.activeRoute.queryParams | ||
.subscribe(params => { | ||
this.queryParams = params | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
this.initForm(); | ||
} | ||
|
||
initForm() { | ||
const rating = ''; | ||
const name = ''; | ||
const title = ''; | ||
const review = ''; | ||
|
||
this.reviewForm = this.fb.group({ | ||
rating: [rating, Validators.required], | ||
name: [JSON.parse(localStorage.getItem('user')).email], | ||
title: [title, Validators.required], | ||
review: [review, Validators.required] | ||
} | ||
); | ||
} | ||
|
||
parse(formData) { | ||
return { | ||
review: { | ||
rating: formData.rating.toString(), | ||
name: formData.name, | ||
title: formData.title, | ||
review: formData.review | ||
} | ||
} | ||
} | ||
|
||
onSubmit() { | ||
if (this.reviewForm.valid) { | ||
const values = this.reviewForm.value; | ||
const params = this.parse(values) | ||
this.productService.submitReview(this.queryParams.prodId, params) | ||
.subscribe((res) => { | ||
this.showThanks = true | ||
}) | ||
} else { | ||
this.toastrService.error('Enter data in all fields', 'Error!') | ||
} | ||
} | ||
goToProduct() { | ||
this.router.navigate([this.queryParams.prodId]) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { WriteProductReviewComponent } from './components/product-detail-page/write-product-review/write-product-review.component'; | ||
import { Routes } from '@angular/router'; | ||
import { ProductDetailPageComponent } from './components/product-detail-page/product-detail-page.component'; | ||
import { ProductComponent } from './product.component'; | ||
|
||
export const ProductRoutes: Routes = [ | ||
{ path: '', component: ProductComponent, pathMatch: 'full' }, | ||
{ path: ':id', component: ProductDetailPageComponent } | ||
{ path: ':id', component: ProductDetailPageComponent }, | ||
{ path: ':id/write_review', component: WriteProductReviewComponent } | ||
]; | ||
|
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