Skip to content

Commit

Permalink
Merge pull request #229 from agiledev-students-fall2023/Event_main
Browse files Browse the repository at this point in the history
Event main
  • Loading branch information
elaineZhang67 authored Dec 7, 2023
2 parents c3be6e3 + 30db521 commit 26d704e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 52 deletions.
9 changes: 4 additions & 5 deletions front-end/src/components/AddEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ function AddEvent({ addEvent, onClose }) {
if (decodedUser && decodedUser.id) {
friendsCL(decodedUser.id);
setselectedMember((prevMembers) => {
// Check if the current user's ID is already in the selected members
if (prevMembers.some((member) => member.id === decodedUser.id)) {
return prevMembers;
// Correctly check if the user ID is already in the array
if (!prevMembers.includes(decodedUser.id)) {
return [...prevMembers, decodedUser.id];
}
// Add the current user's ID to the selected members
return [...prevMembers, decodedUser.id];
return prevMembers;
});
} else {
}
Expand Down
28 changes: 13 additions & 15 deletions front-end/src/components/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,27 @@ const Event = (props) => {
const isDarkMode = props.isDarkMode;
const { eventId } = useParams();


function reformatDate(dateStr) {

const months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];

// Create a new Date object in local time zone
const date = new Date(dateStr);

const monthName = months[date.getMonth()];
const day = date.getDate();

// Convert it back to UTC
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());

const monthName = months[date.getUTCMonth()];
const day = date.getUTCDate();

return `${monthName} ${day}`;
}


// This effect runs when the `isDarkMode` value changes
useEffect(() => {
if (isDarkMode) {
Expand Down
29 changes: 13 additions & 16 deletions front-end/src/components/Events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@ function Events({ isDarkMode }) {
const [searchTerm, setSearchTerm] = useState("");

function reformatDate(dateStr) {

const months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];

// Create a new Date object in local time zone
const date = new Date(dateStr);

const monthName = months[date.getMonth()];
const day = date.getDate();
const year = date.getFullYear();

// Convert it back to UTC
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());

const monthName = months[date.getUTCMonth()];
const day = date.getUTCDate();
const year = date.getUTCFullYear();

return `${monthName} ${day} ${year}`;
}


// Toggle the 'body-dark-mode' class on the body element
useEffect(() => {
if (isDarkMode) {
Expand Down
30 changes: 14 additions & 16 deletions front-end/src/components/Expense.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,28 @@ function Expense({ isDarkMode }) {
const navigate = useNavigate();
const { expenseId } = useParams();


function reformatDate(dateStr) {

const months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];

// Create a new Date object in local time zone
const date = new Date(dateStr);

const monthName = months[date.getMonth()];
const day = date.getDate();
const year = date.getFullYear();

// Convert it back to UTC
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());

const monthName = months[date.getUTCMonth()];
const day = date.getUTCDate();
const year = date.getUTCFullYear();

return `${monthName} ${day} ${year}`;
}


const fetchData = async () => {
try {
const response = await axios.get(
Expand Down

0 comments on commit 26d704e

Please sign in to comment.