diff --git a/components/page/irl/events/irl-past-events.tsx b/components/page/irl/events/irl-past-events.tsx index ea90741d..09ee8b5c 100644 --- a/components/page/irl/events/irl-past-events.tsx +++ b/components/page/irl/events/irl-past-events.tsx @@ -26,7 +26,6 @@ interface EventDetailsProps { } const IrlPastEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, handleDataNotFound }: EventDetailsProps) => { - const dialogRef = useRef(null); const dropdownRef = useRef(null); const { updateQueryParams } = useUpdateQueryParams(); @@ -58,8 +57,8 @@ const IrlPastEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, han if (gathering.slugURL !== searchParams?.event) { triggerLoader(true); const currentParams = new URLSearchParams(searchParams); - const allowedParams = ['event', 'type', 'location']; - + const allowedParams = ['event', 'type', 'location']; + // Remove parameters not in the allowed list for (const [key, value] of Object.entries(searchParams)) { if (!allowedParams.includes(key)) { @@ -87,8 +86,8 @@ const IrlPastEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, han triggerLoader(true); selectedEvent = gathering; const currentParams = new URLSearchParams(searchParams); - const allowedParams = ['event', 'type', 'location']; - + const allowedParams = ['event', 'type', 'location']; + // Remove parameters not in the allowed list for (const [key, value] of Object.entries(searchParams)) { if (!allowedParams.includes(key)) { @@ -146,12 +145,24 @@ const IrlPastEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, han const sanitizedDesc = sanitize(selectedEvent?.description); const clippedDesc = clip(sanitizedDesc, 80, { html: true, maxLines: 2 }); -const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && - eventDetails?.pastEvents?.some(event => event.slugURL === searchParams?.event) : true; + const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && eventDetails?.pastEvents?.some((event) => event.slugURL === searchParams?.event) : true; + + useEffect(() => { + const gathering = eventsToShow.find((event: any) => event.slugURL === searchParams?.event); + const container = document.getElementById('container'); + const element = document.getElementById(`past-web-${gathering.uid}`); + + if (container) { + const containerRect = container.getBoundingClientRect(); + const elementRect = element ? element.getBoundingClientRect() : null; + const scrollTop = elementRect ? elementRect.top - containerRect.top + container.scrollTop : 0; + container.scrollTo({ top: scrollTop - 42, behavior: 'smooth' }); + } + }, []); return ( <> -
+
{eventsToShow?.length > 0 && isEventAvailable ? ( <> @@ -186,12 +197,11 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' &&
calendar
-
No results found for the applied input - {' '} - Reset to default im - +
+ No results found for the applied input{' '} + + Reset to default im +
)} @@ -733,8 +743,8 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && } .root__irl__table__no-data__errorMsg { - cursor: pointer; - color: #156FF7; + cursor: pointer; + color: #156ff7; } @media screen and (min-width: 360px) { @@ -784,7 +794,7 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && } .root__irl__table__no-data { - width: 1203px; + width: 1203px; } } @@ -805,7 +815,7 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && } .root__irl__table__no-data { - width: 1638px; + width: 1638px; } } @@ -817,7 +827,7 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && .root__irl__table-col__headerDesc, .root__irl__table-col__contentDesc { - width: 1411px; + width: 1411px; } .root__irl__table-col__headerRes, @@ -826,7 +836,7 @@ const isEventAvailable = searchParams?.type ? searchParams?.type === 'past' && } .root__irl__table__no-data { - width: 2196px; + width: 2196px; } } `} diff --git a/components/page/member-details/member-irl-contributions.tsx b/components/page/member-details/member-irl-contributions.tsx index 5343da17..537fbc67 100644 --- a/components/page/member-details/member-irl-contributions.tsx +++ b/components/page/member-details/member-irl-contributions.tsx @@ -1,14 +1,15 @@ 'use client'; -import { Fragment, useRef, useState } from 'react'; +import { useRef, useState } from 'react'; import Modal from '@/components/core/modal'; import { IMember } from '@/types/members.types'; import { IAnalyticsUserInfo, IUserInfo } from '@/types/shared.types'; import { useMemberAnalytics } from '@/analytics/members.analytics'; import React from 'react'; import { Tooltip } from '@/components/core/tooltip/tooltip'; -import { usePathname, useRouter } from 'next/navigation'; import { format, toZonedTime } from 'date-fns-tz'; +import { compareAsc, isWithinInterval } from 'date-fns'; +import { sortEventsByDate } from '@/utils/irl.utils'; interface IEvent { uid: string; @@ -43,13 +44,14 @@ const IrlMemberContribution = (props: IMemberRepositories) => { const modalRef = useRef(null); const [selectedRole, setSelectedRole] = useState(''); const analytics = useMemberAnalytics(); - const router = useRouter(); const member = props?.member?.eventGuests; - const transformData = (array: IEventGuest[]): GroupedEvents => { + const sortedEvents = sortEventsByDate(member); + + const transformData = (array: any[]): GroupedEvents => { return array.reduce( (acc: GroupedEvents, item) => { - if ((!item.isSpeaker && !item.isHost)) { + if (!item.isSpeaker && !item.isHost) { acc.Attendee.push(item.event); } @@ -62,7 +64,7 @@ const IrlMemberContribution = (props: IMemberRepositories) => { ); }; - const groupedData: GroupedEvents = member ? transformData(member) : { Attendee: [], Speaker: [], Host: [] }; + const groupedData: GroupedEvents = member ? transformData(sortedEvents) : { Attendee: [], Speaker: [], Host: [] }; const onClose = () => { if (modalRef.current) { @@ -80,26 +82,25 @@ const IrlMemberContribution = (props: IMemberRepositories) => { const handleEventClick = (details: any, role: any) => { analytics.onClickEventIrlContribution(userInfo); - const isActive = checkTimeZone(details) + const isActive = checkTimeZone(details); - const type = isActive ? "upcoming" : "past"; - const location = details?.location?.location ?? ""; - const locationName = location.split(",")[0].trim(); + const type = isActive ? 'upcoming' : 'past'; + const location = details?.location?.location ?? ''; + const locationName = location.split(',')[0].trim(); const baseUrl = window.location.origin; let url = `irl?location=${locationName}&type=${type}`; - if (role === "Attendee" && type === "upcoming") { + if (role === 'Attendee' && type === 'upcoming') { url += `&attending=${details.name}`; } - if (type === "past") { + if (type === 'past') { url += `&event=${details.slugURL}`; } const fullUrl = `${baseUrl}/${url}`; window.open(fullUrl, '_blank'); - } - + }; const checkTimeZone = (details: any) => { const timezone = details?.location?.timezone; @@ -107,12 +108,12 @@ const IrlMemberContribution = (props: IMemberRepositories) => { const currentDateInTargetTimezone = toZonedTime(new Date(), timezone); return endDateInTargetTimezone.getTime() > currentDateInTargetTimezone.getTime(); - } + }; const getFormattedDateString = (date: string, timeZone: string) => { const dateInTargetTimezone = toZonedTime(date, timeZone); - return format(dateInTargetTimezone, 'MMM dd', { timeZone }); - } + return format(dateInTargetTimezone, 'MMM yyyy', { timeZone }); + }; return ( <> @@ -134,35 +135,28 @@ const IrlMemberContribution = (props: IMemberRepositories) => { {visibleEvents.map((details: any, index: React.Key | null | undefined) => { const isActive = checkTimeZone(details); return ( -
{ handleEventClick(details, role) }} - > - - {details?.name} -
- } - trigger={ + side="top" + content={
{details?.name}
} + trigger={ +
{ + handleEventClick(details, role); + }} + >
{details?.name}
- } - /> -
- {getFormattedDateString(details?.startDate, details?.location?.timezone)} -
-
+
{getFormattedDateString(details?.startDate, details?.location?.timezone)}
+
+ } + /> ); })} {additionalCount > 0 && ( -
onClickHandler(role)} - > +
onClickHandler(role)}> +{additionalCount}
)} @@ -180,12 +174,18 @@ const IrlMemberContribution = (props: IMemberRepositories) => { .map(([role, events]) => ( <>
-
{role}
+
Contributions ({role})
- {events.map((resource: { link: any; name: any; }, index: React.Key | null | undefined) => ( -
-
{resource?.name}
+ {events.map((resource: { link: any; name: any }, index: number) => ( +
{ + handleEventClick(resource, role); + }} + > +
{resource?.name}
arrow icon
@@ -194,15 +194,18 @@ const IrlMemberContribution = (props: IMemberRepositories) => {
))} - -