chore: team stuff (#1228)

- Added functionality to decline team invitations
- Added email notifications for when team is deleted
- Added email notifications for team members joining and leaving
This commit is contained in:
Ephraim Duncan
2024-07-25 04:27:19 +00:00
committed by GitHub
parent b366ab8736
commit a8febae87e
44 changed files with 1014 additions and 226 deletions

View File

@ -0,0 +1,46 @@
'use client';
import { trpc } from '@documenso/trpc/react';
import { Button } from '@documenso/ui/primitives/button';
import { useToast } from '@documenso/ui/primitives/use-toast';
export type DeclineTeamInvitationButtonProps = {
teamId: number;
};
export const DeclineTeamInvitationButton = ({ teamId }: DeclineTeamInvitationButtonProps) => {
const { toast } = useToast();
const {
mutateAsync: declineTeamInvitation,
isLoading,
isSuccess,
} = trpc.team.declineTeamInvitation.useMutation({
onSuccess: () => {
toast({
title: 'Success',
description: 'Declined team invitation',
duration: 5000,
});
},
onError: () => {
toast({
title: 'Something went wrong',
variant: 'destructive',
duration: 10000,
description: 'Unable to decline this team invitation at this time.',
});
},
});
return (
<Button
onClick={async () => declineTeamInvitation({ teamId })}
loading={isLoading}
disabled={isLoading || isSuccess}
variant="ghost"
>
Decline
</Button>
);
};