diff --git a/src/api/client.ts b/src/api/client.ts index c9839b2..af5a4c1 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -25,10 +25,22 @@ export async function apiFetch( throw new Error("Session expired") } + // Handle error responses if (!res.ok) { const text = await res.text() throw new Error(text || res.statusText) } - return res.json() as Promise + // Get the response as text first + const responseText = await res.text() + + if (!responseText) { + return {} as T + } + + try { + return JSON.parse(responseText) as T + } catch (e) { + return responseText as unknown as T + } } diff --git a/src/api/friends.ts b/src/api/friends.ts index 7d2f446..2cace51 100644 --- a/src/api/friends.ts +++ b/src/api/friends.ts @@ -22,3 +22,10 @@ export function acceptFriendRequest(senderUuid: string) { body: JSON.stringify({ sender_uuid: senderUuid }), }) } + +export function declineFriendRequest(senderUuid: string) { + return apiFetch('/friends/decline', { + method: 'POST', + body: JSON.stringify({ sender_uuid: senderUuid }), + }) +} diff --git a/src/api/rooms.ts b/src/api/rooms.ts index c26149d..6d8abe3 100644 --- a/src/api/rooms.ts +++ b/src/api/rooms.ts @@ -33,3 +33,10 @@ export function acceptRoomInvite(senderUuid: string, roomUuid: string) { body: JSON.stringify({ sender_uuid: senderUuid, room_uuid: roomUuid }), }) } + +export function declineRoomInvite(senderUuid: string, roomUuid: string) { + return apiFetch('/rooms/decline', { + method: 'POST', + body: JSON.stringify({ sender_uuid: senderUuid, room_uuid: roomUuid }), + }) +} diff --git a/src/assets/vue.svg b/src/assets/vue.svg deleted file mode 100644 index 770e9d3..0000000 --- a/src/assets/vue.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/ChatWindow.vue b/src/components/ChatWindow.vue index 67c0106..87f37e1 100644 --- a/src/components/ChatWindow.vue +++ b/src/components/ChatWindow.vue @@ -9,6 +9,8 @@
+ +
@@ -218,6 +220,11 @@ onUnmounted(async () => { flex: 1; } +/* .room-name { */ +/* margin: 15px 0; */ +/* text-align: center; */ +/* } */ + .loading-more { text-align: center; padding: 10px; diff --git a/src/locales/en.ftl b/src/locales/en.ftl index 408cc6f..aee4c8a 100644 --- a/src/locales/en.ftl +++ b/src/locales/en.ftl @@ -53,10 +53,13 @@ notifications-room-invites = Room Invites notifications-no-requests = No pending requests notifications-no-invites = No pending invites notifications-accept = Accept +notifications-decline = Decline notifications-join = Join notifications-invite-from = from: {$user} -notifications-error-friend = An error occurred while accepting the request. -notifications-error-room = An error occurred while accepting the invite. +notifications-error-friend-accept = An error occurred while accepting the request. +notifications-error-friend-decline = An error occurred while declining the request. +notifications-error-room-accept = An error occurred while accepting the invite. +notifications-error-room-decline = An error occurred while declining the invite. ## Settings page settings-title = Settings diff --git a/src/locales/fr.ftl b/src/locales/fr.ftl index 22a788a..52b81af 100644 --- a/src/locales/fr.ftl +++ b/src/locales/fr.ftl @@ -53,10 +53,13 @@ notifications-room-invites = Invitations notifications-no-requests = Aucune demande en attente notifications-no-invites = Aucune invitation en attente notifications-accept = Accepter +notifications-decline = Refuser notifications-join = Rejoindre notifications-invite-from = de : {$user} -notifications-error-friend = Erreur lors de l'acceptation de la demande. -notifications-error-room = Erreur lors de l'acceptation de l'invitation. +notifications-error-friend-accept = Erreur lors de l'acceptation de la demande. +notifications-error-friend-decline = Erreur lors du refus de la demande. +notifications-error-room-accept = Erreur lors de l'acceptation de l'invitation. +notifications-error-room-decline = Erreur lors du refus de l'invitation. ## Settings page settings-title = Paramètres diff --git a/src/pages/NotificationsPage.vue b/src/pages/NotificationsPage.vue index 2fbe172..87f0994 100644 --- a/src/pages/NotificationsPage.vue +++ b/src/pages/NotificationsPage.vue @@ -9,7 +9,11 @@
  • {{ req.sender_username }} - +
    + + +

{{ $t('notifications-no-requests') }}

@@ -22,7 +26,11 @@
  • {{ inv.room_name }} {{ $t('notifications-invite-from', { user: inv.sender_username }) }} - +
    + + +
  • {{ $t('notifications-no-invites') }}

    @@ -32,8 +40,8 @@