Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbush committed Sep 30, 2024
1 parent 358385f commit 9b99d4a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
21 changes: 17 additions & 4 deletions postrify-frontend/src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import { CommonModule } from '@angular/common';
template: `
<div class="home-container">
<div class="posts-grid">
@for (post of posts; track $index) {
<div class="post-card" (click)="viewPost(post.id)">
@for (post of posts; track post.id) {
<div
class="post-card"
(click)="viewPost(post.id)"
role="button"
tabindex="0"
(keyup.enter)="viewPost(post.id)"
(keyup.space)="viewPost(post.id)"
>
<h3>{{ post.title }}</h3>
<p>
{{ post.content | slice: 0 : 100
Expand All @@ -27,7 +34,13 @@ import { CommonModule } from '@angular/common';
}
</div>
@if (isLogged) {
<button class="floating-button" (click)="createPost()">+</button>
<button
class="floating-button"
(click)="createPost()"
aria-label="Create new post"
>
+
</button>
}
</div>
`,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('PostDetailComponent', () => {
mockActivatedRoute = {
snapshot: {
paramMap: {
get: (key: string) => '1',
get: () => '1',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ import { CommonModule } from '@angular/common';
})
export class PostDetailComponent implements OnInit {
post?: PostResponseDTO;
isLogged: boolean = false;
isLogged = false;
username?: string;

constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -143,7 +143,7 @@ import { ToastService } from '../../services/toast.service';
}
`,
})
export class PostFormComponent implements OnInit {
export class PostFormComponent {
post: Post = {
title: '',
content: '',
Expand All @@ -155,8 +155,6 @@ export class PostFormComponent implements OnInit {
private router: Router,
) {}

ngOnInit(): void {}

onSubmit(): void {
this.postService.createPost(this.post).subscribe({
next: (data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('PostUpdateComponent', () => {
mockActivatedRoute = {
snapshot: {
paramMap: {
get: (key: string) => '1',
get: () => '1',
},
},
};
Expand Down
4 changes: 4 additions & 0 deletions postrify-frontend/src/app/models/login-response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface LoginResponse {
token: string;
username: string;
}
1 change: 0 additions & 1 deletion postrify-frontend/src/app/models/post.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export interface Post {
id?: number;
title: string;
content: string;
user?: any;
createdAt?: string;
updatedAt?: string;
}
3 changes: 3 additions & 0 deletions postrify-frontend/src/app/models/register-response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface RegisterResponse {
message: string;
}
11 changes: 2 additions & 9 deletions postrify-frontend/src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9b99d4a

Please sign in to comment.