mirror of
https://github.com/documenso/documenso.git
synced 2025-11-11 21:12:48 +10:00
## Description Adds support for customising the theme and CSS for the embedding components which is restricted to platform customers and above. Additionally adds proper support for the platform plan which will let us update our stripe products. <img width="1040" alt="image" src="https://github.com/user-attachments/assets/f694cd1e-ac93-4dc0-9f78-92fa813f6404"> <img width="1015" alt="image" src="https://github.com/user-attachments/assets/4209972a-b2bd-40c9-9049-0367382a4de5"> <img width="1065" alt="image" src="https://github.com/user-attachments/assets/fdbaaaa5-a028-4b1d-a58a-ea6224e21abe"> ## Related Issue N/A ## Changes Made - Added support for using CSS Vars and CSS within the embedding route - Added a guard for platform and enterprise plans to activate the custom css - Added support for the platform plan ## Testing Performed Yes
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { IS_BILLING_ENABLED } from '@documenso/lib/constants/app';
|
|
import { subscriptionsContainsActivePlan } from '@documenso/lib/utils/billing';
|
|
import { prisma } from '@documenso/prisma';
|
|
import type { Document, Subscription } from '@documenso/prisma/client';
|
|
|
|
import { getPlatformPlanPriceIds } from '../stripe/get-platform-plan-prices';
|
|
|
|
export type IsDocumentPlatformOptions = Pick<Document, 'id' | 'userId' | 'teamId'>;
|
|
|
|
/**
|
|
* Whether the user is platform, or has permission to use platform features on
|
|
* behalf of their team.
|
|
*
|
|
* It is assumed that the provided user is part of the provided team.
|
|
*/
|
|
export const isDocumentPlatform = async ({
|
|
userId,
|
|
teamId,
|
|
}: IsDocumentPlatformOptions): Promise<boolean> => {
|
|
let subscriptions: Subscription[] = [];
|
|
|
|
if (!IS_BILLING_ENABLED()) {
|
|
return true;
|
|
}
|
|
|
|
if (teamId) {
|
|
subscriptions = await prisma.team
|
|
.findFirstOrThrow({
|
|
where: {
|
|
id: teamId,
|
|
},
|
|
select: {
|
|
owner: {
|
|
include: {
|
|
Subscription: true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
.then((team) => team.owner.Subscription);
|
|
} else {
|
|
subscriptions = await prisma.user
|
|
.findFirstOrThrow({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
select: {
|
|
Subscription: true,
|
|
},
|
|
})
|
|
.then((user) => user.Subscription);
|
|
}
|
|
|
|
if (subscriptions.length === 0) {
|
|
return false;
|
|
}
|
|
|
|
const platformPlanPriceIds = await getPlatformPlanPriceIds();
|
|
|
|
return subscriptionsContainsActivePlan(subscriptions, platformPlanPriceIds);
|
|
};
|