- add popup function pour delete an account in settings page
This commit is contained in:
Kum1ta
2024-09-30 22:57:15 +02:00
parent b68642a5cd
commit 3ed6224d5c
4 changed files with 30 additions and 7 deletions

View File

@ -63,7 +63,7 @@
</div> </div>
</div> </div>
<button class="delete-btn" id="deleteButton">Delete the account</button> <button class="delete-btn" id="buttonShowDeleteMenu">Delete the account</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/25 17:00:35 by edbernar #+# #+# */ /* Created: 2024/09/25 17:00:35 by edbernar #+# #+# */
/* Updated: 2024/09/26 22:48:29 by edbernar ### ########.fr */ /* Updated: 2024/09/30 22:47:54 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,14 +26,18 @@ class settingsPage
const passwordInput = document.getElementById('password'); const passwordInput = document.getElementById('password');
const newPasswordInput = document.getElementById('new-password'); const newPasswordInput = document.getElementById('new-password');
const confirmPasswordInput = document.getElementById('confirm-password'); const confirmPasswordInput = document.getElementById('confirm-password');
const usernameDeleteInput = document.getElementById('username-delete');
const usernameSaveButton = document.getElementById('usernameButtonSave'); const usernameSaveButton = document.getElementById('usernameButtonSave');
const discordSaveButton = document.getElementById('discordButtonSave'); const discordSaveButton = document.getElementById('discordButtonSave');
const passwordSaveButton = document.getElementById('passwordButtonSave'); const passwordSaveButton = document.getElementById('passwordButtonSave');
const deleteButton = document.getElementById('deleteButton'); const deleteButton = document.getElementById('deleteButton');
const buttonShowDeleteMenu = document.getElementById('buttonShowDeleteMenu');
const loginButton = document.getElementById('loginButton').getElementsByTagName('p')[0]; const loginButton = document.getElementById('loginButton').getElementsByTagName('p')[0];
const methButton = document.getElementById("homeButton"); const methButton = document.getElementById('homeButton');
const divDeleteAccount = document.getElementById('popup-background-delete');
let interval = null; let interval = null;
@ -60,6 +64,9 @@ class settingsPage
{ {
passwordInput.style.backgroundColor = newPasswordInput.style.backgroundColor = confirmPasswordInput.style.backgroundColor = passwordSaveButton.style.backgroundColor = "#bbbbbb"; passwordInput.style.backgroundColor = newPasswordInput.style.backgroundColor = confirmPasswordInput.style.backgroundColor = passwordSaveButton.style.backgroundColor = "#bbbbbb";
passwordInput.type = newPasswordInput.type = confirmPasswordInput.type = 'text'; passwordInput.type = newPasswordInput.type = confirmPasswordInput.type = 'text';
passwordInput.disabled = true;
newPasswordInput.disabled = true;
confirmPasswordInput.disabled = true;
passwordSaveButton.disabled = true; passwordSaveButton.disabled = true;
} }
discordInput.value = data.discord_username; discordInput.value = data.discord_username;
@ -71,7 +78,25 @@ class settingsPage
discordSaveButton.addEventListener('click', () => { discordSaveButton.addEventListener('click', () => {
sendRequest("change_private_info", {discord: discordInput.value}); sendRequest("change_private_info", {discord: discordInput.value});
}); });
buttonShowDeleteMenu.addEventListener('click', () => {
divDeleteAccount.style.display = 'flex';
function hideMenu(e)
{
if (e.target.getAttribute('class') == "popup-background-delete")
{
divDeleteAccount.style.display = 'none';
usernameDeleteInput.value = 'aaa';
buttonShowDeleteMenu.removeEventListener('click', hideMenu);
}
};
divDeleteAccount.addEventListener('click', hideMenu);
});
deleteButton.addEventListener('click', () => { deleteButton.addEventListener('click', () => {
if (usernameDeleteInput.value != userMeInfo.username)
{
CN.new("Error", "Username does not match", CN.error);
return ;
}
sendRequest("change_private_info", {delete: true}); sendRequest("change_private_info", {delete: true});
userMeInfo.id = -1; userMeInfo.id = -1;
setTimeout(() => { setTimeout(() => {

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/27 10:53:20 by edbernar #+# #+# */ /* Created: 2024/09/27 10:53:20 by edbernar #+# #+# */
/* Updated: 2024/09/27 10:58:05 by edbernar ### ########.fr */ /* Updated: 2024/09/30 22:44:27 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -10,8 +10,6 @@
font-style: normal; font-style: normal;
} }
/* POUR EDDY : POPUP DELETE ACCOUNT ICI NONE -> FLEX, BE CAREFULL CHANGE DE FUNCTIONNALITY OF THE FIRST BUTTON FOR NOT DELETE THE ACCOUNT */
.popup-background-delete { .popup-background-delete {
display: none; display: none;
position: fixed; position: fixed;
@ -26,7 +24,7 @@
} }
.popup-delete { .popup-delete {
display: none; display: flex;
flex-direction: column; flex-direction: column;
background-color: #020202; background-color: #020202;
color: white; color: white;