diff --git a/frontend/src/components/Calendar/Calendar.jsx b/frontend/src/components/Calendar/Calendar.jsx
index 9e50333..5de0ddf 100644
--- a/frontend/src/components/Calendar/Calendar.jsx
+++ b/frontend/src/components/Calendar/Calendar.jsx
@@ -1,197 +1,217 @@
-import React,{useState, useEffect} from "react";
-import { Calendar, dateFnsLocalizer, momentLocalizer } from 'react-big-calendar';
-import { format, parse, startOfWeek, getDay} from 'date-fns';
-import ptBR from 'date-fns/locale/pt-BR';
+import { useState, useEffect } from "react";
+import {
+ Calendar,
+ dateFnsLocalizer,
+} from "react-big-calendar";
+import { format, parse, startOfWeek, getDay } from "date-fns";
+import ptBR from "date-fns/locale/pt-BR";
import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop";
import "react-big-calendar/lib/css/react-big-calendar.css";
import "react-big-calendar/lib/addons/dragAndDrop/styles.css";
-import './Calendar.scss';
-import moment from 'moment';
-import 'moment/locale/pt-br';
-
+import "./Calendar.scss";
+import moment from "moment";
+import "moment/locale/pt-br";
const DragAndDropCalendar = withDragAndDrop(Calendar);
-
const locales = {
- 'pt-BR': ptBR,
- };
+ "pt-BR": ptBR,
+};
const localizer = dateFnsLocalizer({
- format,
- parse,
- startOfWeek: () => startOfWeek(new Date(), { locale: ptBR }),
- getDay,
- locales,
- });
+ format,
+ parse,
+ startOfWeek: () => startOfWeek(new Date(), { locale: ptBR }),
+ getDay,
+ locales,
+});
+
+function Calendario({ eventos }) {
+ const events = eventos.map((evento) => {
+ const [strData, strHora] = evento.date.split("T");
+ const [year, month, day] = strData.split("-").map(Number);
+ const [hour, minute] = strHora.split(":").map(Number);
+
+ const dateStart = new Date(year, month - 1, day, hour, minute);
+ const [durHour, durMin] = evento.estimatedDuration.split(":").map(Number);
-function Calendario(){
+ const dateEnd = new Date(dateStart);
+ dateEnd.setHours(dateEnd.getHours() + durHour);
+ dateEnd.setMinutes(dateEnd.getMinutes() + durMin);
- const [eventos, setEventos] = useState([{
- id:1,
- title: "Mutirão das esponjas",
- start: new Date(2025,2,26,10,0),
- end: new Date(2025,2,26,15,0),
- desc: "Primeiro mutirão",
- color: "#195D39",
- tipo: "Atividade",
+ return {
+ title: evento.name,
+ start: dateStart,
+ end: dateEnd,
+ desc: `Localização: ${evento.location}`,
+ color: "#195D39"
+ };
+ });
+
+ const eventStyle = (e) => ({
+ style: {
+ backgroundColor: e.color,
},
- {
- id:2,
- title: "Esponjas do bob",
- start: new Date(2025,2,26,10,0),
- end: new Date(2025,2,26,15,0),
- desc: "Segundo mutirão",
- color: "#195D39",
- tipo: "Atividade",
- }
- ])
-
- const eventStyle = (e) => ({
- style:{
- backgroundColor: e.color
- },
- })
- const [viewAtual, setViewAtual] = useState('month');
- const [dataAtual, setDataAtual] = useState(new Date());
-
- // Força sincronização com a view inicial
+ });
+ const [viewAtual, setViewAtual] = useState("month");
+ const [dataAtual, setDataAtual] = useState(new Date());
+
useEffect(() => {
- setViewAtual('month');
+ setViewAtual("month");
}, []);
- return(
-
-
{label}
-
-
-
-
- {viewsItem.map((view, index) => (
- -
-
-
- ))}
-
-
-
-
-
-
-
-
+const CustomTollbar = ({
+ label,
+ views,
+ viewAtual,
+ setViewAtual,
+ dataAtual,
+ setDataAtual,
+}) => {
+ const [itemText, setItemText] = useState("Mês");
+ const viewsItem = [
+ { label: "Mês", value: views[0] },
+ { label: "Semana", value: views[1] },
+ { label: "Dia", value: views[2] },
+ { label: "Agenda", value: views[3] },
+ ];
+
+ const handleViewChange = (view) => {
+ setViewAtual(view);
+ const selected = viewsItem.find((v) => v.value === view);
+ setItemText(selected ? selected.label : "");
+ };
+
+ useEffect(() => {
+ const selected = viewsItem.find((v) => v.value === viewAtual);
+ setItemText(selected ? selected.label : "");
+ }, [viewAtual]);
+
+ const getUnidade = () => {
+ switch (viewAtual) {
+ case "month":
+ return "month";
+ case "week":
+ return "week";
+ case "day":
+ case "agenda":
+ return "day";
+ default:
+ return "month";
+ }
+ };
+
+ const handleNavigate = (action) => {
+ const current = moment(dataAtual);
+ let novaData;
+
+ switch (action) {
+ case "TODAY":
+ novaData = new Date();
+ break;
+ case "PREV":
+ novaData = current.subtract(1, getUnidade()).toDate();
+ break;
+ case "NEXT":
+ novaData = current.add(1, getUnidade()).toDate();
+ break;
+ default:
+ novaData = dataAtual;
+ }
+
+ setDataAtual(novaData);
+ };
+
+ return (
+
+
+ {label.charAt(0).toUpperCase() + label.slice(1)}
+
+
+
+
+
+ {viewsItem.map((view, index) => (
+ -
+
+
+ ))}
+
+
+
+
+
+
- );
+
+
+ );
};
-export default Calendario
\ No newline at end of file
+export default Calendario;
diff --git a/frontend/src/components/Calendar/Calendar.scss b/frontend/src/components/Calendar/Calendar.scss
index e7bdb6d..b8b29dd 100644
--- a/frontend/src/components/Calendar/Calendar.scss
+++ b/frontend/src/components/Calendar/Calendar.scss
@@ -1,10 +1,11 @@
-.calendario{
+.calendario {
height: 90vh;
width: 100vw;
// background-color: #262626;
margin-bottom: 5%;
}
-.calendar{
+
+.calendar {
margin: 5% 5%;
padding: 1%;
// height: 60vh;
@@ -14,96 +15,101 @@
border-radius: 4px;
}
-.calendar button{
+.calendar button {
// color:#c2c2c2;
}
+
/*header modificado*/
-.toolbar-container{
+.toolbar-container {
display: flex;
height: 12vh;
align-items: center;
padding-left: 50px;
}
-.mesAno{
+
+.mesAno {
width: 50%;
color: #f3f3f3;
justify-content: flex-start;
}
-.dirtop{
+
+.dirtop {
width: 50%;
justify-content: end;
display: flex;
align-items: center;
padding-left: 5%;
}
-.rbc-toolbar{
+
+.rbc-toolbar {
height: 10vh;
color: #bbb;
font-size: 20px;
}
-.rbc-btn-group > button{
+.rbc-btn-group>button {
border: 0;
}
-.rbc-toolbar button{
- color:#cecece;
+.rbc-toolbar button {
+ color: #cecece;
border: 1px solid #cccccc4f;
}
-.rbc-toolbar button:active,
-.rbc-toolbar button.rbc-active{
+.rbc-toolbar button:active,
+.rbc-toolbar button.rbc-active {
background-color: #565656;
- border-color:#bbbb
+ border-color: #bbbb
}
/*Corpo*/
/*linhas*/
-.rbc-month-view{
+.rbc-month-view {
border-color: #eeeeee5f;
}
-.rbc-month-row + .rbc-month-row {
+
+.rbc-month-row+.rbc-month-row {
border-color: #dddddd73;
}
-.rbc-day-bg + .rbc-day-bg{
+.rbc-day-bg+.rbc-day-bg {
border-color: #dddddd73;
}
/*Mês*/
-.rbc-header{
- color:#eeeeeeee;
+.rbc-header {
+ color: #eeeeeeee;
border-color: #dddddd73;
}
-.rbc-header + .rbc-header{
+.rbc-header+.rbc-header {
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-color: #dddddd73;
}
-.rbc-off-range-bg{
- background-color: #313131;
+.rbc-off-range-bg {
+ background-color: #313131;
}
-.rbc-today{
+.rbc-today {
background-color: #1a1a1a;
}
-.rbc-button-link{
+.rbc-button-link {
margin: 2px;
font-size: 15px;
color: #eeeeeee5;
}
-.rbc-off-range .rbc-button-link{
+.rbc-off-range .rbc-button-link {
color: #eeeeee37;
}
-.rbc-now .rbc-button-link{
+.rbc-now .rbc-button-link {
background-color: #B1E3FA;
color: #114C6D;
border-radius: 2px;
@@ -112,28 +118,93 @@
font-size: 16px;
}
-.rbc-time-content, .rbc-time-content > .rbc-day-slot,
-.rbc-timeslot-group, .rbc-time-slot{
+.rbc-time-content,
+.rbc-time-content>.rbc-day-slot,
+.rbc-timeslot-group,
+.rbc-time-slot {
color: #bbb;
border-color: #b0b0b036;
}
-.rbc-day-slot .rbc-time-slot{
- border-top:1px solid #c8c8c80a;
+.rbc-day-slot .rbc-time-slot {
+ border-top: 1px solid #c8c8c80a;
}
/*Agenda*/
-.rbc-agenda-content, .rbc-agenda-view{
+.rbc-agenda-content,
+.rbc-agenda-view {
color: #aaa;
}
-.rbc-agenda-date-cell, .rbc-agenda-time-cell{
+.rbc-agenda-date-cell,
+.rbc-agenda-time-cell {
background-color: #262626;
}
-.rbc-agenda-event-cell{
+.rbc-agenda-event-cell {
border-radius: 20px;
font-weight: bold;
color: #e0e0e0;
}
+
+.dropdown {
+ width: 30%;
+}
+
+.dropdown button {
+ width: 100%;
+}
+
+.toolbar-navigation {
+ width: 50%;
+ display: flex;
+ gap: 2%;
+}
+
+#today_config {
+ width: 60%;
+}
+
+#prev_config,
+#next_config {
+ width: 20%;
+}
+
+@media(max-width:760px) {
+ .dropdown {
+ width: 40%;
+ }
+
+ .toolbar-navigation {
+ margin-right: 5%;
+ }
+
+}
+
+@media(max-width:580px) {
+ .mesAno {
+ font-size: 20px;
+ }
+
+ .dropdown {
+ width: 50%;
+ }
+
+ .toolbar-navigation {
+
+ margin-right: 7%;
+ }
+
+}
+
+@media(max-width:580px) {
+ .mesAno {
+ position: relative;
+ left: -10%;
+ }
+
+ .dirtop {
+ width: 80%;
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/components/CrowndfundindCard/CrowndfundingCard.jsx b/frontend/src/components/CrowndfundindCard/CrowndfundingCard.jsx
index 64e56be..faf988f 100644
--- a/frontend/src/components/CrowndfundindCard/CrowndfundingCard.jsx
+++ b/frontend/src/components/CrowndfundindCard/CrowndfundingCard.jsx
@@ -1,57 +1,130 @@
import React from "react";
-import cardStyle from "./CrowndfundingCard.module.scss"
+import cardStyle from "./CrowndfundingCard.module.scss";
import { PiStarFill } from "react-icons/pi";
import { FaCalendarDays } from "react-icons/fa6";
import { AiFillCloseSquare } from "react-icons/ai";
-import { FaUsers, FaMinusSquare,FaWindowClose,FaStar } from "react-icons/fa";
+import { FaUsers, FaMinusSquare, FaWindowClose, FaStar } from "react-icons/fa";
import { MdAccessTimeFilled, MdLocationOn } from "react-icons/md";
-function CrowndfundingCard(props){
+function CrowndfundingCard({
+ crownd,
+ name,
+ location,
+ date,
+ hour,
+ state,
+ meetingpoint,
+ estimatedDuration,
+}) {
+ let status =
+ state === "presente"
+ ? "presente"
+ : state === "analise"
+ ? "em_analise"
+ : "faltou";
- let status = props.state === "presente" ? "presente" :
- props.state === "analise"
- ? "em_analise"
- : "faltou";
- return(
- <>{ props.crownd ?
-
-
{props.num} esponjas
-
- {props.place}
- {props.date}
- {props.hour}
-
-
-
- :
-
-
{props.nome}
-
- {props.place}
- {props.date}
- {props.duration}
-
- {
- status === "presente" ?
-
- : status === "em_analise" ?
-
- :
-
- }
-
-
- }
- >
- )
+ return (
+ <>
+ {crownd ? (
+
+
{name}
+
+
+ {" "}
+ {location}
+
+
+ {" "}
+ {date}
+
+
+ {" "}
+ {hour}
+
+
+
+
+ ) : (
+
+
+ {name}
+
+
+
+ {" "}
+ {" "}
+ {location}
+
+
+ {" "}
+ {" "}
+ {date}
+
+
+ {" "}
+ {" "}
+ {estimatedDuration}
+
+
+ {status === "presente" ? (
+
+ ) : status === "em_analise" ? (
+
+ ) : (
+
+ )}
+
+ )}
+ >
+ );
}
-export default CrowndfundingCard;
\ No newline at end of file
+export default CrowndfundingCard;
diff --git a/frontend/src/pages/depositos/depositos.module.scss b/frontend/src/pages/depositos/depositos.module.scss
index 652702d..5d85556 100644
--- a/frontend/src/pages/depositos/depositos.module.scss
+++ b/frontend/src/pages/depositos/depositos.module.scss
@@ -1,5 +1,6 @@
.body {
min-height: 75dvh;
+
h1 {
margin: 5% 0% 0% 3%;
}
@@ -11,7 +12,7 @@
justify-content: center;
align-items: center;
margin-top: 7%;
-
+
p {
margin: auto;
color: black;
@@ -22,7 +23,11 @@
padding-top: 5%;
}
-.infoSection p, .btnRegisterDeposit, .modalBody label, .modalImagePreviewContainer p, .modalSubmit {
+.infoSection p,
+.btnRegisterDeposit,
+.modalBody label,
+.modalImagePreviewContainer p,
+.modalSubmit {
font-family: 'Tankindred', sans-serif;
}
@@ -34,7 +39,8 @@
width: 40%;
}
-.btnRegisterDeposit, .pointFullError {
+.btnRegisterDeposit,
+.pointFullError {
margin: 5% 0% 3% 0%;
}
@@ -53,9 +59,9 @@
border-radius: 10px;
background-color: #F1F1F1;
padding: 20px;
- position: absolute;
- top: 50%;
- left: 50%;
+ position: absolute;
+ top: 50%;
+ left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}
@@ -130,45 +136,113 @@
margin-top: 2%;
}
+@media(max-width:1340px) {
+ .modalBody {
+ width: 50%;
+ padding: 3%
+ }
+
+ .modalClose {
+ margin-bottom: -9%;
+ }
+}
+
+@media(max-width:1115px) {
+ .modalForm label {
+ font-size: 17px;
+ }
+
+ .modalForm div label {
+ font-size: 15px;
+ }
+
+}
+
+@media (max-width: 1035px) {
+ .infoSection {
+ max-width: 100%;
+ padding: 2% 5%;
+ margin-top: 4%;
+ }
+
+ .modalSubmit {
+ display: flex;
+ text-align: center;
+ justify-content: center;
+ margin-right: 5%;
+ font-size: 80%;
+ min-width: 25px;
+ padding: 2%;
+ }
+}
+
+@media(max-width:870px) {
+ .modalForm div label {
+ font-size: 13px;
+ }
+
+}
+
@media (max-width: 768px) {
- .modalBody {
- width: 90%;
- padding: 15px;
- }
+ .modalBody {
+ width: 80%;
+ padding: 5% 5%;
+ justify-content: center;
+ align-items: center;
+ }
- .modalInputSpongeAmount {
- width: 100%;
- font-size: 1rem;
- }
+ .modalForm {
+ width: 100%;
+ justify-content: center;
+ align-items: center;
+ }
- .modalLabelInputImage {
- width: 100%;
- height: 20dvh;
- font-size: 0.9rem;
- }
+ .modalForm div label {
+ min-width: 90%;
+ }
- .modalImagePreviewContainer {
- width: 100%;
+ .modalForm div {
+ min-width: 70%;
+ }
- img {
- max-width: 80%;
+ .modalInputSpongeAmount {
+ margin-left: 0%;
+ width: 100%;
+ font-size: 1rem;
}
- button {
- font-size: 0.9rem;
- padding: 2%;
+ .modalLabelInputImage {
+ width: 100%;
+ height: 20dvh;
+ font-size: 0.9rem;
}
- }
- .modalSubmit {
- width: 100%;
- font-size: 1rem;
- padding: 10px;
- }
+ .modalInputImage {
+ width: 90%;
+ }
- .modalForm label,
- .modalImagePreviewContainer p {
- font-size: 1rem;
- text-align: center;
- }
+ .modalImagePreviewContainer {
+ width: 100%;
+
+ img {
+ max-width: 80%;
+ }
+
+ button {
+ font-size: 0.9rem;
+ padding: 2%;
+ }
+ }
+
+ .modalSubmit {
+ display: flex;
+ width: 50%;
+ margin-left: 5%;
+ font-size: 1rem;
+ }
}
+
+.modalForm label,
+.modalImagePreviewContainer p {
+ font-size: 1rem;
+}
\ No newline at end of file
diff --git a/frontend/src/pages/depositos/index.jsx b/frontend/src/pages/depositos/index.jsx
index 4819731..de04757 100644
--- a/frontend/src/pages/depositos/index.jsx
+++ b/frontend/src/pages/depositos/index.jsx
@@ -2,182 +2,247 @@ import { useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import Header from "../../components/Header";
import Footer from "../../components/Footer";
-import depositos from './depositos.module.scss'
+import depositos from "./depositos.module.scss";
import { MdClose } from "react-icons/md";
-import api from "../../api.js"
-import { toast } from "react-toastify"
+import api from "../../api.js";
+import { toast } from "react-toastify";
import { useLocation } from "react-router-dom";
const Depositos = () => {
-
- const { id: idUrl } = useParams();
- const loc = useLocation();
-
- let id = null;
-
- if (loc.state?.id) {
- id = loc.state.id; // prioridade para o que veio no state
- } else {
- id = idUrl; // se não tiver no state, pega da URL
- }
-
- console.log(id)
-
- const [pointData, setPointData] = useState({
- name: "",
- location: "",
- amountSponges: 0,
- capacitySponges: 0,
- isInactive: 0
- })
- const [depositAmount, setDepositAmount] = useState(0);
- const [, setImageURL] = useState("");
- const [preview, setPreview] = useState(null);
- const [imageFile, setImageFile] = useState(null); // arquivo real
- const [modalRegisterDeposit, setModalRegisterDeposit] = useState(false);
-
- const nav = useNavigate();
-
- const handleClose = () => {
- setImageURL(null);
- setPreview(null);
- setDepositAmount(0);
- setModalRegisterDeposit(false);
- }
-
- const handleImageUpload = (event) => {
- const file = event.target.files[0];
- if (file) {
- setImageFile(file); // guarda o arquivo real
- setPreview(URL.createObjectURL(file)); // gera preview
- }
- }
-
- const handleImageDeletion = () => {
- setPreview(null);
- setImageURL(null);
- }
-
- async function getCollectionPointData() {
- try {
- let req = await api.get(`/collectionPoint/${id}`);
-
- if(req.status == 200) {
- setPointData({
- name: req.data.name,
- location: req.data.location,
- amountSponges: req.data.amountSponges,
- capacitySponges: req.data.capacitySponges,
- isInactive: req.data.isInactive
- })
- }
- } catch(error) {
-
- console.log(error);
- if(error.response){
- setTimeout(()=>{
- toast.error(error.response.data.message);
- },1000);
- }else{
- setTimeout(()=>{
- toast.error('Servidor não respondeu. Verifique sua conexão ou tente mais tarde.');
- },1000);
- }
- }
+ const { id: idUrl } = useParams();
+ const loc = useLocation();
+
+ let id = null;
+
+ if (loc.state?.id) {
+ id = loc.state.id; // prioridade para o que veio no state
+ } else {
+ id = idUrl; // se não tiver no state, pega da URL
+ }
+
+ console.log(id);
+
+ const [pointData, setPointData] = useState({
+ name: "",
+ location: "",
+ amountSponges: 0,
+ capacitySponges: 0,
+ isInactive: 0,
+ });
+ const [depositAmount, setDepositAmount] = useState(0);
+ const [, setImageURL] = useState("");
+ const [preview, setPreview] = useState(null);
+ const [imageFile, setImageFile] = useState(null); // arquivo real
+ const [modalRegisterDeposit, setModalRegisterDeposit] = useState(false);
+
+ const nav = useNavigate();
+
+ const handleClose = () => {
+ setImageURL(null);
+ setPreview(null);
+ setDepositAmount(0);
+ setModalRegisterDeposit(false);
+ };
+
+ const handleImageUpload = (event) => {
+ const file = event.target.files[0];
+ if (file) {
+ setImageFile(file); // guarda o arquivo real
+ setPreview(URL.createObjectURL(file)); // gera preview
}
-
- const handleSubmit = () => {
- if(depositAmount >= 1) {
- registerDeposit();
- } else toast.error("Insira um valor de depósito válido!")
+ };
+
+ const handleImageDeletion = () => {
+ setPreview(null);
+ setImageURL(null);
+ };
+
+ async function getCollectionPointData() {
+ try {
+ let req = await api.get(`/collectionPoint/${id}`);
+
+ if (req.status == 200) {
+ setPointData({
+ name: req.data.name,
+ location: req.data.location,
+ amountSponges: req.data.amountSponges,
+ capacitySponges: req.data.capacitySponges,
+ isInactive: req.data.isInactive,
+ });
+ }
+ } catch (error) {
+ console.log(error);
+ if (error.response) {
+ setTimeout(() => {
+ toast.error(error.response.data.message);
+ }, 1000);
+ } else {
+ setTimeout(() => {
+ toast.error(
+ "Servidor não respondeu. Verifique sua conexão ou tente mais tarde."
+ );
+ }, 1000);
+ }
}
-
- async function registerDeposit() {
- const formData = new FormData();
- formData.append("depositData", JSON.stringify({ amountSponges: depositAmount }));
- formData.append('comprovante', imageFile);
-
- try {
-
- let req = await api.post(`/deposit/${id}`, formData );
-
- if(req.status == 201){
- toast.success("Depósito registrado com sucesso!");
- setTimeout(() => {
- nav('/home');
- }, 2000)
- }
- } catch(error) {
- if(error.response){
- setTimeout(()=>{
- toast.error(error.response.data.message);
- },1000);
- }else{
- setTimeout(()=>{
- toast.error('Servidor não respondeu. Verifique sua conexão ou tente mais tarde.');
- },1000);
- }
-
- }
+ }
+
+ const handleSubmit = () => {
+ if (depositAmount >= 1) {
+ registerDeposit();
+ } else toast.error("Insira um valor de depósito válido!");
+ };
+
+ async function registerDeposit() {
+ const formData = new FormData();
+ formData.append(
+ "depositData",
+ JSON.stringify({ amountSponges: depositAmount })
+ );
+ formData.append("comprovante", imageFile);
+
+ try {
+ let req = await api.post(`/deposit/${id}`, formData);
+
+ if (req.status == 201) {
+ toast.success("Depósito registrado com sucesso!");
+ setTimeout(() => {
+ nav("/home");
+ }, 2000);
+ }
+ } catch (error) {
+ if (error.response) {
+ setTimeout(() => {
+ toast.error(error.response.data.message);
+ }, 1000);
+ } else {
+ setTimeout(() => {
+ toast.error(
+ "Servidor não respondeu. Verifique sua conexão ou tente mais tarde."
+ );
+ }, 1000);
+ }
}
-
- useEffect(() => {
- getCollectionPointData();
- },[])
-
- return (
- <>
-
-
-
Ponto de Coleta: {pointData.name}
-
+ }
+
+ const validDigits = (text) => {
+ return text.replace(/[^0-9,]/g, "");
+ };
+
+ useEffect(() => {
+ getCollectionPointData();
+ }, []);
+
+ return (
+ <>
+
+
+
Ponto de Coleta: {pointData.name}
+
+
+
Este ponto de coleta está localizado em {pointData.location}.
+
+ Obs: Lembre-se de conferir se este é realmente o ponto de coleta
+ que você está.
+
+
+
+ Situação: {pointData.isInactive ? "Inativo" : "Ativo"}
+
+
+
+ {pointData.amountSponges == pointData.capacitySponges ? (
+
+ Este ponto de coleta está cheio!
+
+ ) : (
+
+ )}
+
+
+
+ {modalRegisterDeposit && (
+
+ )}
- {modalRegisterDeposit &&
-
- }
-
-
- >
- )
-}
+
+ >
+ );
+};
-export default Depositos;
\ No newline at end of file
+export default Depositos;
diff --git a/frontend/src/pages/principal_Interna/Home.jsx b/frontend/src/pages/principal_Interna/Home.jsx
index 8264d5c..1fce3ec 100644
--- a/frontend/src/pages/principal_Interna/Home.jsx
+++ b/frontend/src/pages/principal_Interna/Home.jsx
@@ -14,124 +14,112 @@ import { toast } from "react-toastify";
import { UserContext } from "../../components/Context/userContext";
function Home() {
- const [esponge, setEsponge] = useState(false);
- const [muti, setMuti] = useState(false);
- const [adress, setAdress] = useState({ street: '', lat: '', long: '' });
- const [point, setPoint] = useState([]);
+ const [pointSection, setPointSection] = useState(false);
+ const [eventSection, setEventSection] = useState(false);
+ const [mapAddress, setMapAddress] = useState({ street: "", lat: "", long: "" });
+ const [points, setPoints] = useState([]);
const [donations, setDonations] = useState([]);
- const { client, token } = useContext(UserContext);
+ const [events, setEvents] = useState([]);
const [showAllDonations, setShowAllDonations] = useState(false);
const [showAllPoints, setShowAllPoints] = useState(false);
- const coletaSectionRef = useRef(null);
+ const { client, token } = useContext(UserContext);
+
+ const coletaSectionRef = useRef(null);
- function changePageEsponge(e) {
+ function changePagePoint(e) {
e.preventDefault();
- setEsponge(true);
- setMuti(false);
+ setPointSection(true);
+ setEventSection(false);
setTimeout(() => {
coletaSectionRef.current?.scrollIntoView({ behavior: "smooth" });
- }, 100);
+ }, 100);
}
- /*function changePageMuti(e) {
+ function changePageEvent(e) {
e.preventDefault();
- setEsponge(false);
- setMuti(true);
+ setPointSection(false);
+ setEventSection(true);
}
- const dados = [
- {
- idx: 1,
- num: 20,
- place: "Rua Gen. Canabarro - Maracanã",
- date: "19/03/2025",
- hour: "14:35",
- state: "presente",
- },
- {
- idx: 2,
- num: 20,
- place: "Rua Sambaetiba - Padre Miguel, n44",
- date: "19/03/2025",
- hour: "14:35",
- state: "analise"
- },
- {
- idx: 3,
- num: 20,
- place: "Norte Shopping",
- date: "19/03/2025",
- hour: "14:35",
- state: "presente"
- },
- {
- idx: 4,
- num: 20,
- place: "Rua Canabarro, n100",
- date: "19/03/2025",
- hour: "14:35",
- state: "faltou"
- },
- ];*/
-
- async function dadosDeps() {
+ async function getScheduledEvents() {
try {
- const req = await api.get("/deposits");
-
+ const req = await api.get("/events/scheduled");
if (req.status === 200) {
- setDonations(req.data);
+ setEvents(req.data);
}
- } catch (err) {
- if(err.response){
- if(err.response.status === 404){
- setTimeout(() => {
- //toast.info("Você ainda não fez nenhum depósito. Que tal começar agora e ajudar o planeta 🌍 ♻️", { autoClose: 3000 });
- }, 1000);
- }else{
- setTimeout(() => {
- toast.error(err.response.data.message);
+ } catch (e) {
+ if (e.response) {
+ setTimeout(() => {
+ toast.error(err.response.data.message);
}, 1000);
- }
- }else{
+ } else {
setTimeout(() => {
- toast.error('Servidor não respondeu. Verifique sua conexão ou tente mais tarde.');
+ toast.error(
+ "Servidor não respondeu. Verifique sua conexão ou tente mais tarde."
+ );
}, 1000);
}
-
+ }
+ }
+ async function getDeposits() {
+ try {
+ const req = await api.get("/deposits");
+
+ if (req.status === 200) {
+ setDonations(req.data);
+ }
+ } catch (err) {
+ if(!(err.response.status === 404)) {
+ toast.error(err.response?.data?.message || "Servidor não respondeu. Verifique sua conexão ou tente mais tarde.")
+ console.log(err);
+ }
}
}
- async function getColectData() {
+ async function getCollectionPoints() {
try {
- const req = await api.get('/collectionPoints');
- setPoint(req.data);
+ const req = await api.get("/collectionPoints");
+ console.log(await api.get("/collectionPoints"));
+ setPoints(req.data);
} catch (error) {
- if(error.response){
- if(error.response.status === 404){
- //se o usuario nao tiver dados de coleta ele não mostra nada no toast
- }else{
- setTimeout(() => {
- toast.error(error.response.data.message);
- }, 1000);
- }
-
-
- }else{
- setTimeout(() => {
- toast.error('Servidor não respondeu. Verifique sua conexão ou tente mais tarde.');
- }, 1000);
+ if(!(error.response.status === 404)) {
+ toast.error(error.response?.data?.message || "Servidor não respondeu. Verifique sua conexão ou tente mais tarde.");
+ console.log(error);
}
}
+ console.log(points);
}
useEffect(() => {
- if(token){
- getColectData();
- dadosDeps();
+ if (token) {
+ getCollectionPoints();
+ getDeposits();
+ getScheduledEvents();
}
}, [token]);
+ const convertDate = (date) => {
+ const dateUTC = new Date(date);
+ dateUTC.setHours(dateUTC.getHours() + 3);
+
+ // Data no horário de Brasília
+ const brasiliaDate = dateUTC.toLocaleDateString("pt-BR", {
+ day: "2-digit",
+ month: "2-digit",
+ year: "numeric",
+ timeZone: "America/Sao_Paulo",
+ });
+
+ // Hora no horário de Brasília
+ const hour = dateUTC.toLocaleTimeString("pt-BR", {
+ hour: "2-digit",
+ minute: "2-digit",
+ hour12: false,
+ timeZone: "America/Sao_Paulo",
+ });
+ return { brasiliaDate, hour };
+ };
return (
<>
@@ -140,209 +128,252 @@ function Home() {
- Escolha o que deseja fazer a seguir:
+
+ {" "}
+ Escolha o que deseja fazer a seguir:
+
-
-
+
+
- {esponge && (
+ {pointSection && (
<>
-
- Minhas doações recentes
-
- {donations?.deposits?.length > 0 ? (
- <>
- {(showAllDonations
- ? donations.deposits
- : donations.deposits.slice(0, 4)
- ).map((dado) => {
-
- const dateUTC = new Date(dado.created_at);
-
- // Data no horário de Brasília
- const brasiliaDate = dateUTC.toLocaleDateString('pt-BR', {
- day: '2-digit',
- month: '2-digit',
- year: 'numeric',
- timeZone: 'America/Sao_Paulo',
- });
-
- // Hora no horário de Brasília
- const hour = dateUTC.toLocaleTimeString('pt-BR', {
- hour: '2-digit',
- minute: '2-digit',
- hour12: false,
- timeZone: 'America/Sao_Paulo'
- });
-
- const location = point.find((p) => p.id === dado.collectionPointId);
+
+ Minhas doações recentes
+
+ {donations?.deposits?.length > 0 ? (
+ <>
+ {(showAllDonations
+ ? donations.deposits
+ : donations.deposits.slice(0, 4)
+ ).map((dado) => {
+ const { brasiliaDate, hour } = convertDate(dado.created_at);
+
+ const location = points.find(
+ (p) => p.id === dado.collectionPointId
+ );
+
+ return (
+
+ );
+ })}
+ >
+ ) : (
+ Nenhuma doação encontrada.
+ )}
+
- return (
-
- );
- })}
- >
- ) : (
- Nenhuma doação encontrada.
+ {donations?.deposits?.length > 4 && (
+
+
+
)}
-
-
- {donations?.deposits?.length > 4 && (
-
-
-
- )}
-
-
-
-
- Pontos de Coleta
-
- {(showAllPoints ? point : point.slice(0, 4)).map((dado) => (
-
- ))}
-
+
- {point.length > 4 && (
-
-
-
- )}
-
+
+ Pontos de Coleta
+
+ {(showAllPoints ? points : points.slice(0, 4)).map((dado) => (
+
+ ))}
+
+ {points.length > 4 && (
+
+
+
+ )}
+
>
)}
- {/**
- *
- * {muti && (
+ {eventSection && (
<>
-
+ {/*
Minhas Inscrições
{dados.map((dado) => (
))}
-
+ */}
Próximos mutirões
-
- {dados.map((dado) => (
-
- ))}
+
+ {events
+ ?.sort((a, b) => {
+ const tzA = new Date(a.date);
+ const tzB = new Date(b.date);
+ return tzA - tzB;
+ })
+ .map((evento) => {
+ const { brasiliaDate, hour } = convertDate(evento.date);
+
+ return (
+
+ );
+ })}
>
)}
- */}
- {!esponge && !muti && (
+ {!pointSection && !eventSection && (
<>
-
- Minhas doações recentes
-
- {donations?.deposits?.length > 0 ? (
- <>
- {(showAllDonations
- ? donations.deposits
- : donations.deposits.slice(0, 4)
- ).map((dado) => {
- const dateUTC = new Date(dado.created_at);
-
- // Data no horário de Brasília
- const brasiliaDate = dateUTC.toLocaleDateString('pt-BR', {
- day: '2-digit',
- month: '2-digit',
- year: 'numeric',
- timeZone: 'America/Sao_Paulo',
- });
-
- // Hora no horário de Brasília
- const hour = dateUTC.toLocaleTimeString('pt-BR', {
- hour: '2-digit',
- minute: '2-digit',
- hour12: false,
- timeZone: 'America/Sao_Paulo'
- });
- const location = point.find((p) => p.id === dado.collectionPointId);
- return (
-
- );
- })}
- >
- ) : (
- Nenhuma doação encontrada.
- )}
-
-
- {donations?.deposits?.length > 4 && (
-
-
-
- )}
-
+
+ Minhas doações recentes
+
+ {donations?.deposits?.length > 0 ? (
+ <>
+ {(showAllDonations
+ ? donations.deposits
+ : donations.deposits.slice(0, 4)
+ ).map((dado) => {
+ const { brasiliaDate, hour } = convertDate(dado.created_at);
+ const location = points.find(
+ (p) => p.id === dado.collectionPointId
+ );
+ return (
+
+ );
+ })}
+ >
+ ) : (
+ Nenhuma doação encontrada.
+ )}
+
+ {donations?.deposits?.length > 4 && (
+
+
+
+ )}
+
- {/**
+
Próximos mutirões
-
- {dados.map((dado) => (
-
- ))}
+
+ {events
+ ?.sort((a, b) => {
+ const tzA = new Date(a.date).getTime();
+ const tzB = new Date(b.date).getTime();
+ return tzA - tzB;
+ })
+ .map((evento) => {
+ const { brasiliaDate, hour } = convertDate(evento.date);
+
+ return (
+
+ );
+ })}
- */}
+
>
)}