Skip to content

Commit

Permalink
Merge pull request #7 from FGA0138-MDS-Ajax/CalendarAtt
Browse files Browse the repository at this point in the history
fix: fix no render do react não chamando um getEventos a cada mudança…
  • Loading branch information
Felipe-Brandim authored Jul 1, 2024
2 parents 2a5d79e + c91416f commit 86001f6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 13 deletions.
27 changes: 14 additions & 13 deletions view/src/pages/Calendar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ const Calendar = () => {
}).then(function (response) {
if (!(response.data < 0)) {
axios.get("http://localhost:3000/users/" + response.data.id).then(function (resposta) {
if (resposta.data.acesso.acesso_calendar) {
} else {
if (!resposta.data.acesso.acesso_calendar){
navigate("/detail");
}
});
Expand All @@ -101,27 +100,27 @@ const Calendar = () => {
navigate("/login");
}


const loadEvents = async () => {
const events = await fetchEvents();
setEventsArr(events);
initCalendar();
listMonthEvents();
};

loadEvents();
}, []);

useEffect(() => {
/*useEffect(() => {
initCalendar();
listMonthEvents();
}, [month, year, eventsArr]);
loadEvents();
}, [month, year, eventsArr]);*/

const months = [
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho",
"Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
];

const loadEvents = async () => {
const events = await fetchEvents();
setEventsArr(events);
initCalendar();
listMonthEvents();
};

const weekdays = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"];

const initCalendar = () => {
Expand Down Expand Up @@ -345,13 +344,15 @@ const Calendar = () => {
// Ocorreu um erro ao fazer a solicitação
//console.error("Erro ao criar documento:", error);
});
loadEvents()

};

function deletaEvento(id){
axios.post("http://localhost:3000/eventos/delete",{
id: id
id: id
});
loadEvents()
updateEvents();
}

Expand Down
52 changes: 52 additions & 0 deletions view/src/queries/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import server from "../config/axiosInstance";
import endpoints from "../constants/endpoints";

export const getActions = async () => {
try {
const action = await server.get(endpoints.action.base);
return action;
} catch (error) {
console.log(error);
throw error;
}
};

export const getSingleActions = async (actionId) => {
try {
const action = await server.get(endpoints.action.single(actionId));
return action;
} catch (error) {
console.log(error);
throw error;
}
};

export const createAction = async (data) => {
try {
const action = await server.post(endpoints.action.base, data);
return action;
} catch (error) {
console.log(error);
throw error;
}
};

export const editAction = async (actionId, data) => {
try {
const action = await server.put(endpoints.action.single(actionId), data);
return action;
} catch (error) {
console.log(error);
throw error;
}
};

export const deleteAction = async (actionId) => {
try {
const action = await server.delete(endpoints.action.single(actionId));
return action;
} catch (error) {
console.log(error);
throw error;
}
};

0 comments on commit 86001f6

Please sign in to comment.