Skip to content

Commit

Permalink
fixed accepting friend requests after moving friends routes
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 11, 2024
1 parent cd2ea4e commit d5700af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions client/js/friends/actions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
$(document).on('click', '.accept-request', function() {
const userId = $(this).data('id');
sendFriendAction('/api/accept-friend-request/' + userId, 'Friend request accepted');
sendFriendAction('/api/friends/accept-friend-request/' + userId, 'Friend request accepted');
});

$(document).on('click', '.decline-request', function() {
const userId = $(this).data('id');
sendFriendAction('/api/decline-friend-request/' + userId, 'Friend request declined');
sendFriendAction('/api/friends/decline-friend-request/' + userId, 'Friend request declined');
});

$(document).on('click', '.unfriend', function() {
const userId = $(this).data('id');
sendFriendAction('/api/unfriend/' + userId, 'Unfriended successfully');
sendFriendAction('/api/friends/unfriend/' + userId, 'Unfriended successfully');
});

function sendFriendAction(url, successMessage) {
Expand Down
2 changes: 1 addition & 1 deletion client/js/friends/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function fetchFriendRequests() {
// console.log('Fetching friend requests');
const token = localStorage.getItem('token');
$.ajax({
url: '/api/friend-requests',
url: '/api/friends/friend-requests',
method: 'GET',
headers: {
"Authorization": `Bearer ${token}`
Expand Down
10 changes: 5 additions & 5 deletions client/js/user-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ $(document).ready(function () {
function checkFriendshipStatus(username) {
const token = localStorage.getItem("token");
$.ajax({
url: `/api/friendship-status/${username}`,
url: `/api/friends/friendship-status/${username}`,
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
Expand All @@ -257,31 +257,31 @@ $(document).ready(function () {

function sendFriendRequest(userId) {
sendAjaxRequest(
"/api/send-friend-request/" + userId,
"/api/friends/send-friend-request/" + userId,
"POST",
"Friend request sent successfully"
);
}

function acceptFriendRequest(userId) {
sendAjaxRequest(
"/api/accept-friend-request/" + userId,
"/api/friends/accept-friend-request/" + userId,
"POST",
"Friend request accepted"
);
}

function declineFriendRequest(userId) {
sendAjaxRequest(
"/api/decline-friend-request/" + userId,
"/api/friends/decline-friend-request/" + userId,
"POST",
"Friend request declined"
);
}

function unfriend(userId) {
sendAjaxRequest(
"/api/unfriend/" + userId,
"/api/friends/unfriend/" + userId,
"POST",
"Unfriended successfully"
);
Expand Down

0 comments on commit d5700af

Please sign in to comment.