From 8e7fa8bcb58e5880809f8e446628f8c78017f1e3 Mon Sep 17 00:00:00 2001 From: "James A. Manon-og" Date: Sun, 18 Jan 2026 01:47:56 +0800 Subject: [PATCH] refactor: improve event price display logic and update EventCard component --- app/(main)/events/[id]/page.tsx | 32 +++++----- app/(main)/events/page.tsx | 53 ++++++++++------ components/EventCard.tsx | 104 +++++++++++++++----------------- lib/utils/event-priceUtils.ts | 19 ++++++ 4 files changed, 121 insertions(+), 87 deletions(-) create mode 100644 lib/utils/event-priceUtils.ts diff --git a/app/(main)/events/[id]/page.tsx b/app/(main)/events/[id]/page.tsx index a38239a..670c7f9 100644 --- a/app/(main)/events/[id]/page.tsx +++ b/app/(main)/events/[id]/page.tsx @@ -10,6 +10,7 @@ import { format } from "date-fns"; import Link from "next/link"; import Image from "next/image"; import { EventRegistrationModal } from "@/components/EventRegistrationModal"; +import { getEventPriceDisplay } from "@/lib/utils/event-priceUtils"; const EventDetailsPage = ({ params }: { params: { id: string } }) => { const { id } = params; @@ -52,9 +53,12 @@ const EventDetailsPage = ({ params }: { params: { id: string } }) => {
-

Event Not Found

+

+ Event Not Found +

- The event you're looking for doesn't exist or has been removed. + The event you're looking for doesn't exist or has been + removed.

{/* Event Description */}
-

Event Description

+

+ Event Description +

{descriptionPreview}
@@ -207,7 +208,10 @@ const EventDetailsPage = ({ params }: { params: { id: string } }) => {
@@ -215,7 +225,9 @@ const EventsContent = () => {

{events.data.length} Events Found

-

Discover events that match your interests

+

+ Discover events that match your interests +

@@ -223,13 +235,17 @@ const EventsContent = () => { {
-

No events found

+

+ No events found +

- Try adjusting your search criteria or filters to find more events. + Try adjusting your search criteria or filters to find more + events.

diff --git a/components/EventCard.tsx b/components/EventCard.tsx index 045f7d8..387d3c0 100644 --- a/components/EventCard.tsx +++ b/components/EventCard.tsx @@ -1,14 +1,12 @@ "use client"; import * as React from "react"; -import { Calendar, Clock, Users } from "lucide-react"; +import { Calendar, Clock } from "lucide-react"; import Image from "next/image"; import { cn } from "@/lib/utils"; import { Card } from "@/components/ui/card"; -import { Badge } from "@/components/ui/badge"; import { useRouter } from "next/navigation"; - interface EventCardProps extends React.HTMLAttributes { id: string; title?: string; @@ -28,6 +26,7 @@ const EventCard = React.forwardRef( organization, dateRange, timeRange, + price, imageUrl, ...props }, @@ -37,11 +36,12 @@ const EventCard = React.forwardRef( const handleRedirectToDetails = () => { router.push(`/events/${id}`); }; + return ( ( )}
- - {organization && ( -
- - {organization} - -
- )}
-
-
-

- {title || "Event Title"} -

-
- -
-
- -
-

+

+
+
+
+ +

{dateRange || "DD-MMM-YYYY to DD-MMM-YYYY"}

-
-
- -
-

+

+ +

{timeRange || "00:00 AM to 00:00 AM"}

-
-
handleRedirectToDetails()} - > -
- - Join Event -
-
- - - -
+
+

+ {title || "Event Title"} +

+

+ {organization || "Organization Name"} +

+
+ +
handleRedirectToDetails()} + > +
+ + Price + + + {price || "Free"} + +
+
+ + +
diff --git a/lib/utils/event-priceUtils.ts b/lib/utils/event-priceUtils.ts new file mode 100644 index 0000000..afc5f61 --- /dev/null +++ b/lib/utils/event-priceUtils.ts @@ -0,0 +1,19 @@ +import type { TicketCategory } from "@/client/types/entities"; + +export const getEventPriceDisplay = ( + ticketCategories?: TicketCategory[] +): string => { + if (!ticketCategories || ticketCategories.length === 0) return "Free"; + + const prices = ticketCategories.map((tc) => tc.price); + const minPrice = Math.min(...prices); + const maxPrice = Math.max(...prices); + + if (maxPrice === 0) return "Free"; + + if (minPrice === maxPrice) return `Php ${minPrice}.00`; + + if (minPrice === 0) return `Free - Php ${maxPrice}.00`; + + return `Php ${minPrice}.00 - ${maxPrice}.00`; +};