Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get associated by 'session' #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading