From c71a89d1b7f79f8405bb228007ec1a6f809c2691 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu Date: Thu, 5 Oct 2023 12:21:34 +0000 Subject: [PATCH 1/9] fix: Add gitpod configuration --- .gitpod.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..b5ab15cb7 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,40 @@ +tasks: + - init: | + cp .env.example .env && + set -a; source .env && + npm run dx && + sed -i -e "s|http://localhost:3000|$(gp url 3000)|" .env \ + -e "s|http://localhost:3001|$(gp url 3001)|" .env \ + -e "s|http://localhost:9000|$(gp url 9000)|" .env + command: npm run dev + +ports: + - port: 3000 + visibility: public + onOpen: open-preview + - port: 3001 + visibility: public + onOpen: open-preview + - port: 9000 + visibility: public + onOpen: ignore + - port: 1100 + visibility: private + onOpen: ignore + - port: 2500 + visibility: private + onOpen: ignore + + +github: + prebuilds: + master: true + pullRequests: true + pullRequestsFromForks: true + addCheck: true + addComment: true + addBadge: true + +vscode: + extensions: + - bradlc.vscode-tailwindcss From 04a80b7c037c1e45c9a877f973ad7878d1461896 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:06:34 +0530 Subject: [PATCH 2/9] fix: add gitpod configuration --- .gitpod.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index b5ab15cb7..9bfc333db 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,12 +1,13 @@ tasks: - init: | + npm i && + npm run dx:up && cp .env.example .env && set -a; source .env && - npm run dx && sed -i -e "s|http://localhost:3000|$(gp url 3000)|" .env \ -e "s|http://localhost:3001|$(gp url 3001)|" .env \ -e "s|http://localhost:9000|$(gp url 9000)|" .env - command: npm run dev + command: npm run d ports: - port: 3000 @@ -38,3 +39,6 @@ github: vscode: extensions: - bradlc.vscode-tailwindcss + - esbenp.prettier-vscode + - Prisma.prisma + From cc65537ea38e91119715c234a4cedef91cd134fc Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Fri, 6 Oct 2023 23:03:13 +0530 Subject: [PATCH 3/9] fix: Add gitpod configuration --- .gitpod.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitpod.yml b/.gitpod.yml index 9bfc333db..0ad9299b2 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -25,6 +25,9 @@ ports: - port: 2500 visibility: private onOpen: ignore + - port: 54320 + visibility: private + onOpen: ignore github: From 4e010c562478c824b4401547d36215ffe1a22aaa Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:58:12 +0530 Subject: [PATCH 4/9] fix : add gittpod configuration --- .gitpod.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 0ad9299b2..b03003160 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -4,9 +4,9 @@ tasks: npm run dx:up && cp .env.example .env && set -a; source .env && - sed -i -e "s|http://localhost:3000|$(gp url 3000)|" .env \ - -e "s|http://localhost:3001|$(gp url 3001)|" .env \ - -e "s|http://localhost:9000|$(gp url 9000)|" .env + export NEXTAUTH_URL="$(gp url 3000)" && + export NEXT_PUBLIC_WEBAPP_URL="$(gp url 3000)" && + export NEXT_PUBLIC_MARKETING_URL="$(gp url 3001)" command: npm run d ports: @@ -25,8 +25,8 @@ ports: - port: 2500 visibility: private onOpen: ignore - - port: 54320 - visibility: private + - port: 54320 + visibility: private onOpen: ignore @@ -41,7 +41,15 @@ github: vscode: extensions: + - aaron-bond.better-comments - bradlc.vscode-tailwindcss + - dbaeumer.vscode-eslint - esbenp.prettier-vscode + - mikestead.dotenv + - unifiedjs.vscode-mdx + - GitHub.copilot-chat + - GitHub.copilot-labs + - GitHub.copilot + - GitHub.vscode-pull-request-github - Prisma.prisma - + - VisualStudioExptTeam.vscodeintellicode From 2ea5ff2c94569601f28830145158f2f278b62d68 Mon Sep 17 00:00:00 2001 From: Abhinav-Developer-23 <145282438+Abhinav-Developer-23@users.noreply.github.com> Date: Thu, 12 Oct 2023 06:03:01 +0530 Subject: [PATCH 5/9] fix: bypass signature fix (#536) (#547) --- .../app/(signing)/sign/[token]/signature-field.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/(signing)/sign/[token]/signature-field.tsx b/apps/web/src/app/(signing)/sign/[token]/signature-field.tsx index 020af41c2..01923bd6c 100644 --- a/apps/web/src/app/(signing)/sign/[token]/signature-field.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/signature-field.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useMemo, useState, useTransition } from 'react'; +import { useEffect, useMemo, useState, useTransition } from 'react'; import { useRouter } from 'next/navigation'; @@ -48,6 +48,7 @@ export const SignatureField = ({ field, recipient }: SignatureFieldProps) => { const [showSignatureModal, setShowSignatureModal] = useState(false); const [localSignature, setLocalSignature] = useState(null); + const [isLocalSignatureSet, setIsLocalSignatureSet] = useState(false); const state = useMemo(() => { if (!field.inserted) { @@ -61,9 +62,16 @@ export const SignatureField = ({ field, recipient }: SignatureFieldProps) => { return 'signed-text'; }, [field.inserted, signature?.signatureImageAsBase64]); + useEffect(() => { + if (!showSignatureModal && !isLocalSignatureSet) { + setLocalSignature(null); + } + }, [showSignatureModal, isLocalSignatureSet]); + const onSign = async (source: 'local' | 'provider' = 'provider') => { try { if (!providedSignature && !localSignature) { + setIsLocalSignatureSet(false); setShowSignatureModal(true); return; } @@ -178,6 +186,7 @@ export const SignatureField = ({ field, recipient }: SignatureFieldProps) => { disabled={!localSignature} onClick={() => { setShowSignatureModal(false); + setIsLocalSignatureSet(true); void onSign('local'); }} > From eb5f5f7a90ec2ca8e690a1135fc721a5a3ab7b6f Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Thu, 12 Oct 2023 08:38:26 +0530 Subject: [PATCH 6/9] fix: background color of signature page (#487) --- apps/web/src/components/forms/profile.tsx | 3 ++- apps/web/src/components/forms/signup.tsx | 3 ++- packages/ui/primitives/signature-pad/signature-pad.tsx | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/forms/profile.tsx b/apps/web/src/components/forms/profile.tsx index 0082147b4..0630bfdd1 100644 --- a/apps/web/src/components/forms/profile.tsx +++ b/apps/web/src/components/forms/profile.tsx @@ -117,7 +117,8 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => { name="signature" render={({ field: { onChange } }) => ( onChange(v ?? '')} /> diff --git a/apps/web/src/components/forms/signup.tsx b/apps/web/src/components/forms/signup.tsx index 7d8100c26..a1f3ab81e 100644 --- a/apps/web/src/components/forms/signup.tsx +++ b/apps/web/src/components/forms/signup.tsx @@ -147,7 +147,8 @@ export const SignUpForm = ({ className }: SignUpFormProps) => { name="signature" render={({ field: { onChange } }) => ( onChange(v ?? '')} /> )} diff --git a/packages/ui/primitives/signature-pad/signature-pad.tsx b/packages/ui/primitives/signature-pad/signature-pad.tsx index 9463e3ddb..107627240 100644 --- a/packages/ui/primitives/signature-pad/signature-pad.tsx +++ b/packages/ui/primitives/signature-pad/signature-pad.tsx @@ -22,10 +22,12 @@ const DPI = 2; export type SignaturePadProps = Omit, 'onChange'> & { onChange?: (_signatureDataUrl: string | null) => void; + containerClassName?: string; }; export const SignaturePad = ({ className, + containerClassName, defaultValue, onChange, ...props @@ -210,7 +212,7 @@ export const SignaturePad = ({ }, [defaultValue]); return ( -
+
+ onShowDocumentClick()} loading={isFetchingDocumentFile} - className="col-span-2" + className="z-10 col-span-2" > Show document diff --git a/apps/marketing/src/pages/api/trpc/[trpc].ts b/apps/marketing/src/pages/api/trpc/[trpc].ts new file mode 100644 index 000000000..a42844904 --- /dev/null +++ b/apps/marketing/src/pages/api/trpc/[trpc].ts @@ -0,0 +1,8 @@ +import * as trpcNext from '@documenso/trpc/server/adapters/next'; +import { createTrpcContext } from '@documenso/trpc/server/context'; +import { appRouter } from '@documenso/trpc/server/router'; + +export default trpcNext.createNextApiHandler({ + router: appRouter, + createContext: async ({ req, res }) => createTrpcContext({ req, res }), +}); diff --git a/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx b/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx index 4443981f8..234c222eb 100644 --- a/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx +++ b/apps/web/src/app/(dashboard)/documents/data-table-action-button.tsx @@ -6,13 +6,12 @@ import { Edit, Pencil, Share } from 'lucide-react'; import { useSession } from 'next-auth/react'; import { match } from 'ts-pattern'; +import { useCopyToClipboard } from '@documenso/lib/client-only/hooks/use-copy-to-clipboard'; import { Document, DocumentStatus, Recipient, SigningStatus, User } from '@documenso/prisma/client'; import { trpc } from '@documenso/trpc/react'; import { Button } from '@documenso/ui/primitives/button'; import { useToast } from '@documenso/ui/primitives/use-toast'; -import { useCopyToClipboard } from '~/hooks/use-copy-to-clipboard'; - export type DataTableActionButtonProps = { row: Document & { User: Pick; @@ -47,7 +46,7 @@ export const DataTableActionButton = ({ row }: DataTableActionButtonProps) => { documentId: row.id, }); - await copyToClipboard(`${window.location.origin}/share/${slug}`).catch(() => null); + await copyToClipboard(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/share/${slug}`).catch(() => null); toast({ title: 'Copied to clipboard', diff --git a/apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx b/apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx index 2fb06833b..8963058a6 100644 --- a/apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx +++ b/apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx @@ -18,6 +18,7 @@ import { } from 'lucide-react'; import { useSession } from 'next-auth/react'; +import { useCopyToClipboard } from '@documenso/lib/client-only/hooks/use-copy-to-clipboard'; import { getFile } from '@documenso/lib/universal/upload/get-file'; import { Document, DocumentStatus, Recipient, User } from '@documenso/prisma/client'; import { DocumentWithData } from '@documenso/prisma/types/document-with-data'; @@ -32,8 +33,6 @@ import { } from '@documenso/ui/primitives/dropdown-menu'; import { useToast } from '@documenso/ui/primitives/use-toast'; -import { useCopyToClipboard } from '~/hooks/use-copy-to-clipboard'; - import { DeleteDraftDocumentDialog } from './delete-draft-document-dialog'; export type DataTableActionDropdownProps = { @@ -73,7 +72,7 @@ export const DataTableActionDropdown = ({ row }: DataTableActionDropdownProps) = documentId: row.id, }); - await copyToClipboard(`${window.location.origin}/share/${slug}`).catch(() => null); + await copyToClipboard(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/share/${slug}`).catch(() => null); toast({ title: 'Copied to clipboard', diff --git a/apps/web/src/app/(signing)/sign/[token]/complete/page.tsx b/apps/web/src/app/(signing)/sign/[token]/complete/page.tsx index 414a6624b..5402d12cb 100644 --- a/apps/web/src/app/(signing)/sign/[token]/complete/page.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/complete/page.tsx @@ -9,12 +9,11 @@ import { getFieldsForToken } from '@documenso/lib/server-only/field/get-fields-f import { getRecipientByToken } from '@documenso/lib/server-only/recipient/get-recipient-by-token'; import { DocumentStatus, FieldType } from '@documenso/prisma/client'; import { DocumentDownloadButton } from '@documenso/ui/components/document/document-download-button'; +import { DocumentShareButton } from '@documenso/ui/components/document/document-share-button'; import { SigningCard3D } from '@documenso/ui/components/signing-card'; import signingCelebration from '~/assets/signing-celebration.png'; -import { ShareButton } from './share-button'; - export type CompletedSigningPageProps = { params: { token?: string; @@ -89,7 +88,7 @@ export default async function CompletedSigningPage({ ))}
- + Promise; - -export function useCopyToClipboard(): [CopiedValue, CopyFn] { - const [copiedText, setCopiedText] = useState(null); - - const copy: CopyFn = async (text) => { - if (!navigator?.clipboard) { - console.warn('Clipboard not supported'); - return false; - } - - // Try to save to clipboard then save it in the state if worked - try { - await navigator.clipboard.writeText(text); - setCopiedText(text); - return true; - } catch (error) { - console.warn('Copy failed', error); - setCopiedText(null); - return false; - } - }; - - return [copiedText, copy]; -} diff --git a/apps/marketing/src/hooks/use-copy-to-clipboard.ts b/packages/lib/client-only/hooks/use-copy-to-clipboard.ts similarity index 100% rename from apps/marketing/src/hooks/use-copy-to-clipboard.ts rename to packages/lib/client-only/hooks/use-copy-to-clipboard.ts diff --git a/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx b/packages/ui/components/document/document-share-button.tsx similarity index 81% rename from apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx rename to packages/ui/components/document/document-share-button.tsx index c76d3d7c5..4e7ee1a94 100644 --- a/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx +++ b/packages/ui/components/document/document-share-button.tsx @@ -5,8 +5,10 @@ import { HTMLAttributes, useState } from 'react'; import { Copy, Share } from 'lucide-react'; import { FaXTwitter } from 'react-icons/fa6'; +import { useCopyToClipboard } from '@documenso/lib/client-only/hooks/use-copy-to-clipboard'; import { generateTwitterIntent } from '@documenso/lib/universal/generate-twitter-intent'; import { trpc } from '@documenso/trpc/react'; +import { cn } from '@documenso/ui/lib/utils'; import { Button } from '@documenso/ui/primitives/button'; import { Dialog, @@ -18,14 +20,12 @@ import { } from '@documenso/ui/primitives/dialog'; import { useToast } from '@documenso/ui/primitives/use-toast'; -import { useCopyToClipboard } from '~/hooks/use-copy-to-clipboard'; - -export type ShareButtonProps = HTMLAttributes & { +export type DocumentShareButtonProps = HTMLAttributes & { token: string; documentId: number; }; -export const ShareButton = ({ token, documentId }: ShareButtonProps) => { +export const DocumentShareButton = ({ token, documentId, className }: DocumentShareButtonProps) => { const { toast } = useToast(); const [, copyToClipboard] = useCopyToClipboard(); @@ -60,7 +60,7 @@ export const ShareButton = ({ token, documentId }: ShareButtonProps) => { slug = result.slug; } - await copyToClipboard(`${window.location.origin}/share/${slug}`).catch(() => null); + await copyToClipboard(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/share/${slug}`).catch(() => null); toast({ title: 'Copied to clipboard', @@ -85,7 +85,7 @@ export const ShareButton = ({ token, documentId }: ShareButtonProps) => { window.open( generateTwitterIntent( `I just ${token ? 'signed' : 'sent'} a document with @documenso. Check it out!`, - `${window.location.origin}/share/${slug}`, + `${process.env.NEXT_PUBLIC_WEBAPP_URL}/share/${slug}`, ), '_blank', ); @@ -99,7 +99,7 @@ export const ShareButton = ({ token, documentId }: ShareButtonProps) => {