Display names on event cards
This commit is contained in:
parent
f603bc67b1
commit
5f7716d440
@ -52,11 +52,23 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
status: 500,
|
status: 500,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const membersList = await context.env.D1.prepare(
|
||||||
|
"SELECT id, name FROM et_members WHERE id IN (SELECT created_by FROM events WHERE month = ? AND year = ?);",
|
||||||
|
)
|
||||||
|
.bind(now.getUTCMonth() + 1, now.getUTCFullYear())
|
||||||
|
.all();
|
||||||
|
|
||||||
|
if (membersList.error)
|
||||||
|
throw new Response(null, {
|
||||||
|
status: 500,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
can_approve: Boolean(
|
can_approve: Boolean(
|
||||||
[1 << 4, 1 << 12].find((p) => context.data.current_user.permissions & p),
|
[1 << 4, 1 << 12].find((p) => context.data.current_user.permissions & p),
|
||||||
),
|
),
|
||||||
events: monthEventList.results,
|
events: monthEventList.results,
|
||||||
|
members: membersList.results as { id: string; name: string }[],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +76,13 @@ export default function () {
|
|||||||
const {
|
const {
|
||||||
can_approve,
|
can_approve,
|
||||||
events,
|
events,
|
||||||
|
members,
|
||||||
}: {
|
}: {
|
||||||
can_approve: boolean;
|
can_approve: boolean;
|
||||||
events: { [k: string]: any }[];
|
events: { [k: string]: any }[];
|
||||||
|
members: { id: string; name: string }[];
|
||||||
} = useLoaderData<typeof loader>();
|
} = useLoaderData<typeof loader>();
|
||||||
|
const [eventData, setEventData] = useState(events);
|
||||||
const eventCards: ReactNode[] = [];
|
const eventCards: ReactNode[] = [];
|
||||||
const { isOpen, onClose, onOpen } = useDisclosure();
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
@ -107,9 +122,16 @@ export default function () {
|
|||||||
title: "Success",
|
title: "Success",
|
||||||
});
|
});
|
||||||
|
|
||||||
events.find((e, i) => {
|
const newEventData = eventData;
|
||||||
if (e.id === eventId) events[i].approved = approved;
|
|
||||||
|
newEventData.find((e, i) => {
|
||||||
|
if (e.id === eventId) {
|
||||||
|
events[i].approved = approved;
|
||||||
|
events[i].pending = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setEventData(newEventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function certify(eventId: string) {
|
async function certify(eventId: string) {
|
||||||
@ -145,12 +167,20 @@ export default function () {
|
|||||||
title: "Success",
|
title: "Success",
|
||||||
});
|
});
|
||||||
|
|
||||||
events.find((e, i) => {
|
const newEventData = eventData;
|
||||||
|
|
||||||
|
newEventData.find((e, i) => {
|
||||||
if (e.id === eventId) events[i].reached_minimum_player_count = true;
|
if (e.id === eventId) events[i].reached_minimum_player_count = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setEventData(newEventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const event of events) {
|
for (const event of eventData) {
|
||||||
|
const eventCreatorName = members.find(
|
||||||
|
(member) => member.id === event.created_by,
|
||||||
|
);
|
||||||
|
|
||||||
eventCards.push(
|
eventCards.push(
|
||||||
<Card w="100%">
|
<Card w="100%">
|
||||||
<CardBody>
|
<CardBody>
|
||||||
@ -184,7 +214,9 @@ export default function () {
|
|||||||
<Box>
|
<Box>
|
||||||
<Heading size="sm">Host</Heading>
|
<Heading size="sm">Host</Heading>
|
||||||
<Text fontSize="sm" pt="2">
|
<Text fontSize="sm" pt="2">
|
||||||
{event.created_by}
|
{eventCreatorName
|
||||||
|
? `${eventCreatorName} (${event.created_by})`
|
||||||
|
: event.created_by}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
@ -268,7 +300,7 @@ export default function () {
|
|||||||
<Link color="#646cff" href="/book-event" mt="16px">
|
<Link color="#646cff" href="/book-event" mt="16px">
|
||||||
Book an Event
|
Book an Event
|
||||||
</Link>
|
</Link>
|
||||||
<Link color="#646cff" href="/et-members" my="8px">
|
<Link color="#646cff" href="/et-members" mb="32px" mt="8px">
|
||||||
Events Team Member Management
|
Events Team Member Management
|
||||||
</Link>
|
</Link>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user