diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index a39ce9b..70e36c9 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -497,12 +497,28 @@ export const api: API = { }); } }, - changeUserName: function ( - // eslint-disable-next-line @typescript-eslint/no-unused-vars - _data: StrNameChange, - // eslint-disable-next-line @typescript-eslint/no-unused-vars + + async changeUserName( + data: StrNameChange, token: string, ): Promise> { - throw new Error("Function not implemented."); + try { + const response = await fetch("/api/changeUserName", { + method: "PUT", + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + token, + }, + body: JSON.stringify(data), + }); + + if (!response.ok) { + return { success: false, message: "Failed to change username" }; + } else { + return { success: true }; + } + } catch (e) { + return { success: false, message: "Failed to change username" }; + } }, };