From 905a1103777bd96254f5e7ef5cb7d7784c5af91a Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:27:05 +0000 Subject: [PATCH] Invites (#6665) --- apps/web/public/static/locales/en/common.json | 2 + .../features/ee/teams/components/TeamList.tsx | 26 ++++++------- .../ee/teams/components/TeamListItem.tsx | 14 ++++--- .../ee/teams/components/TeamsListing.tsx | 25 ++++++++++--- packages/features/shell/Shell.tsx | 3 ++ packages/features/shell/TeamInviteBadge.tsx | 12 ++++++ packages/features/tips/UpgradeTip.tsx | 37 ++++++------------- packages/lib/hooks/useHasTeamPlan.ts | 6 +++ packages/trpc/server/routers/viewer/teams.tsx | 11 ++++++ 9 files changed, 85 insertions(+), 51 deletions(-) create mode 100644 packages/features/shell/TeamInviteBadge.tsx diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 51a7c408c3..1b1e382c70 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -24,6 +24,7 @@ "rejection_confirmation": "Reject the booking", "manage_this_event": "Manage this event", "invite_team_member": "Invite team member", + "invite_team_notifcation_badge":"Inv.", "your_event_has_been_scheduled": "Your event has been scheduled", "your_event_has_been_scheduled_recurring": "Your recurring event has been scheduled", "accept_our_license": "Accept our license by changing the .env variable <1>NEXT_PUBLIC_LICENSE_CONSENT to '{{agree}}'.", @@ -1313,6 +1314,7 @@ "password_reset_leading": "If you don't receive an email soon, check that the email address you entered is correct, check your spam folder or reach out to support if the issue persists.", "password_updated": "Password updated!", "pending_payment": "Pending payment", + "pending_invites":"Pending Invites", "confirmation_page_rainbow": "Token gate your event with tokens or NFTs on Ethereum, Polygon, and more.", "not_on_cal": "Not on {{appName}}", "no_calendar_installed": "No calendar installed", diff --git a/packages/features/ee/teams/components/TeamList.tsx b/packages/features/ee/teams/components/TeamList.tsx index d92f32a9fe..9595ab5534 100644 --- a/packages/features/ee/teams/components/TeamList.tsx +++ b/packages/features/ee/teams/components/TeamList.tsx @@ -36,19 +36,17 @@ export default function TeamList(props: Props) { } return ( -
- -
+ ); } diff --git a/packages/features/ee/teams/components/TeamListItem.tsx b/packages/features/ee/teams/components/TeamListItem.tsx index 44c3f5fdc4..a237d72581 100644 --- a/packages/features/ee/teams/components/TeamListItem.tsx +++ b/packages/features/ee/teams/components/TeamListItem.tsx @@ -67,6 +67,7 @@ export default function TeamListItem(props: Props) { const acceptOrLeaveMutation = trpc.viewer.teams.acceptOrLeave.useMutation({ onSuccess: () => { utils.viewer.teams.list.invalidate(); + utils.viewer.teams.listInvites.invalidate(); }, }); @@ -88,12 +89,12 @@ export default function TeamListItem(props: Props) { if (!team) return <>; const teamInfo = ( -
+
{team.name} @@ -105,7 +106,7 @@ export default function TeamListItem(props: Props) { ); return ( -
  • +
  • { @@ -140,13 +141,14 @@ export default function TeamListItem(props: Props) {
    {isInvitee ? ( <> -
    +
    - {invites.length > 0 && ( -
    -

    {t("open_invitations")}

    - -
    - )} +
    - {invites.length === 0 && - features.map((feature) => ( -
    - {feature.icon} -

    {feature.title}

    -

    {feature.description}

    -
    - ))} + {features.map((feature) => ( +
    + {feature.icon} +

    {feature.title}

    +

    {feature.description}

    +
    + ))}
    diff --git a/packages/lib/hooks/useHasTeamPlan.ts b/packages/lib/hooks/useHasTeamPlan.ts index 13fd9b6f13..87b51ccf36 100644 --- a/packages/lib/hooks/useHasTeamPlan.ts +++ b/packages/lib/hooks/useHasTeamPlan.ts @@ -6,4 +6,10 @@ export function useHasTeamPlan() { return { isLoading: hasTeam.isLoading, hasTeamPlan: hasTeam.data?.hasTeamPlan || false }; } +export function useTeamInvites() { + const listInvites = trpc.viewer.teams.listInvites.useQuery(); + + return { isLoading: listInvites.isLoading, listInvites: listInvites.data }; +} + export default useHasTeamPlan; diff --git a/packages/trpc/server/routers/viewer/teams.tsx b/packages/trpc/server/routers/viewer/teams.tsx index a08a19ed92..07269ec9f7 100644 --- a/packages/trpc/server/routers/viewer/teams.tsx +++ b/packages/trpc/server/routers/viewer/teams.tsx @@ -700,4 +700,15 @@ export const viewerTeamsRouter = router({ }); return { hasTeamPlan: !!hasTeamPlan }; }), + listInvites: authedProcedure.query(async ({ ctx }) => { + const userId = ctx.user.id; + return await ctx.prisma.membership.findMany({ + where: { + user: { + id: userId, + }, + accepted: false, + }, + }); + }), });