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

Fix: IRL Search Param issue #385

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion analytics/irl.analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const useIrlAnalytics = () => {
IRL_LOCATION_CARD_CLICKED:'irl-location-card-button-clicked',
IRL_SEE_OTHER_LOCATION_CARD_CLICKED: 'on-see-other-location-card-clicked',
IRL_UPCOMING_EVENTS_BUTTON_CLICKED: 'on-upcoming-events-button-clicked',
IRL_ALL_EVENTS_BUTTON_CLICKED: 'on-all-events-button-clicked',

IRL_PAST_EVENTS_BUTTON_CLICKED: 'on-past-events-button-clicked',
IRL_UPCOMING_RESOURCE_POPUP_VIEWED: 'on-resource-popup-viewed',
IRL_PAST_RESOURCE_POPUP_VIEWED: 'on-resource-popup-viewed',
Expand Down Expand Up @@ -363,6 +365,13 @@ export const useIrlAnalytics = () => {
captureEvent(IRL_ANALYTICS_EVENTS.IRL_UPCOMING_EVENTS_BUTTON_CLICKED, {...params});
}

function trackAllEventsButtonClicked(events: any) {
const params = {
allEvents: events,
};
captureEvent(IRL_ANALYTICS_EVENTS.IRL_ALL_EVENTS_BUTTON_CLICKED, {...params});
}

function trackPastEventsButtonClicked(events: any) {
const params = {
pastEvents: events,
Expand Down Expand Up @@ -530,6 +539,7 @@ export const useIrlAnalytics = () => {
irlAddAttendeePopupCloseClicked,
trackLoginClicked,
onAddGatheringClicked,
searchEventClicked
searchEventClicked,
trackAllEventsButtonClicked
};
};
17 changes: 9 additions & 8 deletions app/irl/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import IrlErrorPage from '@/components/core/irl-error-page';
import { getFilteredEventsForUser, parseSearchParams } from '@/utils/irl.utils';

export default async function Page({ searchParams }: any) {
const { isError, userInfo, isLoggedIn, locationDetails, eventDetails, showTelegram, eventLocationSummary, guestDetails, isUserGoing, isLocationError, currentEventNames } = await getPageData(searchParams);
const { isError, userInfo, isLoggedIn, locationDetails, eventDetails, showTelegram, eventLocationSummary, guestDetails, isUserGoing, isLocationError, currentEventNames } = await getPageData(
searchParams
);

if (isLocationError) {
return <IrlErrorPage />;
Expand Down Expand Up @@ -102,19 +104,19 @@ const getPageData = async (searchParams: any) => {
const eventLocationSummary = { uid, name };

// Determine event type and fetch event guest data
const eventType = searchParams?.type === 'past' ? '' : 'upcoming';
const eventType = searchParams?.type === 'past' ? 'past' : searchParams?.type === 'upcoming' ? 'upcoming' : '';

if (searchParams?.type === 'past' && !searchParams?.event) {
searchParams.event = pastEvents[0]?.slugURL;
}

const currentEvents = eventType === 'upcoming' ? eventDetails.upcomingEvents : eventDetails.pastEvents;
const currentEventNames = currentEvents.map((item: any) => item.name); // Get current event names
const currentEvents = eventType === 'upcoming' ? eventDetails?.upcomingEvents : eventType === 'past' ? eventDetails?.pastEvents : eventDetails?.events;
const currentEventNames = currentEvents?.map((item: any) => item.name); // Get current event names

// Proceed with API calls only after currentEventNames is set
const [events, currentGuestResponse, topics, loggedInUserEvents] = await Promise.all([
getGuestsByLocation(uid, parseSearchParams(searchParams, currentEvents), authToken,currentEventNames),
getGuestsByLocation(uid, { type: eventType }, authToken,currentEventNames, 1, 1),
getGuestsByLocation(uid, parseSearchParams(searchParams, currentEvents), authToken, currentEventNames),
getGuestsByLocation(uid, { type: eventType }, authToken, currentEventNames, 1, 1),
getTopicsByLocation(uid, eventType),
getGuestEvents(uid, authToken),
]);
Expand All @@ -125,7 +127,7 @@ const getPageData = async (searchParams: any) => {

let guestDetails = events as any;

guestDetails.events = currentEvents;
guestDetails.events = eventType === 'past' ? eventDetails.pastEvents : eventDetails.upcomingEvents;
guestDetails.currentGuest = currentGuestResponse?.guests?.[0]?.memberUid === userInfo?.uid ? currentGuestResponse?.guests?.[0] : null;
guestDetails.isUserGoing = currentGuestResponse?.guests?.[0]?.memberUid === userInfo?.uid;
guestDetails.topics = topics;
Expand Down Expand Up @@ -159,7 +161,6 @@ const getPageData = async (searchParams: any) => {
}
};


export const metadata: Metadata = {
title: 'IRL Gatherings | Protocol Labs Directory',
description:
Expand Down
1 change: 0 additions & 1 deletion components/page/home/featured/member-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const MemberCard = (props: any) => {
const member = props?.member;
const profileUrl = member?.profile || '/icons/default_profile.svg';

console.log('member', member,profileUrl);
const mainTeam = member?.mainTeam;
const otherTeams = member?.teams
?.filter((team: any) => team.id !== mainTeam?.id)
Expand Down
3 changes: 2 additions & 1 deletion components/page/irl/add-edit-attendee/attendee-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const AttendeeForm: React.FC<IAttendeeForm> = (props) => {
const getEventDetails = props?.getEventDetails;
const gatherings = getGatherings();

const eventType = searchParams?.type === 'past' ? 'past' : 'upcoming';

const analytics = useIrlAnalytics();

Expand Down Expand Up @@ -342,7 +343,7 @@ const AttendeeForm: React.FC<IAttendeeForm> = (props) => {
<h2 className="atndform__bdy__ttl">Enter Attendee Details</h2>
<AttendeeFormErrors errors={errors} />
<div>
<AttendeeDetails setFormInitialValues={setFormInitialValues} initialValues={formInitialValues} allGuests={allGuests} memberInfo={userInfo} mode={mode} errors={errors} location={selectedLocation} eventType = {searchParams?.type === 'past' ? 'past' : 'upcoming'}/>
<AttendeeDetails setFormInitialValues={setFormInitialValues} initialValues={formInitialValues} allGuests={allGuests} memberInfo={userInfo} mode={mode} errors={errors} location={selectedLocation} eventType = {eventType}/>
</div>
<div>
<Gatherings
Expand Down
2 changes: 1 addition & 1 deletion components/page/irl/attendee-list/attendees-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const AttendeeList = (props: IAttendeeList) => {

const getEventDetails = async () => {
const authToken = getParsedValue(Cookies.get('authToken'));
const eventType = searchParams.type === 'past' ? '' : 'upcoming';
const eventType = searchParams?.type === 'past' ? 'past' : searchParams?.type === 'upcoming' ? 'upcoming' : '';

if (tableRef.current) {
tableRef.current.scrollTop = 0;
Expand Down
Loading