-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
134 additions
and
87 deletions.
There are no files selected for viewing
28 changes: 13 additions & 15 deletions
28
src/app/components/create-post/create-post.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
<section class="create-post"> | ||
<div class="footer-grp"> | ||
<div class="content"> | ||
<div class="profile"> | ||
<img src="../../../assets/images/avatars/image-juliusomo.png" alt="User avatar"> | ||
<button class="edit-profile" aria-label="Edit profile"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="15"> | ||
<path d="M21.731 2.269a2.625 2.625 0 00-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 000-3.712zM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 00-1.32 2.214l-.8 2.685a.75.75 0 00.933.933l2.685-.8a5.25 5.25 0 002.214-1.32L19.513 8.2z" /> | ||
</svg> | ||
</button> | ||
</div> | ||
<div class="post-input"> | ||
<textarea placeholder="What's on your mind?"></textarea> | ||
<button class="create-btn" type="button"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="15"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> | ||
</svg> | ||
</button> | ||
<img id="profile-img" src="../../../assets/images/avatars/image-juliusomo.png" alt="" title="edit profile"> | ||
<div> | ||
<img src="../../../assets/images/icon-edit.svg" alt=""> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="content-grp"> | ||
<textarea name="content" id="post"></textarea> | ||
<button (click)="createPost()" title="create post"> | ||
create post | ||
</button> | ||
</div> | ||
|
||
|
||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,49 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { FireblogFacadeService } from '../../services/fireblog/fireblog-facade.service'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Subscription } from 'rxjs'; | ||
import { IUser } from '../../services/blog.interface'; // Make sure to import IUser | ||
|
||
@Component({ | ||
selector: 'app-create-post', | ||
standalone: true, | ||
imports: [], | ||
imports: [CommonModule, FormsModule], | ||
templateUrl: './create-post.component.html', | ||
styleUrl: './create-post.component.scss' | ||
}) | ||
export class CreatePostComponent { | ||
export class CreatePostComponent implements OnInit, OnDestroy { | ||
currentUser: IUser | null = null; | ||
private userSubscription: Subscription | undefined; | ||
content = ''; | ||
|
||
constructor(private blogFacade: FireblogFacadeService) {} | ||
|
||
ngOnInit() { | ||
this.userSubscription = this.blogFacade.getCurrentUser$.subscribe(user => { | ||
this.currentUser = user; | ||
console.log(user); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
if (this.userSubscription) { | ||
this.userSubscription.unsubscribe(); | ||
} | ||
} | ||
|
||
createPost() { | ||
if (this.currentUser && this.content.trim()) { | ||
this.blogFacade.createBlogPost(this.currentUser, this.content) | ||
.then(() => { | ||
console.log('Post created successfully'); | ||
this.content = ''; | ||
}) | ||
.catch(error => { | ||
console.error('Error creating post:', error); | ||
}); | ||
} else { | ||
console.error('Cannot create post: User not logged in or content is empty'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>likes works!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ section{ | |
|
||
|
||
h2{ | ||
color: $blueviolet; | ||
font-family: $titlefont | ||
} | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.