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

Us5 exibir preços e detalhes dos beneficios para os usuarios logados #4

Merged
Show file tree
Hide file tree
Changes from 3 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
101 changes: 101 additions & 0 deletions src/Pages/Protected/Benefit/BenefitsValue/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.benefits-container {
max-width: 1200px;
margin: 0 auto;
padding: 4rem 2rem;
font-family: "Noto Sans";
color: #332117;
height: 100%;
}

.benefits-header h1 {
font-size: 2.125rem;
}

.benefits-header p {
font-size: 1.5rem;
color: #341f14;
margin-bottom: 1.25rem;
}

.benefits-list {
width: 100%;
}

.box-benefits {
margin-top: 1.25rem;
}

.benefit-item {
display: flex;
align-items: center;
padding: 1rem 0;
}

.benefit-datails {
position: absolute;
justify-items: center;
left: 50%;
transform: translateX(-50%);
}

.benefit-value {
position: absolute;
justify-items: center;
left: 85%;
}


.benefit-details-expanded {
display: flex;
justify-content: space-between;
align-items: center;
overflow-wrap: break-word;
gap: 7rem;
padding: 0.25rem 3rem;
}

.benefit-item > .MuiListItemText-primary {
font-weight: bold;
font-size: 1.25rem;
}

.benefit-item .MuiListItemText-secondary {
font-weight: 300;
font-size: 0.875rem;
color: #8c7765;
}

@media (max-width: 890px) {
.benefits-container {
padding-top: 4rem;
}
.benefit-datails {
position: relative;
left: auto;
transform: none;
}
.benefit-item {
flex-direction: column;
}
.benefit-value {
display: flex;
text-align: center;
align-items: center;
padding: 0.25rem 2rem;
border-radius: 10px;
background: #eae3d7;
}
.benefit-details-expanded {
flex-direction: column-reverse;
overflow-wrap: anywhere;
gap: 1rem;
}
.benefit-details-expanded .MuiListItemText-primary {
font-size: 0.85rem;
}
.benefit-value {
position: relative;
left: auto;
transform: none;
}
}
97 changes: 97 additions & 0 deletions src/Pages/Protected/Benefit/BenefitsValue/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { useState, useEffect } from "react";
import { getBenefitsForm } from "../../../../Services/benefitsService";

import { FaWhatsapp } from "react-icons/fa";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import ListItemText from "@mui/material/ListItemText";
import Divider from "@mui/material/Divider";

import "./index.css";

export default function BenefitsValue() {
const [benefits, setBenefits] = useState([]);
const [expandedBenefit, setExpandedBenefit] = useState(null);

const handleExpand = (id) => {
// Alterna entre expandir e recolher o benefício clicado
setExpandedBenefit((prev) => (prev === id ? null : id));
};

useEffect(() => {
const getBenefits = async () => {
const response = await getBenefitsForm();
setBenefits(response);
};

getBenefits();
}, []);

return (
<section className="benefits-container">
<div className="benefits-list">
<div className="benefits-header">
<h1> Valores dos benefícios</h1>
<p>Benefícios disponíveis</p>
</div>
<div className="box-benefits">
<List>
{benefits?.map(
(benefit, index) => (
console.log(benefit),
(
<div key={benefit._id}>
<ListItem className="benefit-item">
<ListItemText primary={benefit.nome} />
<ListItemText
className="benefit-datails"
style={{
textDecoration: "underline",
cursor: "pointer",
}}
primary="Mais Detalhes"
onClick={() => handleExpand(benefit._id)}
/>
<div className="benefit-value">
<ListItemText
primary="Valor"
secondary={
index % 2
? "Incluso na filiação"
: "Disconto de 15%"
}
/>
</div>
</ListItem>

{expandedBenefit === benefit._id && (
<div className="benefit-details-expanded">
<ListItemText primary={benefit.descricao} />
<a
href="https://api.whatsapp.com/send/?phone=556133211949"
style={{
fontSize: "2rem",
textDecoration: "none",
color: "#3D160D",
}}
>
<FaWhatsapp />
</a>
</div>
)}

<Divider
style={{
padding: "1rem 0 0 0"
}}
/>
</div>
)
)
)}
</List>
</div>
</div>
</section>
);
}
13 changes: 0 additions & 13 deletions src/Pages/Public/Advantages/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,4 @@
margin: 20px auto;
}

h1, h2{
padding-left: 65px;
color: #3D160D;
}
h1{
font-size: 50px;
padding-top: 67px;
}

h2{
font-size: 30px;
padding-top: 19px;
}

13 changes: 12 additions & 1 deletion src/Routes/protectedRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import RolesListPage from "../Pages/Protected/Roles/RolesListPage";
import RolesUpdatePage from "../Pages/Protected/Roles/RolesUpdatePage";
import MembershipRequest from "../Pages/Protected/MembershipRequests";
import Benefits from "../Pages/Protected/Benefit/Benefits";
import BenefitsValue from "../Pages/Protected/Benefit/BenefitsValue";
import BenefitsList from "../Pages/Protected/Benefit/BenefitsList";
import BenefitsCreate from "../Pages/Protected/Benefit/BenefitsCreate";
import BenefitsUpdate from "../Pages/Protected/Benefit/BenefitsUpdate";
Expand Down Expand Up @@ -151,6 +152,16 @@ const ProtectedRoutes = () => {
/>
}
/>
<Route
path="/beneficios/valor"
element={
<PermissionProtect
element={<BenefitsValue />}
moduleName="benefits"
actions={["read"]}
/>
}
/>
<Route
path="/beneficios/lista"
element={
Expand Down Expand Up @@ -299,4 +310,4 @@ const ProtectedRoutes = () => {
);
};

export default ProtectedRoutes;
export default ProtectedRoutes;