Skip to content

Commit

Permalink
Fix: IRL bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yosuva-rajendran authored and navneethkrish committed Nov 26, 2024
1 parent fc80755 commit e24a87f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
3 changes: 2 additions & 1 deletion app/irl/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const getPageData = async (searchParams: any) => {
if (!eventType) {
if (eventDetails?.upcomingEvents?.length === 0 && eventDetails?.pastEvents?.length > 0) {
searchParams.event = pastEvents[0]?.slugURL;
searchParams.type = 'past';
}
} else {
if (eventType === 'past' && !searchParams?.event) {
Expand All @@ -135,7 +136,7 @@ const getPageData = async (searchParams: any) => {
}

let guestDetails = events as any;
const selectedTypeEvents = eventType === 'past' ? eventDetails.pastEvents : eventDetails.upcomingEvents;
const selectedTypeEvents = (eventType === 'past' || eventDetails?.upcomingEvents?.length === 0 && eventDetails?.pastEvents?.length > 0) ? eventDetails.pastEvents : eventDetails.upcomingEvents;

guestDetails.events = selectedTypeEvents;
guestDetails.currentGuest = currentGuestResponse?.guests?.[0]?.memberUid === userInfo?.uid ? currentGuestResponse?.guests?.[0] : null;
Expand Down
8 changes: 5 additions & 3 deletions components/page/irl/add-edit-attendee/attendee-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SearchableSingleSelect from '@/components/form/searchable-single-select';
import SingleSelectWithImage from '@/components/form/single-select-with-image';
import { getMember, getMembersForAttendeeForm, getMembersForProjectForm } from '@/services/members.service';
import { getMemberPreferences } from '@/services/preferences.service';
import { IIrlAttendeeFormErrors, IIrlLocation } from '@/types/irl.types';
import { IIrlAttendeeFormErrors, IIrlEvent, IIrlLocation } from '@/types/irl.types';
import { IUserInfo } from '@/types/shared.types';
import { getParsedValue, getUserInfoFromLocal, triggerLoader } from '@/utils/common.utils';
import { EVENTS, IAM_GOING_POPUP_MODES, IRL_ATTENDEE_FORM_ERRORS } from '@/utils/constants';
Expand All @@ -21,6 +21,7 @@ interface IAttendeeForm {
setFormInitialValues: SetStateAction<any>;
location: IIrlLocation;
eventType: string;
gatherings: IIrlEvent[];
}

const AttendeeDetails = (props: IAttendeeForm) => {
Expand All @@ -32,6 +33,7 @@ const AttendeeDetails = (props: IAttendeeForm) => {
const setFormInitialValues = props?.setFormInitialValues;
const location = props?.location;
const eventType = props?.eventType ?? '';
const gatherings = props?.gatherings ?? [];

const [initialContributors, setInitialContributors] = useState([]);
const [initialTeams, setInitialTeams] = useState(initialValues?.teams ?? []);
Expand Down Expand Up @@ -86,9 +88,9 @@ const AttendeeDetails = (props: IAttendeeForm) => {
const fetchGuestDetails = async () => {
try {
let result = await getGuestDetail(selectedMember.uid ?? '', location.uid, authToken, eventType);

const gatheringsToShow = result?.filter((gathering:any) => (gatherings?.some((guest: any) => guest?.slugURL === gathering.event?.slugURL)));
if (result.length>0) {
const formData = transformGuestDetail(result);
const formData = transformGuestDetail(gatheringsToShow);

updateMemberDetails(false);
setSelectedTeam({name: formData?.teamName,
Expand Down
2 changes: 1 addition & 1 deletion components/page/irl/add-edit-attendee/attendee-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,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 = {eventType}/>
<AttendeeDetails gatherings={gatherings} 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 @@ -196,7 +196,7 @@ const AttendeeList = (props: IAttendeeList) => {
)}
<div className="attendeeList">
<div className="attendeeList__toolbar">
<Toolbar isAdminInAllEvents={isAdminInAllEvents} location={location} onLogin={onLogin} filteredListLength={updatedEventDetails.totalGuests} eventDetails={updatedEventDetails} userInfo={userInfo} isLoggedIn={isLoggedIn} />
<Toolbar locationEvents={locationEvents} isAdminInAllEvents={isAdminInAllEvents} location={location} onLogin={onLogin} filteredListLength={updatedEventDetails.totalGuests} eventDetails={updatedEventDetails} userInfo={userInfo} isLoggedIn={isLoggedIn} />
</div>
<div className="attendeeList__table">
{/* {eventDetails?.guests?.length > 0 && ( */}
Expand Down
13 changes: 8 additions & 5 deletions components/page/irl/attendee-list/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IToolbar {
eventDetails: IGuestDetails;
location: IAnalyticsGuestLocation;
isAdminInAllEvents: any;
locationEvents: any;
}

const Toolbar = (props: IToolbar) => {
Expand All @@ -32,6 +33,9 @@ const Toolbar = (props: IToolbar) => {
const updatedUser = eventDetails?.currentGuest ?? null;
const isUserGoing = eventDetails?.isUserGoing;
const isAdminInAllEvents = props?.isAdminInAllEvents;
const locationEvents = props?.locationEvents;
const pastEvents = locationEvents?.pastEvents;
const upcomingEvents = locationEvents?.upcomingEvents;

//states
// const [searchTerm, setSearchTerm] = useState('');
Expand All @@ -41,9 +45,10 @@ const Toolbar = (props: IToolbar) => {
const type = searchParams.get('type');
const search = searchParams.get('search');
const editResponseRef = useRef<HTMLButtonElement>(null);

const router = useRouter();

const inPastEvents = type ? type === 'past' : (pastEvents && pastEvents.length > 0 && upcomingEvents && upcomingEvents.length === 0);

useClickedOutside({
ref: editResponseRef,
callback: () => {
Expand Down Expand Up @@ -148,8 +153,6 @@ const Toolbar = (props: IToolbar) => {
officeHours: updatedUser?.officeHours ?? '',
};

console.log('formData', formData);

document.dispatchEvent(new CustomEvent(EVENTS.OPEN_IAM_GOING_POPUP, { detail: { isOpen: true, formdata: formData, mode: IAM_GOING_POPUP_MODES.EDIT } }));
};

Expand Down Expand Up @@ -177,7 +180,7 @@ const Toolbar = (props: IToolbar) => {
</div>
)}

{!isUserGoing && isUserLoggedIn && type !== 'past' && (
{!isUserGoing && isUserLoggedIn && !inPastEvents && (
<button onClick={onIAmGoingClick} className="mb-btn toolbar__actionCn__imGoingBtn">
I&apos;m Going
</button>
Expand All @@ -194,7 +197,7 @@ const Toolbar = (props: IToolbar) => {
</>
)}

{isUserGoing && isUserLoggedIn && type !== 'past' && (
{isUserGoing && isUserLoggedIn && !inPastEvents && (
<div className="toolbar__actionCn__edit__wrpr">
<button ref={editResponseRef} onClick={onEditResponseClick} className="toolbar__actionCn__edit">
Edit Response
Expand Down
1 change: 1 addition & 0 deletions components/page/irl/locations/irl-location.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const IrlLocation = (props: IrlLocation) => {
else if (hasPastEvents && !hasUpcomingEvents) setPastEvent();
else if (hasUpcomingEvents && hasPastEvents) {
currentParams.delete('type');
currentParams.delete('event');
}
} else if (hasPastEvents && hasUpcomingEvents) {
currentParams.delete('type');
Expand Down
4 changes: 1 addition & 3 deletions services/irl.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export const getGuestsByLocation = async (location: string, searchParams: any, a
}
}
const url = `${process.env.DIRECTORY_API_URL}/v1/irl/locations/${location}/guests?&page=${currentPage}&limit=${limit}&${urlParams.toString()}`;

console.log('url', url)


let result = await fetchGuests(url, authToken);
if (result.isError) return { isError: true };

Expand Down

0 comments on commit e24a87f

Please sign in to comment.