From e8b56485ee59e94e617551a46323fd8664141eac Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Tue, 5 Nov 2024 10:40:33 +0000 Subject: [PATCH] ENCOA-217: Adapted the invite system to now work based on Entities instead of Users/Groups --- src/components/Medium/InviteWithUserCard.tsx | 8 +- src/email/templates/receivedInvite.handlebars | 2 +- src/interfaces/invite.ts | 9 ++- src/pages/(admin)/BatchCreateUser.tsx | 27 ++++++- src/pages/api/hello.ts | 3 +- src/pages/api/invites/accept/[id].ts | 75 ++----------------- src/pages/api/invites/index.ts | 11 +-- src/pages/dashboard/student.tsx | 8 +- src/pages/settings.tsx | 15 ++-- src/utils/invites.be.ts | 7 +- 10 files changed, 63 insertions(+), 102 deletions(-) diff --git a/src/components/Medium/InviteWithUserCard.tsx b/src/components/Medium/InviteWithUserCard.tsx index 158723f7..d0e14aac 100644 --- a/src/components/Medium/InviteWithUserCard.tsx +++ b/src/components/Medium/InviteWithUserCard.tsx @@ -1,4 +1,4 @@ -import {Invite, InviteWithUsers} from "@/interfaces/invite"; +import {Invite, InviteWithEntity} from "@/interfaces/invite"; import {User} from "@/interfaces/user"; import {getUserName} from "@/utils/users"; import axios from "axios"; @@ -7,14 +7,14 @@ import {BsArrowRepeat} from "react-icons/bs"; import {toast} from "react-toastify"; interface Props { - invite: InviteWithUsers; + invite: InviteWithEntity; reload: () => void; } export default function InviteWithUserCard({invite, reload}: Props) { const [isLoading, setIsLoading] = useState(false); - const name = useMemo(() => (!invite.from ? null : getUserName(invite.from)), [invite.from]); + const name = useMemo(() => (!invite.entity ? null : invite.entity.label), [invite.entity]); const decide = (decision: "accept" | "decline") => { if (!confirm(`Are you sure you want to ${decision} this invite?`)) return; @@ -37,7 +37,7 @@ export default function InviteWithUserCard({invite, reload}: Props) { return (
- Invited by {name} + Invited to {name}