From 6fdfc80880bbdd0f70dcc8c4d4c772d6ce70c502 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 4 Nov 2023 23:13:41 +0100 Subject: [PATCH] variable for item --- web/html/user.html | 2 +- web/js/{user.js => item.js} | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) rename web/js/{user.js => item.js} (92%) diff --git a/web/html/user.html b/web/html/user.html index 2273ae7..34b612f 100644 --- a/web/html/user.html +++ b/web/html/user.html @@ -369,5 +369,5 @@ - + \ No newline at end of file diff --git a/web/js/user.js b/web/js/item.js similarity index 92% rename from web/js/user.js rename to web/js/item.js index 80c3321..e6a89c2 100644 --- a/web/js/user.js +++ b/web/js/item.js @@ -1,10 +1,12 @@ checkToken(); signOut(); closeButton(); +pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0] + var id = getQuery("id"); if(id.length > 0){ - instance.get("users/"+id, {withCredentials: true}) + instance.get(pathURL + "s/"+id, {withCredentials: true}) .then(function(response){ var listValue = [ "id", "username", "name", "firstName", "email", "birth"]; var listTime = ["connected_at", "created_at", "updated_at", "deleted_at", "disabled_at"]; @@ -64,15 +66,15 @@ if(id.length > 0){ switch(e.currentTarget.id){ case "disableUserButton": httpMethod = "delete"; - httpUrl = "users/"+idInput; + httpUrl = pathURL + "s/"+idInput; break; case "removeUserButton": httpMethod = "delete"; - httpUrl = "users/"+idInput+"?remove=true"; + httpUrl = pathURL + "s/"+idInput+"?remove=true"; break; default: httpMethod = "patch"; - httpUrl = "users/"+idInput; + httpUrl = pathURL + "s/"+idInput; break; } instance({ @@ -82,7 +84,7 @@ if(id.length > 0){ }) .then(function(response){ if(response.status == 200){ - location.href="/html/user.html?id="+idInput; + location.href="/html/"+pathURL+".html?id="+idInput; } }) .catch(function(error){ @@ -140,7 +142,7 @@ if(id.length > 0){ } instance({ method : "put", - url:"users/"+document.getElementById("idUpdateInput").value, + url:pathURL+"s/"+document.getElementById("idUpdateInput").value, withCredentials: true, data: dataPut }).then(function(response){