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

Task #0000:Commented poll update logic #469

Merged
merged 3 commits into from
Aug 10, 2024
Merged
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
4 changes: 3 additions & 1 deletion packages/nulp_elite/src/configs/urlConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@
"REPORT": "/custom_event/reports",
"CUSTOM_ENROLL_LIST": "/custom_event/enrollment-list",
"UNREGISTER": "custom_event/unregister",
"UPDATE_REGISTER": "custom_event/registration/update"
"UPDATE_REGISTER": "custom_event/registration/update",
"CUSTOM_COMPOSITE_SEARCH": "/custom_event/composite/search",
"READ_BY_ID": "/custom_event/read/event"
},
"POLL": {
"CREATE": "/polls/create",
Expand Down
24 changes: 11 additions & 13 deletions packages/nulp_elite/src/pages/events/eventDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
const consenttext = require("../../configs/consent.json");
const urlConfig = require("../../configs/urlConfig.json");
const designations = require("../../configs/designations.json");
const recording = require("../../assets/eventRecording.json")
const recording = require("../../assets/eventRecording.json");

import {
FacebookShareButton,
Expand Down Expand Up @@ -167,12 +167,10 @@ const EventDetails = () => {
fetchUserData();
const fetchData = async () => {
try {
const url = `${urlConfig.URLS.PUBLIC_PREFIX}${urlConfig.URLS.CUSTOM_EVENT.READ}/${eventId}`;
const url = `${urlConfig.URLS.CUSTOM_EVENT.READ_BY_ID}?eventId=${eventId}`;
const response = await fetch(url, {
headers: {
"Content-Type": "application/json",
Authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzVGRIUkFpTUFiRHN1SUhmQzFhYjduZXFxbjdyQjZrWSJ9.MotRsgyrPzt8O2jp8QZfWw0d9iIcZz-cfNYbpifx5vs",
},
});
if (!response.ok) {
Expand Down Expand Up @@ -626,15 +624,15 @@ const EventDetails = () => {
};

const getEventRecording = async () => {
try {
const url = "/custom_event/fetch_recordings?event_id=" + eventId;
const response = await axios.get(url);
console.log("---------------Recording Link", response.data);
console.log("Recording Hardcoded Data",recording);
} catch (error) {
console.error("Error fetching recording:", error);
}
};
try {
const url = "/custom_event/fetch_recordings?event_id=" + eventId;
const response = await axios.get(url);
console.log("---------------Recording Link", response.data);
console.log("Recording Hardcoded Data", recording);
} catch (error) {
console.error("Error fetching recording:", error);
}
};

return (
<div>
Expand Down
4 changes: 1 addition & 3 deletions packages/nulp_elite/src/pages/events/eventList.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,11 @@ const EventList = (props) => {

const headers = {
"Content-Type": "application/json",
Authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzVGRIUkFpTUFiRHN1SUhmQzFhYjduZXFxbjdyQjZrWSJ9.MotRsgyrPzt8O2jp8QZfWw0d9iIcZz-cfNYbpifx5vs",
};
// console.log(data.result.content)

try {
const url = `${urlConfig.URLS.PUBLIC_PREFIX}${urlConfig.URLS.COMPOSITE.SEARCH}`;
const url = `${urlConfig.URLS.CUSTOM_EVENT.CUSTOM_COMPOSITE_SEARCH}`;
const response = await getAllContents(url, data, headers);
console.log("All Event ----", response.data.result.Event);
setData(response.data.result.Event);
Expand Down
46 changes: 23 additions & 23 deletions packages/nulp_elite/src/pages/voting/votingDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,29 @@ const VotingDetails = () => {
const queryString = location.search;
const pollId = queryString.startsWith("?do_") ? queryString.slice(1) : null;

useEffect(() => {
// Ensure startDate is parsed as UTC and then converted to local time
const startDateLocal = moment.utc(startDate).local();
console.log("startDate:----", startDateLocal);
// Check if the current time has passed the start date
if (moment().isAfter(startDateLocal)) {
if (!updateFlag) {
setUpdateFlag(true);
// Send update to the backend
fetch(`${urlConfig.URLS.POLL.UPDATE}?poll_id=${pollId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
body: JSON.stringify({ status: "Live" }),
})
.then((response) => response.json())
.then((data) => console.log("Success:", data))
.catch((error) => console.error("Error:", error));
}
}
}, [currentTime, startDate, pollId, updateFlag]);
// useEffect(() => {
// // Ensure startDate is parsed as UTC and then converted to local time
// const startDateLocal = moment.utc(startDate).local();
// console.log("startDate:----", startDateLocal);
// // Check if the current time has passed the start date
// if (moment().isAfter(startDateLocal)) {
// if (!updateFlag) {
// setUpdateFlag(true);
// // Send update to the backend
// fetch(`${urlConfig.URLS.POLL.UPDATE}?poll_id=${pollId}`, {
// method: "PUT",
// headers: {
// "Content-Type": "application/json",
// },
// credentials: "include",
// body: JSON.stringify({ status: "Live" }),
// })
// .then((response) => response.json())
// .then((data) => console.log("Success:", data))
// .catch((error) => console.error("Error:", error));
// }
// }
// }, [currentTime, startDate, pollId, updateFlag]);

useEffect(() => {
if (pollId) {
Expand Down
Loading