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 297be6f8..8500df60 100644 --- a/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts +++ b/srcs/requirements/nestjs/api_back/src/friendship/friendship.controller.ts @@ -17,6 +17,10 @@ export class FriendshipController { return this.friendshipService.findAllFriends(user.id); } + // the username may change but the relationship id will not so we need to grab the relationship id from the username + // ie did that username send a friendship thing, and if so what are the ids + + // GET http://transcendance:8080/api/v2/network/myfriends/relationshipId @Get('myfriend/:relationshipId') @UseGuards(AuthenticateGuard) 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 0f567db8..977ad13e 100644 --- a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileFriends.svelte @@ -6,94 +6,65 @@ import DisplayAUser from "../../pieces/DisplayAUser.svelte"; import Tabs from "../../pieces/Tabs.svelte"; - - // Ok so i need to test all the paths Cherif has made but a major one doesn't work yet... - // in the mean time, i need to make some other stuff look nice - // what do i want? - -/* -Ideas -- a list of all users and if they're active -could be a list of friends and if they're active but i can't see that yet -- I click on a thing and it lets me see all the users and i get a button that lets me add them - - would that be like a serachable list of all users? - - am i skipping optimization? i mean for now yes, but like - - - -*/ - - - - let errors = {friendRequest: '',}; - let set = {friendUsername: '', friendId: Number} let user; let allUsers; let myFriends; let requestsMade, requestsRecieved; - let userBeingViewed; + let usernameBeingViewed; + /**** Layout variables ****/ + let tabItems: string[] = ['All Users', 'My Friends', 'Friend Requests'] + let activeTabItem: string = 'All Users'; onMount( async() => { + + // DO I ACTUALLY NEED TO ON MOUNT ALL THIS STUFF? + // ALSO I COULD JUST USE THE FUNCITONS I MADE... + + // yea no idea what // i mean do i fetch user? i will for now user = await fetch('http://transcendance:8080/api/v2/user') .then( (x) => x.json() ); - // userBeingViewed = user; - // console.log('user is ') - // console.log(user) - // console.log(user.username) - - myFriends = await fetch("http://transcendance:8080/api/v2/network/myfriends") - .then( (x) => x.json() ); - - // console.log('my friends') - // console.log(myFriends) - - requestsMade = await fetch('http://transcendance:8080/api/v2/network/pending') - .then( x => x.json() ); - - // console.log('Requests pending '); - // console.log(requestsMade); - - - requestsRecieved = await fetch('http://transcendance:8080/api/v2/network/received') - .then( x => x.json() ); - - // console.log('Requests received '); - // console.log(requestsRecieved); - - allUsers = await fetch('http://transcendance:8080/api/v2/user/all') - .then( x => x.json() ); - // console.log('got all users ' + allUsers) - + fetchMyFriends(); + fetchRequestsMade(); + fetchRequestsReceived(); + fetchAllUsers(); }); - const displayAllUsers = async() => { + const fetchAllUsers = async() => { allUsers = await fetch('http://transcendance:8080/api/v2/user/all') .then( x => x.json() ); - console.log('got all users ' + allUsers) + console.log('got all users ') + console.log({...allUsers}) }; - const displayAllFriends = async() => { + const fetchMyFriends = async() => { myFriends = await fetch('http://transcendance:8080/api/v2/network/myfriends') .then( x => x.json() ); - // console.log('got all friends ' + allFriends) + // console.log('got all friends ') + // console.log({...allFriends}) }; - // will this work? - // const displayRequestsMade = async() => { - let displayRequestsMade = async() => { + const fetchRequestsMade = async() => { requestsMade = await fetch('http://transcendance:8080/api/v2/network/pending') .then( x => x.json() ); - console.log('got requests made ' + requestsMade) + console.log('got requests made ') + console.log({...requestsMade}) + }; + + const fetchRequestsReceived = async() => { + requestsRecieved = await fetch('http://transcendance:8080/api/v2/network/received') + .then( x => x.json() ); + console.log('got requests received ') + console.log({...requestsRecieved}) }; let sentFriendRequest; @@ -122,9 +93,9 @@ could be a list of friends and if they're active but i can't see that yet } }; - const viewAUser = async(aUser) => { + const viewAUser = async(aUsername) => { console.log('Profile Friend updating userBeingViewed') - userBeingViewed = aUser; + usernameBeingViewed = aUsername; // sendUsername = userBeingViewed.username; @@ -139,6 +110,17 @@ could be a list of friends and if they're active but i can't see that yet }; + const switchTab = async(e) => { + activeTabItem = e.detail; + if (activeTabItem === 'All Users') { + await fetchAllUsers(); + } else if (activeTabItem === 'My Friends') { + await fetchMyFriends(); + } else if (activeTabItem === 'Friend Requests') { + await fetchRequestsReceived(); + } + }; + @@ -146,59 +128,60 @@ could be a list of friends and if they're active but i can't see that yet