MCPcopy Create free account
hub / github.com/alanagoyal/docbase / Share

Function Share

components/share.tsx:32–250  ·  view source on GitHub ↗
({
  investment,
  onEmailSent,
  isOpen,
  onOpenChange,
  account,
}: {
  investment: UserInvestment
  onEmailSent: () => void
  isOpen: boolean
  onOpenChange: (open: boolean) => void
  account: User
})

Source from the content-addressed store, hash-verified

30type User = Database["public"]["Tables"]["users"]["Row"]
31
32export function Share({
33 investment,
34 onEmailSent,
35 isOpen,
36 onOpenChange,
37 account,
38}: {
39 investment: UserInvestment
40 onEmailSent: () => void
41 isOpen: boolean
42 onOpenChange: (open: boolean) => void
43 account: User
44}) {
45 const form = useForm({
46 defaultValues: {
47 name: "",
48 email: "",
49 },
50 })
51 const [isSending, setIsSending] = useState(false)
52 const idString =
53 typeof window !== "undefined"
54 ? `${window.location.origin}/investments/${investment.id}?step=2&sharing=true`
55 : ""
56 const supabase = createClient()
57
58 const handleCopy = () => {
59 navigator.clipboard
60 .writeText(idString)
61 .then(() => {
62 toast({
63 description: "Copied to clipboard",
64 })
65 })
66 .catch((err) => {
67 toast({
68 variant: "destructive",
69 description: "Unable to copy to clipboard",
70 })
71 clientLogger.error('Unable to copy text', { error: err })
72 })
73 }
74
75 async function onSubmit(values: { name: string; email: string }) {
76 setIsSending(true)
77
78 try {
79 // Upsert contact information
80 const { data: contactData, error: contactError } = await supabase
81 .from("contacts")
82 .upsert(
83 {
84 name: values.name,
85 email: values.email,
86 created_by: account.id,
87 is_founder: true,
88 },
89 {

Callers

nothing calls this directly

Calls 1

createClientFunction · 0.90

Tested by

no test coverage detected