[986] Added component showing all offers that user joined#1077
[986] Added component showing all offers that user joined#1077jacekkalbarczyk wants to merge 53 commits intoCodeForPoznan:masterfrom
Conversation
e remote-tracking branch 'upstream/master' # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit. aborts # the commit.
| <h3 class="card-header">Aktywność</h3> | ||
| <div class="card-body"> | ||
| <p class="card-text">Zgłoś się w jednej z dostępnych ofert wolontariatu i zapełnij to miejsce.</p> | ||
| <!-- <p class="card-text">Zgłoś się w jednej z dostępnych ofert wolontariatu i zapełnij to miejsce.</p> --> |
There was a problem hiding this comment.
Don't leave commented code behind.
|
|
||
| import { AuthService } from '../auth.service'; | ||
| import { Organization } from '../organization/organization.model'; | ||
| import { OffersBoxComponent } from '../offers/offers-box/offers-box.component'; |
|
|
||
| ngOnInit() { | ||
| this.offersService.getUserOffers() | ||
| .subscribe(offers => this.offers = offers); |
There was a problem hiding this comment.
instead of subsribe here use async pipe in tempalate
| @Component({ | ||
| selector: 'volontulo-offers-box', | ||
| templateUrl: './offers-box.component.html', | ||
| styleUrls: ['./offers-box.component.scss'], |
magul
left a comment
There was a problem hiding this comment.
One minor problem with multiple subscription to observable to be resolved.
| @@ -0,0 +1,11 @@ | |||
| <div *ngIf="(offers$ | async)?.length==0; else offersExist"> | |||
There was a problem hiding this comment.
This approach has a few flaws, the first and most obvious is being potentially exposed to multiple, unwanted, subscriptions (previously mentioned up top) that initiate requests.
See how to handle that here: https://toddmotto.com/angular-ngif-async-pipe
There was a problem hiding this comment.
You can even change order here and render list from ngIf and in else block show info, that no offers were yet joined.
| }) | ||
| export class OffersBoxComponent implements OnInit { | ||
| public offers$: Observable<Offer[]>; | ||
| constructor(private offersService: OffersService) { |
There was a problem hiding this comment.
I would add one blank line between class attributes and constructror
Also prefer (if method body is empty) to format it like that:
constructor(private offersService: OffersService) { }
|
You also have Travis build failing: https://travis-ci.org/CodeForPoznan/volontulo/builds/437120822#L1085 |
Codecov Report
@@ Coverage Diff @@
## master #1077 +/- ##
=========================================
+ Coverage 91.49% 91.5% +0.01%
=========================================
Files 119 121 +2
Lines 2904 2921 +17
Branches 32 32
=========================================
+ Hits 2657 2673 +16
- Misses 243 244 +1
Partials 4 4
Continue to review full report at Codecov.
|
For now, accessible only via '/me-working-path' endpoint.