From e05eaffb61e2f1ed98e9b4b5a00293da47bcae6e Mon Sep 17 00:00:00 2001 From: Mythie Date: Fri, 1 Sep 2023 18:43:53 +1000 Subject: [PATCH] feat: store profile signature --- .../src/app/(signing)/sign/[token]/page.tsx | 5 +++- .../app/(signing)/sign/[token]/provider.tsx | 6 ++--- apps/web/src/components/forms/profile.tsx | 1 + .../lib/server-only/user/update-profile.ts | 9 ++----- .../migration.sql | 2 ++ packages/prisma/schema.prisma | 24 +++++++++---------- 6 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 packages/prisma/migrations/20230901083000_add_user_signature_column/migration.sql diff --git a/apps/web/src/app/(signing)/sign/[token]/page.tsx b/apps/web/src/app/(signing)/sign/[token]/page.tsx index d3329ff79..9fd1c3a51 100644 --- a/apps/web/src/app/(signing)/sign/[token]/page.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/page.tsx @@ -3,6 +3,7 @@ import { notFound } from 'next/navigation'; import { match } from 'ts-pattern'; import { PDF_VIEWER_PAGE_SELECTOR } from '@documenso/lib/constants/pdf-viewer'; +import { getServerComponentSession } from '@documenso/lib/next-auth/get-server-session'; import { getDocumentAndSenderByToken } from '@documenso/lib/server-only/document/get-document-by-token'; import { viewedDocument } from '@documenso/lib/server-only/document/viewed-document'; import { getFieldsForToken } from '@documenso/lib/server-only/field/get-fields-for-token'; @@ -42,10 +43,12 @@ export default async function SigningPage({ params: { token } }: SigningPageProp return notFound(); } + const user = await getServerComponentSession(); + const documentUrl = `data:application/pdf;base64,${document.document}`; return ( - +

{document.title} diff --git a/apps/web/src/app/(signing)/sign/[token]/provider.tsx b/apps/web/src/app/(signing)/sign/[token]/provider.tsx index 40d2bd0bb..454007cb0 100644 --- a/apps/web/src/app/(signing)/sign/[token]/provider.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/provider.tsx @@ -28,9 +28,9 @@ export const useRequiredSigningContext = () => { }; export interface SigningProviderProps { - fullName?: string; - email?: string; - signature?: string; + fullName?: string | null; + email?: string | null; + signature?: string | null; children: React.ReactNode; } diff --git a/apps/web/src/components/forms/profile.tsx b/apps/web/src/components/forms/profile.tsx index 5b4045abb..aaab1e9ae 100644 --- a/apps/web/src/components/forms/profile.tsx +++ b/apps/web/src/components/forms/profile.tsx @@ -118,6 +118,7 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => { render={({ field: { onChange } }) => ( onChange(v ?? '')} /> )} diff --git a/packages/lib/server-only/user/update-profile.ts b/packages/lib/server-only/user/update-profile.ts index 437f366fa..a28fd21c5 100644 --- a/packages/lib/server-only/user/update-profile.ts +++ b/packages/lib/server-only/user/update-profile.ts @@ -6,12 +6,7 @@ export type UpdateProfileOptions = { signature: string; }; -export const updateProfile = async ({ - userId, - name, - // TODO: Actually use signature - signature: _signature, -}: UpdateProfileOptions) => { +export const updateProfile = async ({ userId, name, signature }: UpdateProfileOptions) => { // Existence check await prisma.user.findFirstOrThrow({ where: { @@ -25,7 +20,7 @@ export const updateProfile = async ({ }, data: { name, - // signature, + signature, }, }); diff --git a/packages/prisma/migrations/20230901083000_add_user_signature_column/migration.sql b/packages/prisma/migrations/20230901083000_add_user_signature_column/migration.sql new file mode 100644 index 000000000..4b660cd19 --- /dev/null +++ b/packages/prisma/migrations/20230901083000_add_user_signature_column/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "signature" TEXT; diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index 8e4ff31f0..574349aaf 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -14,18 +14,18 @@ enum IdentityProvider { } model User { - id Int @id @default(autoincrement()) - name String? - email String @unique - emailVerified DateTime? - password String? - source String? - identityProvider IdentityProvider @default(DOCUMENSO) - accounts Account[] - sessions Session[] - Document Document[] - Subscription Subscription[] - PasswordResetToken PasswordResetToken[] + id Int @id @default(autoincrement()) + name String? + email String @unique + emailVerified DateTime? + password String? + source String? + signature String? + identityProvider IdentityProvider @default(DOCUMENSO) + accounts Account[] + sessions Session[] + Document Document[] + Subscription Subscription[] } enum SubscriptionStatus {