-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from eight-labs/fix/form-submsission
fix: form submission empty
- Loading branch information
Showing
12 changed files
with
135 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use client"; | ||
|
||
import { useCopyToClipboard } from "~/lib/hooks/use-copy-to-clipboard"; | ||
import { Copy } from "lucide-react"; | ||
import React from "react"; | ||
import { toast } from "sonner"; | ||
|
||
type CopyFormIdProps = { | ||
formId: string; | ||
}; | ||
|
||
export default function CopyFormId({ formId }: CopyFormIdProps) { | ||
const [_, copy] = useCopyToClipboard(); | ||
|
||
return ( | ||
<div className="mt-2 flex items-center gap-2"> | ||
<span className="inline-flex items-center rounded-lg bg-muted px-2 py-0.5 text-sm font-medium"> | ||
{formId} | ||
</span> | ||
<Copy | ||
onClick={() => | ||
copy(formId).then(() => { | ||
toast("Copied to Clipboard", { | ||
icon: <Copy className="h-4 w-4" />, | ||
}); | ||
}) | ||
} | ||
className="h-4 w-4 text-muted-foreground" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useCallback, useState } from "react"; | ||
|
||
type CopiedValue = string | null; | ||
type CopyFn = (text: string) => Promise<boolean>; | ||
|
||
export function useCopyToClipboard(): [CopiedValue, CopyFn] { | ||
const [copiedText, setCopiedText] = useState<CopiedValue>(null); | ||
|
||
const copy: CopyFn = useCallback(async (text) => { | ||
if (!navigator?.clipboard) { | ||
console.warn("Clipboard not supported"); | ||
return false; | ||
} | ||
|
||
try { | ||
await navigator.clipboard.writeText(text); | ||
setCopiedText(text); | ||
return true; | ||
} catch (error) { | ||
setCopiedText(null); | ||
return false; | ||
} | ||
}, []); | ||
|
||
return [copiedText, copy]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters