mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +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.
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { Button } from '@documenso/ui/primitives/button';
|
|
import { useToast } from '@documenso/ui/primitives/use-toast';
|
|
|
|
import { createBillingPortal } from './create-billing-portal.action';
|
|
|
|
export type BillingPortalButtonProps = {
|
|
buttonProps?: React.ComponentProps<typeof Button>;
|
|
};
|
|
|
|
export const BillingPortalButton = ({ buttonProps }: BillingPortalButtonProps) => {
|
|
const { toast } = useToast();
|
|
|
|
const [isFetchingPortalUrl, setIsFetchingPortalUrl] = useState(false);
|
|
|
|
const handleFetchPortalUrl = async () => {
|
|
if (isFetchingPortalUrl) {
|
|
return;
|
|
}
|
|
|
|
setIsFetchingPortalUrl(true);
|
|
|
|
try {
|
|
const sessionUrl = await createBillingPortal();
|
|
|
|
if (!sessionUrl) {
|
|
throw new Error('NO_SESSION');
|
|
}
|
|
|
|
window.open(sessionUrl, '_blank');
|
|
} catch (e) {
|
|
let description =
|
|
'We are unable to proceed to the billing portal at this time. Please try again, or contact support.';
|
|
|
|
if (e.message === 'CUSTOMER_NOT_FOUND') {
|
|
description =
|
|
'You do not currently have a customer record, this should not happen. Please contact support for assistance.';
|
|
}
|
|
|
|
toast({
|
|
title: 'Something went wrong',
|
|
description,
|
|
variant: 'destructive',
|
|
duration: 10000,
|
|
});
|
|
}
|
|
|
|
setIsFetchingPortalUrl(false);
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
{...buttonProps}
|
|
onClick={async () => handleFetchPortalUrl()}
|
|
loading={isFetchingPortalUrl}
|
|
>
|
|
Manage Subscription
|
|
</Button>
|
|
);
|
|
};
|