adjusted events view to only show the availability selector, when a user can do at least one task of the event
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import AddEvent from "@/components/Event/AddEvent";
|
||||
import AssignmentTable from "@/components/Event/AssignmentTable";
|
||||
import Event from "@/components/Event/Event";
|
||||
import { apiCall } from "@/lib";
|
||||
import { apiCall, getUserTasks } from "@/lib";
|
||||
import zustand, { EventDataWithAvailability } from "@/Zustand";
|
||||
import { Add } from "@carbon/icons-react";
|
||||
import { Button, Tab, Tabs } from "@heroui/react";
|
||||
@@ -37,6 +37,14 @@ export default function Events() {
|
||||
},
|
||||
});
|
||||
|
||||
const userTasks = useAsyncList({
|
||||
async load() {
|
||||
return {
|
||||
items: await getUserTasks(),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
function showEvent(event: EventDataWithAvailability): boolean {
|
||||
switch (filter) {
|
||||
case "assigned":
|
||||
@@ -45,13 +53,17 @@ export default function Events() {
|
||||
});
|
||||
|
||||
case "pending":
|
||||
return event.availability === null;
|
||||
return event.availability === null && showAvailabilitySelector(event);
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function showAvailabilitySelector(event: EventDataWithAvailability): boolean {
|
||||
return event.tasks.some((t) => userTasks.items.includes(t.taskID));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative flex flex-1 flex-col gap-4">
|
||||
<h2 className="text-center text-4xl">Upcoming Events</h2>
|
||||
@@ -75,7 +87,9 @@ export default function Events() {
|
||||
tasks={e.tasks}
|
||||
className="mt-auto"
|
||||
/>
|
||||
<AvailabilitySelector event={e} startSelection={e.availability} />
|
||||
{showAvailabilitySelector(e) ? (
|
||||
<AvailabilitySelector event={e} startSelection={e.availability} />
|
||||
) : undefined}
|
||||
</Event>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -7,8 +7,8 @@ import Header from "./Header";
|
||||
import Main from "./Main";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "Golunteer",
|
||||
description: "Volunteeer coordination",
|
||||
};
|
||||
|
||||
export interface SiteLink {
|
||||
|
||||
Reference in New Issue
Block a user