Skip to content

Commit

Permalink
admin comment functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieLukaniuk committed Nov 16, 2022
1 parent f5f951d commit 70ad6ca
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
21 changes: 21 additions & 0 deletions src/app/admin/services/admin.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

export interface AdminComment {
recipyId: string;
text: string;
}

@Injectable({
providedIn: 'root',
})
export class AdminService {
url = `https://cookster-12ac8-default-rtdb.firebaseio.com/admin`;

constructor(private http: HttpClient) {}

addAdminComment(comment: AdminComment): Observable<any> {
return this.http.post<any>(`${this.url}.json`, comment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,16 @@ <h4>{{ item.key }}</h4>
<div class="photo-container" *ngIf="_clonedRecipy.photo">
<app-image [imagePath]="_clonedRecipy.photo"></app-image>
</div>
<div *ngIf="isUserAdmin">
<div *ngIf="isUserAdmin" class="margin-block-medium">
<mat-checkbox
[ngModel]="recipy.isCheckedAndApproved"
(ngModelChange)="onisCheckedAndApprovedClicked()"
>Рецепт перевірений на практиці</mat-checkbox>
</div>
<div *ngIf="isUserAdmin" class="margin-block-medium">
<button mat-flat-button
class="action-button" (click)="onAddAdminComment()">Додати коментар</button>
</div>
</div>
<button
mat-flat-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@

.mobile-details-wrapper {
padding: 10px;
& > div:last-of-type {
margin-bottom: 30px;
}
}

.add-ingredient-button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AdminService } from './../../../admin/services/admin.service';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { DatePipe, Location } from '@angular/common';
import {
Expand Down Expand Up @@ -86,7 +87,8 @@ export class RecipyPreviewComponent implements OnInit, OnDestroy, OnChanges {
private calendarService: CalendarService,
private location: Location,
private router: Router,
private route: ActivatedRoute
private route: ActivatedRoute,
private adminService: AdminService
) {
this.isPreviousRoute$ = this.store.pipe(
select(getPreviousRoute),
Expand Down Expand Up @@ -562,4 +564,14 @@ export class RecipyPreviewComponent implements OnInit, OnDestroy, OnChanges {
} as Recipy;
this.store.dispatch(new fromRecipiesActions.UpdateRecipyAction(updatedRecipy));
}

onAddAdminComment(){
this.dialogsService.openTextInputDialog('Коментар:').pipe(take(1)).subscribe(res => {
if(res && 'id' in this.recipy){
this.adminService.addAdminComment({recipyId: this.recipy.id, text: res}).pipe(take(1)).subscribe(res => {
console.log('comment added')
})
}
})
}
}
7 changes: 5 additions & 2 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ button.mat-menu-item {
justify-content: space-between;
width: 100%;
align-items: center;

}

.ingredient-name {
Expand Down Expand Up @@ -449,7 +448,7 @@ button.mat-menu-item {
height: 80vh;
}

.page-container{
.page-container {
padding-top: 9vh;
}
}
Expand Down Expand Up @@ -477,3 +476,7 @@ button.mat-menu-item {
font-weight: 500 !important;
}
}

.margin-block-medium {
margin-block: 20px;
}

0 comments on commit 70ad6ca

Please sign in to comment.