diff --git a/apps/web/src/app/(dashboard)/settings/profile/page.tsx b/apps/web/src/app/(dashboard)/settings/profile/page.tsx index 460b0b8bb..cb64fb9cd 100644 --- a/apps/web/src/app/(dashboard)/settings/profile/page.tsx +++ b/apps/web/src/app/(dashboard)/settings/profile/page.tsx @@ -1,24 +1,19 @@ import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-component-session'; -import { SigningProvider } from '~/app/(signing)/sign/[token]/provider'; import { ProfileForm } from '~/components/forms/profile'; export default async function ProfileSettingsPage() { const { user } = await getRequiredServerComponentSession(); return ( - -
-

Profile

+
+

Profile

-

- Here you can edit your personal details. -

+

Here you can edit your personal details.

-
+
- -
- + +
); } diff --git a/apps/web/src/components/forms/profile.tsx b/apps/web/src/components/forms/profile.tsx index c8a3d5505..47adf2615 100644 --- a/apps/web/src/components/forms/profile.tsx +++ b/apps/web/src/components/forms/profile.tsx @@ -17,8 +17,6 @@ import { Label } from '@documenso/ui/primitives/label'; import { SignaturePad } from '@documenso/ui/primitives/signature-pad'; import { useToast } from '@documenso/ui/primitives/use-toast'; -import { useRequiredSigningContext } from '~/app/(signing)/sign/[token]/provider'; - import { FormErrorMessage } from '../form/form-error-message'; export const ZProfileFormSchema = z.object({ @@ -38,8 +36,6 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => { const { toast } = useToast(); - const { signature, setSignature } = useRequiredSigningContext(); - const { register, control, @@ -125,8 +121,6 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => { containerClassName="rounded-lg border bg-background" defaultValue={user.signature ?? undefined} onChange={(v) => onChange(v ?? '')} - signature={signature} - setSignature={setSignature} /> )} /> diff --git a/packages/lib/server-only/pdf/insert-field-in-pdf.ts b/packages/lib/server-only/pdf/insert-field-in-pdf.ts index f07c8f6d2..53ebbaf6c 100644 --- a/packages/lib/server-only/pdf/insert-field-in-pdf.ts +++ b/packages/lib/server-only/pdf/insert-field-in-pdf.ts @@ -40,19 +40,10 @@ export const insertFieldInPDF = async (pdf: PDFDocument, field: FieldWithSignatu const fieldX = pageWidth * (Number(field.positionX) / 100); const fieldY = pageHeight * (Number(field.positionY) / 100); - // const url = - // 'https://fonts.gstatic.com/s/dancingscript/v25/If2cXTr6YS-zF4S-kcSWSVi_sxjsohD9F50Ruu7BMSoHTQ.ttf'; - - const url = 'https://fonts.gstatic.com/s/caveat/v18/WnznHAc5bAfYB2QRah7pcpNvOx-pjfJ9SII.ttf'; - const googleFont = await fetch(url).then(async (res) => res.arrayBuffer()); - - const font = await pdf.embedFont(isSignatureField ? googleFont : StandardFonts.Helvetica, { - subset: true, - features: { liga: false }, - }); + const font = await pdf.embedFont(isSignatureField ? fontCaveat : StandardFonts.Helvetica); if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) { - await pdf.embedFont(googleFont, { subset: true, features: { liga: false } }); + await pdf.embedFont(fontCaveat); } const CUSTOM_TEXT = field.customText || field.Signature?.typedSignature || ''; diff --git a/packages/ui/primitives/signature-pad/signature-pad.tsx b/packages/ui/primitives/signature-pad/signature-pad.tsx index cb23b0c3d..d11a6d81c 100644 --- a/packages/ui/primitives/signature-pad/signature-pad.tsx +++ b/packages/ui/primitives/signature-pad/signature-pad.tsx @@ -3,50 +3,27 @@ import type { HTMLAttributes, MouseEvent, PointerEvent, TouchEvent } from 'react'; import { useEffect, useMemo, useRef, useState } from 'react'; -import { zodResolver } from '@hookform/resolvers/zod'; import type { StrokeOptions } from 'perfect-freehand'; import { getStroke } from 'perfect-freehand'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; import { cn } from '../../lib/utils'; -import { Input } from '../input'; import { getSvgPathFromStroke } from './helper'; import { Point } from './point'; const DPI = 2; export type SignaturePadProps = Omit, 'onChange'> & { - signature: string | null; - setSignature: (_value: string | null) => void; onChange?: (_signatureDataUrl: string | null) => void; containerClassName?: string; clearSignatureClassName?: string; - onFormSubmit?: (_data: TSigningpadSchema) => void; }; -const ZSigningpadSchema = z.union([ - z.object({ - signatureDataUrl: z.string().min(1), - signatureText: z.null().or(z.string().max(0)), - }), - z.object({ - signatureDataUrl: z.null().or(z.string().max(0)), - signatureText: z.string().trim().min(1), - }), -]); - -export type TSigningpadSchema = z.infer; - export const SignaturePad = ({ className, containerClassName, defaultValue, clearSignatureClassName, - onFormSubmit, onChange, - signature, - setSignature, ...props }: SignaturePadProps) => { const $el = useRef(null); @@ -54,24 +31,6 @@ export const SignaturePad = ({ const [isPressed, setIsPressed] = useState(false); const [points, setPoints] = useState([]); - const { - register, - handleSubmit, - setValue, - watch, - formState: { isSubmitting }, - } = useForm({ - mode: 'onChange', - defaultValues: { - signatureDataUrl: signature || null, - signatureText: '', - }, - resolver: zodResolver(ZSigningpadSchema), - }); - - // const signatureDataUrl = watch('signatureDataUrl'); - const signatureText = watch('signatureText'); - const perfectFreehandOptions = useMemo(() => { const size = $el.current ? Math.min($el.current.height, $el.current.width) * 0.03 : 10; @@ -247,84 +206,28 @@ export const SignaturePad = ({ }, [defaultValue]); return ( -
undefined))}> -
-
- {!signatureText && signature && ( - onMouseMove(event)} - onPointerDown={(event) => onMouseDown(event)} - onPointerUp={(event) => onMouseUp(event)} - onPointerLeave={(event) => onMouseLeave(event)} - onPointerEnter={(event) => onMouseEnter(event)} - {...props} - /> - )} +
+ onMouseMove(event)} + onPointerDown={(event) => onMouseDown(event)} + onPointerUp={(event) => onMouseUp(event)} + onPointerLeave={(event) => onMouseLeave(event)} + onPointerEnter={(event) => onMouseEnter(event)} + {...props} + /> - {signatureText && ( -

- {signatureText} -

- )} -
- -
e.stopPropagation()} +
+ -
*/} -
- -
- -
+ Clear Signature +
- +
); };