close
Skip to content

Commit 359198b

Browse files
add tags store
Tags store and tags api service added tags are also connected to the api
1 parent 1a26296 commit 359198b

File tree

14 files changed

+103
-25
lines changed

14 files changed

+103
-25
lines changed

‎src/app/models/articles.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Organization } from "./Organisation";
2-
import { User } from "./User";
1+
import { Organization } from "./organisation";
2+
import { User } from "./user";
33

44
export interface Article {
55
type_of: string;

‎src/app/models/tags.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface Tag {
2+
id: number;
3+
name: string;
4+
bg_color_hex: string;
5+
text_color_hex: string;
6+
}

‎src/app/pages/home/articles/article-card/article-card.component.html‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</div>
1212
</div>
1313
<div class="article-body">
14-
<!-- Todo check spacing is 36px but should be 30px -->
1514
<span #ref>
1615
<ng-content></ng-content>
1716
</span>

‎src/app/pages/home/articles/services/article-api.service.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export class ArticleApiService {
1111
constructor(private http: HttpClient) {}
1212

1313
getArticles(): Observable<Article[]> {
14-
return this.http.get<Article[]>(`${environment.baseApi}articles`);
14+
return this.http.get<Article[]>(`${environment.baseApi}/articles`);
1515
}
1616
}

‎src/app/pages/home/articles/services/article.store.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { HttpErrorResponse } from '@angular/common/http';
21
import { Injectable } from '@angular/core';
32
import { ComponentStore, tapResponse } from '@ngrx/component-store';
43
import { Article } from '../../../../models/articles';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { TagsApiService } from './tags-api.service';
4+
5+
describe('TagsApiService', () => {
6+
let service: TagsApiService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(TagsApiService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { Injectable } from '@angular/core';
3+
import { Observable } from 'rxjs';
4+
import { Tag } from 'src/app/models/tags';
5+
import { environment } from 'src/environments/environment';
6+
7+
@Injectable({
8+
providedIn: 'root'
9+
})
10+
export class TagsApiService {
11+
12+
constructor(private http: HttpClient) { }
13+
14+
getTags(): Observable<Tag[]> {
15+
return this.http.get<Tag[]>(`${environment.baseApi}/tags`);
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { TagsStore } from './tags.store';
4+
5+
describe('TagsService', () => {
6+
let service: TagsStore;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(TagsStore);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});

0 commit comments

Comments
 (0)