diff --git a/src/components/Event/EventCarpools.tsx b/src/components/Event/EventCarpools.tsx
index 0807733..4702251 100644
--- a/src/components/Event/EventCarpools.tsx
+++ b/src/components/Event/EventCarpools.tsx
@@ -122,33 +122,29 @@ export default function Carpools() {
return (
Carpools
- {alreadyInCarpool ? (
-
You are already in a carpool for this event
+ {creationStatus === 'completed' ? (
+
+ Created{' '}
+ your carpool!
+
+ ) : myCarpool ? (
+
+ You are already in a carpool for this event:{' '}
+ {myCarpool.name}
+
) : (
<>
- {creationStatus !== 'completed' ? (
- <>
-
Available to drive?
-
- {creationStatus === null
- ? 'Create Empty Carpool'
- : creationStatus === 'pending'
- ? 'Creating...'
- : 'Errored'}
-
- >
- ) : (
-
- Created{' '}
-
- your carpool
-
- !
-
- )}
+
Available to drive?
+
+ {creationStatus === null
+ ? 'Create Empty Carpool'
+ : creationStatus === 'pending'
+ ? 'Creating...'
+ : 'Errored'}
+
>
)}
{event.carpools.map((carpool) => (
diff --git a/src/components/Event/EventSignups.tsx b/src/components/Event/EventSignups.tsx
index 50d9b09..643ebcb 100644
--- a/src/components/Event/EventSignups.tsx
+++ b/src/components/Event/EventSignups.tsx
@@ -3,6 +3,7 @@ import { useMe } from '../hooks';
import latlongdist, { R_miles } from '../../lib/latlongdist';
import { IEventSignup, IEvent } from '../types';
import usePlace from '../usePlace';
+import { useMemo } from 'react';
export default function EventSignups({
event,
@@ -13,15 +14,24 @@ export default function EventSignups({
signups: IEventSignup[];
myPlaceId: string | null;
}) {
+ const carpools = event.carpools;
const placeDetails = usePlace(myPlaceId);
const locationLongitude = event.latitude;
const locationLatitude = event.longitude;
const me = useMe();
+ const signupsWithoutCarpool = useMemo(() => {
+ // A list of users not in any carpool
+ const members = carpools.map((c) => c.members);
+ const allMembers = members.reduce((a, b) => a.concat(b), []);
+ const allMembersIds = allMembers.map((m) => m.id);
+ return signups.filter((s) => !allMembersIds.includes(s.user.id));
+ }, [signups, carpools]);
+
return (
-
People
- {signups.map(({ latitude, longitude, user }) => {
+ People without a carpool
+ {signupsWithoutCarpool.map(({ latitude, longitude, user }) => {
if (user.id === me?.id) {
return null;
}