Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conditionally hide delete button
  • Loading branch information
regalijan committed Oct 19, 2024
1 parent 636d1d6 commit 4f49180
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/routes/events-team.tsx
Expand Up @@ -78,6 +78,7 @@ export async function loader({ context }: { context: RequestContext }) {
),
events: monthEventList.results,
members: membersList.results as { id: string; name: string }[],
user_id: context.data.current_user.id as string,
};
}

Expand All @@ -86,10 +87,12 @@ export default function () {
can_approve,
events,
members,
user_id,
}: {
can_approve: boolean;
events: { [k: string]: any }[];
members: { id: string; name: string }[];
user_id: string;
} = useLoaderData<typeof loader>();
const [eventData, setEventData] = useState(events);
const { isOpen, onClose, onOpen } = useDisclosure();
Expand Down Expand Up @@ -601,12 +604,17 @@ export default function () {
</Text>
<Button
alignSelf="center"
display={
event.created_by === user_id || can_approve
? undefined
: "none"
}
marginLeft="auto"
marginRight={0}
onClick={() => {
setSelectedEvent(event.id);
onDeleteOpen();
}}
marginLeft="auto"
marginRight={0}
>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit 4f49180

Please sign in to comment.