From 139da075dab97daf13793daafeee249c43c551d5 Mon Sep 17 00:00:00 2001 From: Me Date: Fri, 23 Dec 2022 19:49:25 +0100 Subject: [PATCH] so i implemented user blocking but something about the flow in the frontend is broken now, will investigate --- .../src/friendship/friendship.controller.ts | 10 +- .../src/friendship/friendship.service.ts | 7 +- .../src/pages/profile/ProfileFriends.svelte | 314 +++++++++--------- 3 files changed, 169 insertions(+), 162 deletions(-) diff --git a/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts b/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts index bf29d3f7..50de11ed 100644 --- a/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts +++ b/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts @@ -62,18 +62,15 @@ export class FriendshipController { @Patch('myfriends/:relationshipId/accept') @UseGuards(AuthenticateGuard) @UseGuards(TwoFactorGuard) - updateAccept(@Param('relationshipId') relationshipId: string, @Req() req) - { + updateAccept(@Param('relationshipId') relationshipId: string, @Req() req) { const user : User = req.user; - console.log('accepting a friendship BBBBBBBBBBBBBBBBBBBBBBB') return this.friendshipService.acceptFriendship(relationshipId, user); } @Patch('myfriends/:relationshipId/decline') @UseGuards(AuthenticateGuard) @UseGuards(TwoFactorGuard) - updateDecline(@Param('relationshipId') relationshipId: string, @Req() req) - { + updateDecline(@Param('relationshipId') relationshipId: string, @Req() req) { const user : User = req.user; return this.friendshipService.declineFriendship(relationshipId, user); } @@ -81,8 +78,7 @@ export class FriendshipController { @Patch('myfriends/:relationshipId/block') @UseGuards(AuthenticateGuard) @UseGuards(TwoFactorGuard) - updateBlock(@Param('relationshipId') relationshipId: string, @Req() req) - { + updateBlock(@Param('relationshipId') relationshipId: string, @Req() req) { const user : User = req.user; return this.friendshipService.blockFriendship(relationshipId, user); } diff --git a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts index 79ea0eea..fdac2c9a 100644 --- a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts +++ b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts @@ -71,7 +71,6 @@ export class FriendshipService { return friendship; } - // ERIC: test this async findAllFriends(username: string) { const friendship = await this.friendshipRepository .createQueryBuilder('friendship') @@ -80,8 +79,8 @@ export class FriendshipService { .orWhere('friendship.senderUsername = :requester', { requester: username }) .andWhere('friendship.status = :status', { status: FriendshipStatus.ACCEPTED }) .getMany(); - for (const friend of friendship) - console.log("FRIENDSHIP : " + friend.status); + // for (const friend of friendship) + // console.log("FRIENDSHIP : " + friend.status); return friendship; } @@ -204,7 +203,7 @@ export class FriendshipService { } async blockFriendship(relationshipId: string, user: User) { - const relation = await this.friendshipRepository.find({where: {id: +relationshipId }, relations: ['sender', 'receiver']} ); + let relation = await this.friendshipRepository.find({where: {id: +relationshipId }, relations: ['sender', 'receiver']} ); if (!relation[0]) throw new HttpException(`The requested relationship not found.`, HttpStatus.NOT_FOUND); if (relation[0].sender.id === user.id) { diff --git a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte index 996fb9d8..80659127 100644 --- a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte @@ -1,7 +1,7 @@ @@ -210,6 +229,7 @@ + @@ -376,6 +381,13 @@ text-align: center; } + div.tip{ + color: darkgray; + font-size: 0.8em; + font-weight: bold; + } + + .error{ font-size: 0.8em; font-weight: bold;