mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 19:51:32 +10:00
## Description Add support for teams which will allow users to collaborate on documents. Teams features allows users to: - Create, manage and transfer teams - Manage team members - Manage team emails - Manage a shared team inbox and documents These changes do NOT include the following, which are planned for a future release: - Team templates - Team API - Search menu integration ## Testing Performed - Added E2E tests for general team management - Added E2E tests to validate document counts ## Checklist - [X] I have tested these changes locally and they work as expected. - [X] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [X] I have followed the project's coding style guidelines.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
'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 TeamBillingPortalButtonProps = {
|
|
buttonProps?: React.ComponentProps<typeof Button>;
|
|
teamId: number;
|
|
};
|
|
|
|
export const TeamBillingPortalButton = ({ buttonProps, teamId }: TeamBillingPortalButtonProps) => {
|
|
const { toast } = useToast();
|
|
|
|
const { mutateAsync: createBillingPortal, isLoading } =
|
|
trpc.team.createBillingPortal.useMutation();
|
|
|
|
const handleCreatePortal = async () => {
|
|
try {
|
|
const sessionUrl = await createBillingPortal({ teamId });
|
|
|
|
window.open(sessionUrl, '_blank');
|
|
} catch (err) {
|
|
toast({
|
|
title: 'Something went wrong',
|
|
description:
|
|
'We are unable to proceed to the billing portal at this time. Please try again, or contact support.',
|
|
variant: 'destructive',
|
|
duration: 10000,
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Button {...buttonProps} onClick={async () => handleCreatePortal()} loading={isLoading}>
|
|
Manage subscription
|
|
</Button>
|
|
);
|
|
};
|