Skip to content
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
6 changes: 4 additions & 2 deletions client/src/components/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface EventCardProps {
vendors?: Vendor[];
price?: number;
showActions?: boolean;
showShareButton?: boolean;
showDetailedView?: boolean;
showAttendees?: boolean;
showRegisterButton?: boolean;
Expand Down Expand Up @@ -196,6 +197,7 @@ export default function EventCard({
registrationDeadline,
vendors = [],
showActions = true,
showShareButton = true,
showDetailedView = false,
showAttendees = true,
showRegisterButton = true,
Expand Down Expand Up @@ -1685,7 +1687,7 @@ export default function EventCard({
<FavoriteButton eventId={id} />
</div>
)}
{inlineShareButton && (
{showShareButton && inlineShareButton && (
<div className="order-4">
<ShareButton />
</div>
Expand Down Expand Up @@ -1742,7 +1744,7 @@ export default function EventCard({
</Button>
)}

{!inlineShareButton && (
{showShareButton && !inlineShareButton && (
<div className="flex items-center gap-2 ml-auto">
<ShareButton />
</div>
Expand Down
44 changes: 32 additions & 12 deletions client/src/components/EventsDetailsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,40 @@ export default function EventDetailsDialog({

const startTime =
formatStringTime(event.startTime) ||
(event.startDate
? new Date(event.startDate).toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
})
: null);
(() => {
if (!event.startDate) return null;
const date = new Date(event.startDate);
if (
date.getHours() === 0 &&
date.getMinutes() === 0 &&
date.getSeconds() === 0
) {
return null;
}
return date.toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
hour12: true,
});
})();
const endTime =
formatStringTime(event.endTime) ||
(event.endDate
? new Date(event.endDate).toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
})
: null);
(() => {
if (!event.endDate) return null;
const date = new Date(event.endDate);
if (
date.getHours() === 0 &&
date.getMinutes() === 0 &&
date.getSeconds() === 0
) {
return null;
}
return date.toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
hour12: true,
});
})();

const startDateStr = formatDate(event.startDate);
const endDateStr = formatDate(event.endDate);
Expand Down
2 changes: 2 additions & 0 deletions client/src/lib/favoritesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface FavoriteEvent {
location: string;
startDate: string;
endDate: string;
startTime?: string;
endTime?: string;
bannerImage?: string;
status: string;
eventType?: string;
Expand Down
45 changes: 44 additions & 1 deletion client/src/pages/FavoritesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,47 @@ export default function FavoritesPage() {
});
};

// Convert a stored 24-hour time string (e.g. "14:05") to 12-hour ("2:05 PM")
const formatStringTime = (timeStr?: string) => {
if (!timeStr) return null;
if (/^\d{1,2}:\d{2}$/.test(timeStr)) {
const [hoursStr, minutesStr] = timeStr.split(":");
let hours = parseInt(hoursStr, 10);
const suffix = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
return `${hours}:${minutesStr} ${suffix}`;
}
return timeStr;
};

const getEventTimeLabel = (event: any) => {
const start = formatStringTime(event?.startTime);
const end = formatStringTime(event?.endTime);

// If we don't have explicit times, only derive a time from Date fields
// when the Date actually contains a non-midnight time component.
const deriveTimeFromDateIfMeaningful = (dateString?: string) => {
if (!dateString) return null;
const date = new Date(dateString);
if (
date.getHours() === 0 &&
date.getMinutes() === 0 &&
date.getSeconds() === 0
) {
return null;
}
return formatEventTime(dateString);
};

const startLabel =
start || deriveTimeFromDateIfMeaningful(event?.startDate);
const endLabel = end || deriveTimeFromDateIfMeaningful(event?.endDate);

if (startLabel && endLabel) return `${startLabel} - ${endLabel}`;
return startLabel || "";
};

const formatBoothDate = (event: any) => {
// If platform booth has startDate and endDate, show dates
if (event.startDate && event.endDate) {
Expand Down Expand Up @@ -211,7 +252,7 @@ export default function FavoritesPage() {
time={
isBoothEvent && !event.startDate
? ""
: formatEventTime(event.startDate)
: getEventTimeLabel(event)
}
location={
event.location ||
Expand All @@ -225,6 +266,8 @@ export default function FavoritesPage() {
description={event.description}
startDate={event.startDate}
endDate={event.endDate}
dbStartTime={event.startTime}
dbEndTime={event.endTime}
durationWeeks={event.durationWeeks}
showActions={true}
showDetailedView={false}
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/MyEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export default function MyEvents() {
endDate={event.endDate}
durationWeeks={event.durationWeeks}
showActions={true}
showShareButton={false}
isRegistered={true}
hideRegisterButton={
userRole === "student" ||
Expand Down
2 changes: 0 additions & 2 deletions server/src/features/facilities/facility.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class FacilitiesServiceClass {

if (bookingDate < today) throw new Error("Cannot book a past date");

const formattedDate = this.getLocalDateString(bookingDate);

// Check availability directly
const existingBooking = await CourtBooking.findOne({
courtType,
Expand Down
2 changes: 1 addition & 1 deletion server/src/features/users/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class UserService {
.populate({
path: "favoriteEvents",
select:
"name description location locationPreference startDate endDate bannerImage status eventType type category durationWeeks attendees attendeesCount application archivedAt", // Added archivedAt
"name description location locationPreference startDate endDate startTime endTime bannerImage status eventType type category durationWeeks attendees attendeesCount application archivedAt", // Added archivedAt
match: {
deletedAt: null,
archivedAt: null, // ✅ Exclude archived events
Expand Down
Loading