diff --git a/src/app/components/feed/postlist/postlist.component.ts b/src/app/components/feed/postlist/postlist.component.ts
index 353089f..8d5acfd 100644
--- a/src/app/components/feed/postlist/postlist.component.ts
+++ b/src/app/components/feed/postlist/postlist.component.ts
@@ -2,7 +2,6 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Post } from 'src/app/models/post';
import { FeedService } from 'src/app/services/feed/feed.service';
import { Router } from '@angular/router';
-import { User } from 'src/app/models/user';
@Component({
selector: 'feed-postlist',
diff --git a/src/app/components/search/search.component.html b/src/app/components/search/search.component.html
index 1a517d6..c9dc522 100644
--- a/src/app/components/search/search.component.html
+++ b/src/app/components/search/search.component.html
@@ -25,13 +25,15 @@
{{friend.name}}
-->
+ [class.selected]="user === selectedUser"
+ tabindex="0">
-
- {{user.username}}
- {{user.handle}}
+
+ {{user.username}}
+ {{user.handle}}
+
+
+
diff --git a/src/app/components/search/search.component.sass b/src/app/components/search/search.component.sass
index 779df4f..8b866e0 100644
--- a/src/app/components/search/search.component.sass
+++ b/src/app/components/search/search.component.sass
@@ -19,11 +19,22 @@
box-sizing: border-box
width: 100%
margin-top: 0.5em
- cursor: pointer
.mat-card-subtitle
margin: 0
+ .request-button
+ margin-top: 0.5em
+ margin-bottom: 0.5em
.profile-picture
background-image: url(https://material.angular.io/assets/img/examples/shiba1.jpg)
- background-size: cover
\ No newline at end of file
+ background-size: cover
+.profile-picture:hover
+ cursor: pointer
+
+.pointer:hover
+ cursor: pointer
+
+.icon-box
+ text-align: right
+ width: 100%
\ No newline at end of file
diff --git a/src/app/components/search/search.component.ts b/src/app/components/search/search.component.ts
index b1f83ff..641916e 100644
--- a/src/app/components/search/search.component.ts
+++ b/src/app/components/search/search.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit} from '@angular/core';
import { SearchService } from 'src/app/services/search/search.service';
+import { RequestService } from 'src/app/services/request/request.service';
import {Headers, Http} from '@angular/http';
import { User } from 'src/app/models/user';
import {environment} from 'src/environments/environment';
@@ -15,7 +16,11 @@ export class SearchComponent implements OnInit {
category = 'user';
foundUsers: Array;
- constructor(private searchService: SearchService, private http: Http, private router: Router) { }
+ constructor(
+ private searchService: SearchService,
+ private requestService: RequestService,
+ private http: Http,
+ private router: Router) { }
ngOnInit() {
}
@@ -49,8 +54,17 @@ export class SearchComponent implements OnInit {
}
public showUserProfile(user: User) {
- console.log(user);
this.router.navigate(['profile/' + user.userID]);
}
+
+ public sendFriendRequest(user: User) {
+ const headers = new Headers();
+ headers.set('Content-Type', 'application/json');
+ this.http.post(environment.graphQLUrl, this.requestService.buildJsonRequest(user.userID, 'FRIENDREQUEST'))
+ .subscribe(response => {
+ console.log('response received');
+ console.log(response);
+ });
+ }
}
diff --git a/src/app/services/request/request.service.spec.ts b/src/app/services/request/request.service.spec.ts
new file mode 100644
index 0000000..2b8616a
--- /dev/null
+++ b/src/app/services/request/request.service.spec.ts
@@ -0,0 +1,12 @@
+import { TestBed } from '@angular/core/testing';
+
+import { RequestService } from './request.service';
+
+describe('RequestService', () => {
+ beforeEach(() => TestBed.configureTestingModule({}));
+
+ it('should be created', () => {
+ const service: RequestService = TestBed.get(RequestService);
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/request/request.service.ts b/src/app/services/request/request.service.ts
new file mode 100644
index 0000000..ee996b5
--- /dev/null
+++ b/src/app/services/request/request.service.ts
@@ -0,0 +1,30 @@
+import {Injectable} from '@angular/core';
+import {Headers, Http} from '@angular/http';
+import {DatasharingService} from '../datasharing.service';
+import {Router} from '@angular/router';
+import {environment} from 'src/environments/environment';
+
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RequestService {
+
+ constructor(private http: Http, private data: DatasharingService, private router: Router) {
+ }
+
+ public buildJsonRequest(id_: number, type_: String): any {
+ const body = {
+ query: `mutation($id: ID!, $type: RequestType) {
+ sendRequest(receiver: $id, type: $type) {
+ id
+ }
+ }`
+ , variables: {
+ id: id_,
+ type: type_
+ }
+ };
+ return body;
+ }
+}