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 recently attended events #133

Merged
merged 3 commits into from
Feb 7, 2024
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
17 changes: 10 additions & 7 deletions src/components/profile/UserProfilePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export interface UserProfilePageProps {
handleUser: PublicProfile;
isSignedInUser: boolean;
signedInAttendances: PublicAttendance[];
attendances?: PublicAttendance[];
recentAttendances?: PublicAttendance[];
}

export const UserProfilePage = ({
handleUser,
attendances,
recentAttendances,
signedInAttendances,
isSignedInUser,
}: UserProfilePageProps) => {
Expand Down Expand Up @@ -143,7 +143,7 @@ export const UserProfilePage = ({
</div>
)}
</div>
{(attendances || isSignedInUser) && (
{(recentAttendances || isSignedInUser) && (
<div className={styles.section}>
<Typography variant="h2/bold">
Recently Attended Events
Expand All @@ -154,16 +154,19 @@ export const UserProfilePage = ({
)}
</Typography>
<Carousel>
{(isSignedInUser ? signedInAttendances : (attendances as PublicAttendance[])).map(
({ event }) => (
{(isSignedInUser
? signedInAttendances.slice(-10)
: (recentAttendances as PublicAttendance[])
)
.reverse()
.map(({ event }) => (
<EventCard
className={styles.card}
key={event.uuid}
event={event}
attended={signedInAttendances.some(({ event: { uuid } }) => uuid === event.uuid)}
/>
)
)}
))}
</Carousel>
</div>
)}
Expand Down
8 changes: 5 additions & 3 deletions src/pages/u/[handle].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ const getServerSidePropsFunc: GetServerSideProps = async ({ params, req, res })

const isSignedInUser = handleUser.uuid === user.uuid;

let attendances = null;
let recentAttendances = null;
if (!isSignedInUser && handleUser.isAttendancePublic)
attendances = (await UserAPI.getAttendancesForUserByUUID(token, user.uuid)).slice(0, 10);
raymosun marked this conversation as resolved.
Show resolved Hide resolved
recentAttendances = (await UserAPI.getAttendancesForUserByUUID(token, handleUser.uuid)).slice(
-10
);

// render UserProfilePage
return {
props: {
handleUser,
isSignedInUser,
signedInAttendances,
attendances,
recentAttendances,
},
};
} catch (err: any) {
Expand Down