From 9b99d4af19ecab26f74fca32b3f16833ae4795e1 Mon Sep 17 00:00:00 2001 From: Jordi <55429631+jorbush@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:03:24 +0200 Subject: [PATCH] fix lint --- .../src/app/components/home/home.component.ts | 21 +++++++++++++++---- .../post-detail/post-detail.component.spec.ts | 2 +- .../post-detail/post-detail.component.ts | 2 +- .../post-form/post-form.component.ts | 6 ++---- .../post-update/post-update.component.spec.ts | 2 +- .../src/app/models/login-response.ts | 4 ++++ .../src/app/models/post.model.ts | 1 - .../src/app/models/register-response.ts | 3 +++ .../src/app/services/auth.service.ts | 11 ++-------- 9 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 postrify-frontend/src/app/models/login-response.ts create mode 100644 postrify-frontend/src/app/models/register-response.ts diff --git a/postrify-frontend/src/app/components/home/home.component.ts b/postrify-frontend/src/app/components/home/home.component.ts index 3ee305a..6012d3e 100644 --- a/postrify-frontend/src/app/components/home/home.component.ts +++ b/postrify-frontend/src/app/components/home/home.component.ts @@ -12,8 +12,15 @@ import { CommonModule } from '@angular/common'; template: `
- @for (post of posts; track $index) { -
+ @for (post of posts; track post.id) { +

{{ post.title }}

{{ post.content | slice: 0 : 100 @@ -27,7 +34,13 @@ import { CommonModule } from '@angular/common'; }

@if (isLogged) { - + }
`, @@ -87,7 +100,7 @@ import { CommonModule } from '@angular/common'; }) export class HomeComponent implements OnInit { posts: PostResponseDTO[] = []; - isLogged: boolean = false; + isLogged = false; constructor( private postService: PostService, diff --git a/postrify-frontend/src/app/components/post-detail/post-detail.component.spec.ts b/postrify-frontend/src/app/components/post-detail/post-detail.component.spec.ts index bc93d30..9fc490a 100644 --- a/postrify-frontend/src/app/components/post-detail/post-detail.component.spec.ts +++ b/postrify-frontend/src/app/components/post-detail/post-detail.component.spec.ts @@ -14,7 +14,7 @@ describe('PostDetailComponent', () => { mockActivatedRoute = { snapshot: { paramMap: { - get: (key: string) => '1', + get: () => '1', }, }, }; diff --git a/postrify-frontend/src/app/components/post-detail/post-detail.component.ts b/postrify-frontend/src/app/components/post-detail/post-detail.component.ts index 78de324..34c42af 100644 --- a/postrify-frontend/src/app/components/post-detail/post-detail.component.ts +++ b/postrify-frontend/src/app/components/post-detail/post-detail.component.ts @@ -211,7 +211,7 @@ import { CommonModule } from '@angular/common'; }) export class PostDetailComponent implements OnInit { post?: PostResponseDTO; - isLogged: boolean = false; + isLogged = false; username?: string; constructor( diff --git a/postrify-frontend/src/app/components/post-form/post-form.component.ts b/postrify-frontend/src/app/components/post-form/post-form.component.ts index 8e303f3..f47cbf3 100644 --- a/postrify-frontend/src/app/components/post-form/post-form.component.ts +++ b/postrify-frontend/src/app/components/post-form/post-form.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { Post } from '../../models/post.model'; import { Router } from '@angular/router'; import { PostService } from '../../services/post.service'; @@ -143,7 +143,7 @@ import { ToastService } from '../../services/toast.service'; } `, }) -export class PostFormComponent implements OnInit { +export class PostFormComponent { post: Post = { title: '', content: '', @@ -155,8 +155,6 @@ export class PostFormComponent implements OnInit { private router: Router, ) {} - ngOnInit(): void {} - onSubmit(): void { this.postService.createPost(this.post).subscribe({ next: (data) => { diff --git a/postrify-frontend/src/app/components/post-update/post-update.component.spec.ts b/postrify-frontend/src/app/components/post-update/post-update.component.spec.ts index 6c32f61..be97ab6 100644 --- a/postrify-frontend/src/app/components/post-update/post-update.component.spec.ts +++ b/postrify-frontend/src/app/components/post-update/post-update.component.spec.ts @@ -14,7 +14,7 @@ describe('PostUpdateComponent', () => { mockActivatedRoute = { snapshot: { paramMap: { - get: (key: string) => '1', + get: () => '1', }, }, }; diff --git a/postrify-frontend/src/app/models/login-response.ts b/postrify-frontend/src/app/models/login-response.ts new file mode 100644 index 0000000..22500eb --- /dev/null +++ b/postrify-frontend/src/app/models/login-response.ts @@ -0,0 +1,4 @@ +export interface LoginResponse { + token: string; + username: string; +} diff --git a/postrify-frontend/src/app/models/post.model.ts b/postrify-frontend/src/app/models/post.model.ts index 99cc466..7a112ac 100644 --- a/postrify-frontend/src/app/models/post.model.ts +++ b/postrify-frontend/src/app/models/post.model.ts @@ -2,7 +2,6 @@ export interface Post { id?: number; title: string; content: string; - user?: any; createdAt?: string; updatedAt?: string; } diff --git a/postrify-frontend/src/app/models/register-response.ts b/postrify-frontend/src/app/models/register-response.ts new file mode 100644 index 0000000..3a1a89a --- /dev/null +++ b/postrify-frontend/src/app/models/register-response.ts @@ -0,0 +1,3 @@ +export interface RegisterResponse { + message: string; +} diff --git a/postrify-frontend/src/app/services/auth.service.ts b/postrify-frontend/src/app/services/auth.service.ts index d89cb30..4865400 100644 --- a/postrify-frontend/src/app/services/auth.service.ts +++ b/postrify-frontend/src/app/services/auth.service.ts @@ -2,15 +2,8 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, tap } from 'rxjs'; import { environment } from '../../environments/environment'; - -interface RegisterResponse { - message: string; -} - -interface LoginResponse { - token: string; - username: string; -} +import { LoginResponse } from '../models/login-response'; +import { RegisterResponse } from '../models/register-response'; @Injectable({ providedIn: 'root',