Skip to content

Commit

Permalink
fix: friendRequest statusMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash7824 committed Aug 31, 2024
1 parent 584c66f commit 50edca6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/app/components/inbox/inbox.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<h2 mat-dialog-title>Modal Title</h2>
<mat-dialog-content>
<h2 mat-dialog-title>Friend List</h2>

<div class="container flex flex-row flex-wrap text-center" *ngIf="cs.getFriendRequestList.length == 0">
<p class="text-danger">No Friend Request Pending</p>
</div>
<mat-dialog-content *ngIf="cs.getFriendRequestList.length !== 0">
<div *ngFor="let friendReq of cs.getFriendRequestList" class="flex flex-column">
<h2>{{friendReq.sender | titlecase}}</h2>
<span>Sent on: {{friendReq.date | date}}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/inbox/inbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class InboxComponent {
this.apiServ.gets('social/getPendingFriendRequests').subscribe({
next: (response) => {
console.log(response);
this.cs.getFriendRequestList = response;
this.cs.getFriendRequestList = response.friendRequest;
},
error: (error) => console.error(error)
})
Expand Down
15 changes: 13 additions & 2 deletions src/app/pages/social/social.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Toast, ToastrService } from 'ngx-toastr';
import { Observable } from 'rxjs';
import { User } from 'src/app/models/User';
import { ApiService } from 'src/app/services/api.service';
Expand All @@ -12,7 +13,9 @@ import { CommonService } from 'src/app/services/common.service';
export class SocialComponent implements OnInit{

allFriends: any;
constructor(public apiServ: ApiService, public cs: CommonService){}
constructor(public apiServ: ApiService,
public cs: CommonService,
public toastr: ToastrService){}

ngOnInit(){
if(!this.cs.socialLoaded){
Expand Down Expand Up @@ -50,7 +53,15 @@ export class SocialComponent implements OnInit{
const body = { friendId: friend.user_id }
this.apiServ.posts('social/sendFriendRequest', body).subscribe({
next: (response) => {
console.log(response);
if(response.statusMsg){
this.toastr.error(response.statusMsg);
return;
}

if(response.sender_id){
this.toastr.success(`Friend Request sent successfully`);
}

},
error: (error) => console.error(error)
});
Expand Down
2 changes: 0 additions & 2 deletions src/app/services/generic-rule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@ export class GenericRuleService {
}

IsTileSafeForKing(king: string, row: number, col: number): boolean {
debugger;
let king_coordinates = this.findPiece(king);

if (king === 'K' && king_coordinates && !this.IsWhitePiece(row, col)) {
Expand Down Expand Up @@ -1147,7 +1146,6 @@ export class GenericRuleService {
toRow: number,
toCol: number
): boolean {
debugger;
if (fromRow == toRow && fromCol == toCol) return true;

if(this.IsKingUnderCheckAfterPieceMovement('K', fromRow, fromCol, toRow, toCol, this.chess_Board)){
Expand Down

0 comments on commit 50edca6

Please sign in to comment.