Skip to content

Commit

Permalink
get associated by 'session'
Browse files Browse the repository at this point in the history
  • Loading branch information
guipeeix7 committed Dec 17, 2024
1 parent 1148449 commit 2eb6b22
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Components/SideBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function SideBar() {
}}
/>,
<SideButton
hidden={checkModule(permissions, "users") ? "flex" : "none"}
hidden={user ? "flex" : "none"}
key="carteirinha"
text="CARTEIRINHA"
onClick={() => {
Expand Down
18 changes: 9 additions & 9 deletions src/Pages/Protected/Carteirinha/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import penalLogo from "../../../assets/penal_df-min.png.png";
//import qrCode from "../../../assets/qr-code.png";
import { FaFacebook, FaInstagram, FaYoutube } from "react-icons/fa";
import { FaXTwitter } from "react-icons/fa6";
import {
getLoggedMemberShip,
} from "../../../Services/memberShipService";

const Carteirinha = () => {
const cardRef = useRef(null);
Expand All @@ -19,10 +22,12 @@ const Carteirinha = () => {
useEffect(() => {
const fetchMembership = async () => {
try {
const response = await fetch("http://localhost:3001/membership");
const data = await response.json();
setMembershipData(data[0]);
console.log("alohaa", data);
const user = await getLoggedMemberShip();

// const response = await fetch("http://localhost:3001/logged-membership");
// const data = await response.json();
setMembershipData(user);
console.log('noooo', user)
} catch (error) {
console.error("Erro ao buscar os dados do membership:", error);
}
Expand Down Expand Up @@ -88,7 +93,6 @@ const Carteirinha = () => {
<div className="info-block">
<strong>TITULAR:</strong>
<br />
<p className="info-color-titular"></p>
<p className="info-color-titular">
<span>{name}</span>
</p>
Expand All @@ -98,7 +102,6 @@ const Carteirinha = () => {
<div className="info-block">
<strong>DATA DE NASCIMENTO:</strong>
<br />
<p className="info-color" />

<p className="info-color">
<span>{new Date(birthDate).toLocaleDateString()}</span>
Expand All @@ -107,7 +110,6 @@ const Carteirinha = () => {
<div className="info-block">
<strong>DATA DE EXPEDIÇÃO:</strong>
<br />
<p className="info-color" />
<p className="info-color">
<span>{new Date(expeditionDate).toLocaleDateString()}</span>
</p>
Expand All @@ -117,15 +119,13 @@ const Carteirinha = () => {
<div className="info-block">
<strong>CPF:</strong>
<br />
<p className="info-color" />
<p className="info-color">
<span>{cpf}</span>
</p>
</div>
<div className="info-block">
<strong>CONTRATAÇÃO:</strong>
<br />
<p className="info-color" />
<p className="info-color">
<span>{new Date(hiringDate).toLocaleDateString()}</span>
</p>
Expand Down
16 changes: 16 additions & 0 deletions src/Services/memberShipService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { APIUsers } from "./BaseService";
import { getToken } from "./Functions/loader";

// const storagedToken = localStorage.getItem("@App:token");
// const token = JSON.parse(storagedToken);
Expand All @@ -25,6 +26,21 @@ export async function getMemberShip(status) {
}
}

export async function getLoggedMemberShip() {

try {
const token = getToken();
const response = await APIUsers.get("logged-membership", {
headers: {
Authorization: `Bearer ${token}`,
},
});
return response.data;
} catch (error) {
return error.response.data.erro;
}
}

export async function getMemberShipById(id) {
try {
const response = await APIUsers.get(`membership/${id}`);
Expand Down

0 comments on commit 2eb6b22

Please sign in to comment.