Compare commits

...

2 Commits

Author SHA1 Message Date
Catalin Pit fbbb0289c3 fix: fields font-size 2025-10-01 15:10:01 +03:00
Catalin Pit c7d21c6587 fix: update personal organisation email settings (#2048) 2025-09-29 10:11:00 +03:00
11 changed files with 85 additions and 9 deletions
@@ -3,10 +3,11 @@ import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react/macro';
import { Trans } from '@lingui/react/macro';
import type { TeamGlobalSettings } from '@prisma/client';
import { DocumentVisibility } from '@prisma/client';
import { DocumentVisibility, OrganisationType } from '@prisma/client';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { useCurrentOrganisation } from '@documenso/lib/client-only/providers/organisation';
import { useSession } from '@documenso/lib/client-only/providers/session';
import { DATE_FORMATS } from '@documenso/lib/constants/date-formats';
import { DOCUMENT_SIGNATURE_TYPES, DocumentSignatureType } from '@documenso/lib/constants/document';
@@ -86,8 +87,10 @@ export const DocumentPreferencesForm = ({
}: DocumentPreferencesFormProps) => {
const { t } = useLingui();
const { user, organisations } = useSession();
const currentOrganisation = useCurrentOrganisation();
const isPersonalLayoutMode = isPersonalLayout(organisations);
const isPersonalOrganisation = currentOrganisation.type === OrganisationType.PERSONAL;
const placeholderEmail = user.email ?? 'user@example.com';
@@ -331,7 +334,7 @@ export const DocumentPreferencesForm = ({
)}
/>
{!isPersonalLayoutMode && (
{!isPersonalLayoutMode && !isPersonalOrganisation && (
<FormField
control={form.control}
name="includeSenderDetails"
@@ -157,6 +157,7 @@ export const DocumentSigningDateField = ({
'!text-right': parsedFieldMeta?.textAlign === 'right',
},
)}
style={{ fontSize: `${parsedFieldMeta?.fontSize}px` }}
>
{localDateString}
</p>
@@ -132,7 +132,10 @@ export const DocumentSigningEmailField = ({
)}
{field.inserted && (
<DocumentSigningFieldsInserted textAlign={parsedFieldMeta?.textAlign}>
<DocumentSigningFieldsInserted
textAlign={parsedFieldMeta?.textAlign}
fontSize={parsedFieldMeta?.fontSize}
>
{field.customText}
</DocumentSigningFieldsInserted>
)}
@@ -27,14 +27,20 @@ type DocumentSigningFieldsInsertedProps = {
* Defaults to left.
*/
textAlign?: 'left' | 'center' | 'right';
/**
* The font size of the field in pixels.
*/
fontSize?: number;
};
export const DocumentSigningFieldsInserted = ({
children,
textAlign = 'left',
fontSize,
}: DocumentSigningFieldsInsertedProps) => {
return (
<div className="flex h-full w-full items-center overflow-hidden">
<div className="flex h-full w-full items-center overflow-visible">
<p
className={cn(
'text-foreground w-full whitespace-pre-wrap text-left text-[clamp(0.425rem,25cqw,0.825rem)] duration-200',
@@ -43,6 +49,7 @@ export const DocumentSigningFieldsInserted = ({
'!text-right': textAlign === 'right',
},
)}
style={{ fontSize: `${fontSize}px` }}
>
{children}
</p>
@@ -139,7 +139,10 @@ export const DocumentSigningInitialsField = ({
)}
{field.inserted && (
<DocumentSigningFieldsInserted textAlign={parsedFieldMeta?.textAlign}>
<DocumentSigningFieldsInserted
textAlign={parsedFieldMeta?.textAlign}
fontSize={parsedFieldMeta?.fontSize}
>
{field.customText}
</DocumentSigningFieldsInserted>
)}
@@ -178,7 +178,10 @@ export const DocumentSigningNameField = ({
)}
{field.inserted && (
<DocumentSigningFieldsInserted textAlign={parsedFieldMeta?.textAlign}>
<DocumentSigningFieldsInserted
textAlign={parsedFieldMeta?.textAlign}
fontSize={parsedFieldMeta?.fontSize}
>
{field.customText}
</DocumentSigningFieldsInserted>
)}
@@ -253,7 +253,10 @@ export const DocumentSigningNumberField = ({
)}
{field.inserted && (
<DocumentSigningFieldsInserted textAlign={parsedFieldMeta?.textAlign}>
<DocumentSigningFieldsInserted
textAlign={parsedFieldMeta?.textAlign}
fontSize={parsedFieldMeta?.fontSize}
>
{field.customText}
</DocumentSigningFieldsInserted>
)}
@@ -250,7 +250,10 @@ export const DocumentSigningTextField = ({
)}
{field.inserted && (
<DocumentSigningFieldsInserted textAlign={parsedFieldMeta?.textAlign}>
<DocumentSigningFieldsInserted
textAlign={parsedFieldMeta?.textAlign}
fontSize={parsedFieldMeta?.fontSize}
>
{field.customText}
</DocumentSigningFieldsInserted>
)}
@@ -1,3 +1,5 @@
import { OrganisationType } from '@prisma/client';
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
@@ -104,6 +106,19 @@ export const updateOrganisationSettingsRoute = authenticatedProcedure
});
}
const isPersonalOrganisation = organisation.type === OrganisationType.PERSONAL;
const currentIncludeSenderDetails =
organisation.organisationGlobalSettings.includeSenderDetails;
const isChangingIncludeSenderDetails =
includeSenderDetails !== undefined && includeSenderDetails !== currentIncludeSenderDetails;
if (isPersonalOrganisation && isChangingIncludeSenderDetails) {
throw new AppError(AppErrorCode.INVALID_BODY, {
message: 'Personal organisations cannot update the sender details',
});
}
await prisma.organisation.update({
where: {
id: organisationId,
@@ -1,7 +1,10 @@
import { Prisma } from '@prisma/client';
import { OrganisationType } from '@prisma/client';
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
import { TEAM_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/teams';
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
import { prisma } from '@documenso/prisma';
@@ -97,6 +100,35 @@ export const updateTeamSettingsRoute = authenticatedProcedure
}
}
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId: team.organisationId,
userId: user.id,
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_ORGANISATION'],
}),
select: {
type: true,
organisationGlobalSettings: {
select: {
includeSenderDetails: true,
},
},
},
});
const isPersonalOrganisation = organisation?.type === OrganisationType.PERSONAL;
const currentIncludeSenderDetails =
organisation?.organisationGlobalSettings.includeSenderDetails;
const isChangingIncludeSenderDetails =
includeSenderDetails !== undefined && includeSenderDetails !== currentIncludeSenderDetails;
if (isPersonalOrganisation && isChangingIncludeSenderDetails) {
throw new AppError(AppErrorCode.INVALID_BODY, {
message: 'Personal teams cannot update the sender details',
});
}
await prisma.team.update({
where: {
id: teamId,
@@ -188,9 +188,11 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
}
const textAlign = fieldMeta && 'textAlign' in fieldMeta ? fieldMeta.textAlign : 'left';
const fontSize = fieldMeta && 'fontSize' in fieldMeta ? fieldMeta.fontSize : undefined;
const fontSizeStyle = fontSize ? { fontSize: `${fontSize}px` } : {};
return (
<div className="flex h-full w-full items-center overflow-hidden">
<div className="overflow-visibile flex h-full w-full items-center">
<p
className={cn(
'text-foreground w-full whitespace-pre-wrap text-left text-[clamp(0.07rem,25cqw,0.825rem)] duration-200',
@@ -200,6 +202,7 @@ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => {
'font-signature text-[clamp(0.07rem,25cqw,1.125rem)]': isSignatureField,
},
)}
style={fontSizeStyle}
>
{textToDisplay || labelToDisplay}
</p>