ok gotta test all the paths but we more or less have the friendships and users modules working the new way

This commit is contained in:
Me
2023-01-04 16:04:48 +01:00
parent 000987fbde
commit d3be6e5fe8
4 changed files with 75 additions and 22 deletions

View File

@@ -93,23 +93,28 @@
const fetchFriendshipFull = async(aUsername) => {
console.log('fetch friendship from a username')
console.log(aUsername)
friendshipStatusFull = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${aUsername}`)
friendshipStatusFull = await fetch(`http://transcendance:8080/api/v2/network/myfriends?username=${aUsername}`)
.then( x => x.json());
console.log({...friendshipStatusFull})
};
const sendFriendRequest = async(aUser) => {
const sendFriendRequest = async(aUsername) => {
console.log('sending a friend request')
console.log(aUsername)
const resp = await fetch("http://transcendance:8080/api/v2/network/relations", {
method : "POST",
headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({
"receiverUsername": aUser.username,
"receiverUsername": aUsername,
"status": "R"
})
})
.then( x => x.json())
fetchFriendshipFull(aUser.username);
// .catch( x => console.log({...x}))
// "status": "A"
console.log({...resp})
fetchFriendshipFull(aUsername);
};
const viewAUser = async(aUsername) => {
@@ -335,6 +340,7 @@
<Button type="secondary" on:click={() => sendFriendRequest(usernameBeingViewed)}>Add Friend</Button>
<Button on:click={() => blockANonFriendUser(usernameBeingViewed)}>Block User</Button>
{/if}
<Button type="secondary" on:click={() => sendFriendRequest(usernameBeingViewed)}>Add Friend</Button>
</div>
{:else}
<div class="placeholder">