Skip to content

Commit

Permalink
Merge pull request #52 from dwm-2023-2/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
CaioSantdev authored Dec 8, 2023
2 parents 031ee89 + b103deb commit 46a9d34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
},
"description": "Frontend da aplicação web Diário Online para a disciplina de Desenvolvimento WebMobile Turma B 2023.2, do curso de Ciência da Computação da Universidade Federal do Tocantins.",
"main": "vite.config.js",
"author": "",
"license": "ISC"
}
46 changes: 29 additions & 17 deletions src/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import api from "../services/api";
import styles from "../styles/Profile.module.css";
import { useNavigate } from "react-router-dom";
import { Typography, TextField, Button } from "@mui/material";

// ... (importações existentes)
import Swal from "sweetalert2";

export const Profile = () => {
const userInfoState = userInfoStore((state) => state.userInfo);
Expand All @@ -18,21 +17,34 @@ export const Profile = () => {
let storageEmail = localStorage.getItem("email");

const submitDelete = () => {
const shouldDelete = window.confirm(
"Are you sure want to delete your account?"
);
if (shouldDelete) {
api
.delete(`/users/${storageUserId}`)
.then((response) => {
console.log(response);
navigate("/");
localStorage.clear();
})
.catch((err) => {
console.error("ops! ocorreu um erro" + err);
});
}
Swal.fire({
title: "Tem certeza?",
text: "Você não poderá reverter isso!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Sim, Deletar!"
}).then((result) => {
if (result.isConfirmed) {
// If user confirms, proceed with the delete action
api
.delete(`/users/${storageUserId}`)
.then((response) => {
console.log(response);
Swal.fire({
title: "Deletado!",
text: "Seu usuario foi removido com sucesso!.",
icon: "success"
});
navigate("/login");
localStorage.clear();
})
.catch((err) => {
console.error("Oops! An error occurred" + err);
});
}
});
};

return (
Expand Down

0 comments on commit 46a9d34

Please sign in to comment.