diff --git a/admin/src/utils/userActions.ts b/admin/src/utils/userActions.ts index 7d812b4..a1cd182 100644 --- a/admin/src/utils/userActions.ts +++ b/admin/src/utils/userActions.ts @@ -54,14 +54,17 @@ export const createUser = async ( password: string ) => { try { - const response = await fetch(`https://backend.insta.the1s.de/api/createUser`, { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${Cookies.get("token")}`, - }, - body: JSON.stringify({ username, role, password }), - }); + const response = await fetch( + `https://backend.insta.the1s.de/api/createUser`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${Cookies.get("token")}`, + }, + body: JSON.stringify({ username, role, password }), + } + ); if (!response.ok) { throw new Error("Failed to create user"); } @@ -74,14 +77,17 @@ export const createUser = async ( export const changePW = async (newPassword: string, username: string) => { try { - const response = await fetch(`http://localhost:8002/api/changePWadmin`, { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${Cookies.get("token")}`, - }, - body: JSON.stringify({ newPassword, username }), - }); + const response = await fetch( + `https://backend.insta.the1s.de/api/changePWadmin`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${Cookies.get("token")}`, + }, + body: JSON.stringify({ newPassword, username }), + } + ); if (!response.ok) { throw new Error("Failed to change password"); } @@ -139,14 +145,17 @@ export const createItem = async ( can_borrow_role: number ) => { try { - const response = await fetch(`https://backend.insta.the1s.de/api/createItem`, { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${Cookies.get("token")}`, - }, - body: JSON.stringify({ item_name, can_borrow_role }), - }); + const response = await fetch( + `https://backend.insta.the1s.de/api/createItem`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${Cookies.get("token")}`, + }, + body: JSON.stringify({ item_name, can_borrow_role }), + } + ); if (!response.ok) { throw new Error("Failed to create item"); } diff --git a/frontend/src/utils/userHandler.ts b/frontend/src/utils/userHandler.ts index 6bf92b0..2491199 100644 --- a/frontend/src/utils/userHandler.ts +++ b/frontend/src/utils/userHandler.ts @@ -75,14 +75,17 @@ export const rmFromRemove = (itemID: number) => { export const createLoan = async (startDate: string, endDate: string) => { const items = removeArr; - const response = await fetch("https://backend.insta.the1s.de/api/createLoan", { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${Cookies.get("token") || ""}`, - }, - body: JSON.stringify({ items, startDate, endDate }), - }); + const response = await fetch( + "https://backend.insta.the1s.de/api/createLoan", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${Cookies.get("token") || ""}`, + }, + body: JSON.stringify({ items, startDate, endDate }), + } + ); if (!response.ok) { myToast("Fehler beim Erstellen der Ausleihe", "error"); @@ -122,12 +125,15 @@ export const onReturn = async (loanID: number) => { }; export const onTake = async (loanID: number) => { - const response = await fetch(`https://backend.insta.the1s.de/api/takeLoan/${loanID}`, { - method: "POST", - headers: { - Authorization: `Bearer ${Cookies.get("token") || ""}`, - }, - }); + const response = await fetch( + `https://backend.insta.the1s.de/api/takeLoan/${loanID}`, + { + method: "POST", + headers: { + Authorization: `Bearer ${Cookies.get("token") || ""}`, + }, + } + ); if (!response.ok) { myToast("Fehler beim Ausleihen der Ausleihe", "error"); @@ -139,14 +145,17 @@ export const onTake = async (loanID: number) => { }; export const changePW = async (oldPassword: string, newPassword: string) => { - const response = await fetch("http://localhost:8002/api/changePassword", { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${Cookies.get("token") || ""}`, - }, - body: JSON.stringify({ oldPassword, newPassword }), - }); + const response = await fetch( + "https://backend.insta.the1s.de/api/changePassword", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${Cookies.get("token") || ""}`, + }, + body: JSON.stringify({ oldPassword, newPassword }), + } + ); if (!response.ok) { myToast("Fehler beim Ändern des Passworts", "error");