diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 53755f5c..33c728fc 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -25,6 +25,7 @@ import { HomepageOfferComponent } from 'app/components/homepage-offer/homepage-o import { LoginComponent } from 'app/components/login/login.component'; import { MessagesComponent } from 'app/components/messages/messages.component'; import { CreateOfferComponent } from 'app/components/offers/create-offer/create-offer.component'; +import { OffersBoxComponent } from 'app/components/offers/offers-box/offers-box.component'; import { OfferDetailComponent } from 'app/components/offers/offer-detail/offer-detail.component'; import { OrganizationComponent } from 'app/components/organization/organization.component'; import { OrganizationContactComponent } from 'app/components/organization/organization-contact/organization-contact.component'; @@ -213,7 +214,8 @@ registerLocaleData(localePl); ContactComponent, FormErrorComponent, OrganizationsListComponent, - UserProfileComponent + UserProfileComponent, + OffersBoxComponent ], imports: [ BrowserModule.withServerTransition({ appId: 'volontulo' }), diff --git a/frontend/src/app/components/account/account.component.html b/frontend/src/app/components/account/account.component.html index c70e4123..9c49c1b2 100644 --- a/frontend/src/app/components/account/account.component.html +++ b/frontend/src/app/components/account/account.component.html @@ -14,7 +14,7 @@

Profil

Aktywność

-

Zgłoś się w jednej z dostępnych ofert wolontariatu i zapełnij to miejsce.

+
diff --git a/frontend/src/app/components/homepage-offer/homepage-offer.component.html b/frontend/src/app/components/homepage-offer/homepage-offer.component.html index 11c6de8a..b4624c35 100644 --- a/frontend/src/app/components/homepage-offer/homepage-offer.component.html +++ b/frontend/src/app/components/homepage-offer/homepage-offer.component.html @@ -5,7 +5,7 @@

- {{ offer.title }} + {{ offer.title }}

diff --git a/frontend/src/app/components/offers/offers-box/offers-box.component.html b/frontend/src/app/components/offers/offers-box/offers-box.component.html new file mode 100644 index 00000000..2efa9787 --- /dev/null +++ b/frontend/src/app/components/offers/offers-box/offers-box.component.html @@ -0,0 +1,13 @@ +
+
+
+
+ +
+
+
+
+ + +

Zgłoś się w jednej z dostępnych ofert wolontariatu i zapełnij to miejsce.

+
diff --git a/frontend/src/app/components/offers/offers-box/offers-box.component.spec.ts b/frontend/src/app/components/offers/offers-box/offers-box.component.spec.ts new file mode 100644 index 00000000..6c50d89f --- /dev/null +++ b/frontend/src/app/components/offers/offers-box/offers-box.component.spec.ts @@ -0,0 +1,38 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpClient } from '@angular/common/http'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; + +import { HomepageOfferComponent } from 'app/components/homepage-offer/homepage-offer.component'; +import { OffersBoxComponent } from 'app/components/offers/offers-box/offers-box.component'; +import { OffersService } from 'app/services/offers.service'; + +describe('OffersBoxComponent', () => { + let component: OffersBoxComponent; + let fixture: ComponentFixture; + let offersService: OffersService; + let httpClient: HttpClient; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [RouterTestingModule, HttpClientTestingModule], + declarations: [ + OffersBoxComponent, + HomepageOfferComponent + ], + providers: [OffersService] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OffersBoxComponent); + component = fixture.componentInstance; + offersService = TestBed.get(OffersService); + httpClient = TestBed.get(HttpClient); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/components/offers/offers-box/offers-box.component.ts b/frontend/src/app/components/offers/offers-box/offers-box.component.ts new file mode 100644 index 00000000..b88e3ed3 --- /dev/null +++ b/frontend/src/app/components/offers/offers-box/offers-box.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit } from '@angular/core'; +import { OffersService } from 'app/services/offers.service'; +import { Offer } from 'app/models/offer.model'; +import { Observable } from 'rxjs/Observable'; + +@Component({ + selector: 'volontulo-offers-box', + templateUrl: './offers-box.component.html', + providers: [OffersService] +}) +export class OffersBoxComponent implements OnInit { + public offers$: Observable; + + constructor(private offersService: OffersService) { } + + ngOnInit() { + this.offers$ = this.offersService.getUserOffers(); + } +} diff --git a/frontend/src/app/services/offers.service.ts b/frontend/src/app/services/offers.service.ts index f4e0c856..0d8f4a59 100644 --- a/frontend/src/app/services/offers.service.ts +++ b/frontend/src/app/services/offers.service.ts @@ -35,4 +35,8 @@ export class OffersService { return this.http.put(`${environment.apiRoot}/offers/${id}/`, offer); } + getUserOffers(): Observable { + return this.http.get(`${environment.apiRoot}/joined-offers/`) + .map(offers => offers.map(offer => loadDefaultImage(offer))); + } }