The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: init dpa email capture
Jonathan Summers-Muir41a09d162a1e
diff --git a/apps/www/pages/legal/dpa.tsx b/apps/www/pages/legal/dpa.tsxindex b155a771445..cc37828586b 100644--- a/apps/www/pages/legal/dpa.tsx+++ b/apps/www/pages/legal/dpa.tsx@@ -1,10 +1,48 @@-import { Button } from '@supabase/ui'+import { Button, Form, IconDownload, Input } from 'ui'import CTABanner from 'components/CTABanner/index'-import Link from 'next/link'+import { useState } from 'react'import Layout from '~/components/Layouts/Default'import SectionContainer from '~/components/Layouts/SectionContainer'+import supabase from '~/lib/supabase'+import * as Yup from 'yup'const DPA = () => {+ const [email, setEmail] = useState('')+ const [error, setError] = useState('')+ const [message, setMessage] = useState('')+ const [formSubmitted, setFormSubmitted] = useState(false)++ const INITIAL_VALUES = {+ email: '',+ }++ const FormSchema = Yup.object().shape({+ email: Yup.string().email('Invalid email').required('Required'),+ })++ const handleFormSubmit = async (values: typeof INITIAL_VALUES, { resetForm }: any) => {+ console.log('handleFormSubmit ran')+ try {+ setError('')++ const { error } = await supabase.from('enterprise_contacts').insert([+ {+ contact_email: values.email,+ doucment: 'dpa',+ },+ ])++ if (error) throw error++ resetForm()+ setFormSubmitted(true)+ setMessage('A new tab should have opened with the DPA document')++ window.open('https://supabase.com/downloads/docs/legal/dpa.pdf', '_blank')+ } catch (error: any) {+ setError(error.message)+ }+ }return (<><Layout>@@ -20,13 +58,42 @@ const DPA = () => {</p><p>You can download the latest DPA document through our security portal.</p>- <div>- <Link href="https://security.supabase.com">- <Button size="medium" type="default">- Security portal- </Button>- </Link>- </div>++ {message ? (+ <p className="text-brand-900">{message}</p>+ ) : (+ <Form+ initialValues={INITIAL_VALUES}+ validationSchema={FormSchema}+ onSubmit={handleFormSubmit}+ >+ {({ isSubmitting }: any) => (+ <>+ <Input+ value={email}+ onChange={(e) => setEmail(e.target.value)}+ type="email"+ required+ descriptionText="We only keep a record of your email so we can update you when the document has been updated."+ placeholder="Your email address"+ error={error}+ actions={+ <Button+ htmlType="submit"+ type="default"+ iconRight={<IconDownload />}+ loading={isSubmitting}+ >+ Download DPA document+ </Button>+ }+ />+ {formSubmitted && <p>A new tab should have opened with the DPA document</p>}+ {error && <p>{error}</p>}+ </>+ )}+ </Form>+ )}</div></div></div>@@ -36,5 +103,4 @@ const DPA = () => {</>)}-export default DPAdiff --git a/apps/www/supabase/functions/hubspot-notification/index.ts b/apps/www/supabase/functions/hubspot-notification/index.tsindex 00fd315ed26..0ba3c81da16 100644--- a/apps/www/supabase/functions/hubspot-notification/index.ts+++ b/apps/www/supabase/functions/hubspot-notification/index.ts@@ -28,15 +28,7 @@ serve(async (req) => {const partner_gallery_type = input.record.typelet formData: object = {- supabase_table_id,- country,- form_note,- company,- company_size,email,- phone,- lastName,- firstName,}if (input.table === 'partner_contacts') {@@ -48,6 +40,21 @@ serve(async (req) => {}}+ if (input.table === 'enterprise_contacts') {+ formData = {+ ...formData,+ supabase_table_id,+ country,+ form_note,+ company,+ company_size,+ email,+ phone,+ lastName,+ firstName,+ }+ }+const fields: { objectTypeId: '0-1'; name: string; value: string }[] = []for (const [key, value] of Object.entries(formData)) {fields.push({ objectTypeId: '0-1', name: key, value: value || 'NOT_PROVIDED' })