diff --git a/apps/www/components/SOC2RequestForm.tsx b/apps/www/components/SOC2RequestForm.tsx new file mode 100644 index 00000000000..c0b06486b93 --- /dev/null +++ b/apps/www/components/SOC2RequestForm.tsx @@ -0,0 +1,197 @@ +import { Button, Form, Input, Select } from '@supabase/ui' +import { useState } from 'react' +import countries from '~/data/Countries.json' +import supabase from '~/lib/supabase' + +const INITIAL_VALUES = { + companyName: '', + contactFirstName: '', + contactLastName: '', + contactEmail: '', + contactPhone: '', + companySize: '', + details: '', + country: 'US', +} + +const validate = (values: any) => { + const errors: any = {} + + if (!values.companyName) { + errors.companyName = 'Required' + } + + if (!values.contactFirstName) { + errors.contactFirstName = 'Required' + } + + if (!values.contactLastName) { + errors.contactLastName = 'Required' + } + + if (!values.contactEmail) { + errors.contactEmail = 'Required' + } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(values.contactEmail)) { + errors.contactEmail = 'Invalid email address' + } + + return errors +} + +const SOC2RequestForm = () => { + const [error, setError] = useState() + const [formSubmitted, setFormSubmitted] = useState(false) + + const handleFormSubmit = async (values: typeof INITIAL_VALUES, { resetForm }: any) => { + const { error } = await supabase.from('soc2_requests').insert([ + { + company_name: values.companyName, + contact_name: `${values.contactFirstName} ${values.contactLastName}`, + contact_first_name: values.contactFirstName, + contact_last_name: values.contactLastName, + contact_email: values.contactEmail, + contact_phone: values.contactPhone, + company_size: values.companySize, + details: values.details, + country: values.country, + }, + ]) + + if (!error) { + resetForm() + setFormSubmitted(true) + } else { + setError(error.message) + } + } + + return ( +
+ {formSubmitted ? ( +

+ Thank you for your submission! A member from the Supabase team will reach out to you + shortly! +

+ ) : ( + <> +
+ {({ isSubmitting }: any) => ( +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ )} +
+ {error &&

Error: {error}

} + + )} +
+ ) +} + +export default SOC2RequestForm diff --git a/apps/www/pages/legal/dpa.tsx b/apps/www/pages/legal/dpa.tsx index 746aedf0e03..76443ea7637 100644 --- a/apps/www/pages/legal/dpa.tsx +++ b/apps/www/pages/legal/dpa.tsx @@ -20,7 +20,6 @@ const DPA = () => { }) const handleFormSubmit = async (values: typeof INITIAL_VALUES, { resetForm }: any) => { - console.log('handleFormSubmit ran', values) try { setError(undefined) const { error } = await supabase @@ -31,7 +30,7 @@ const DPA = () => { resetForm() setFormSubmitted(true) - window.open('https://supabase.com/downloads/docs/legal/dpa.pdf', '_blank') + window.open('https://supabase.com/downloads/docs/Supabase+DPA.pdf', '_blank') } catch (error: any) { setError(error.message) } @@ -58,7 +57,8 @@ const DPA = () => { {formSubmitted ? (

- A new tab should have opened with the DPA document + Thank you for your submission! A new tab should have opened with the DPA + document

) : (
{ htmlType="submit" type="default" iconRight={} + className="mr-1" loading={isSubmitting} > Download DPA document diff --git a/apps/www/pages/legal/soc2.tsx b/apps/www/pages/legal/soc2.tsx index f33c12b6ebf..c58ebe4dfef 100644 --- a/apps/www/pages/legal/soc2.tsx +++ b/apps/www/pages/legal/soc2.tsx @@ -1,40 +1,10 @@ -import * as Yup from 'yup' import Link from 'next/link' -import { useState } from 'react' -import { Button, Form, Input } from '@supabase/ui' - -import supabase from '~/lib/supabase' import CTABanner from 'components/CTABanner/index' import Layout from '~/components/Layouts/Default' import SectionContainer from '~/components/Layouts/SectionContainer' +import SOC2RequestForm from '~/components/SOC2RequestForm' const SOC2 = () => { - const [email, setEmail] = useState('') - const [error, setError] = 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', values) - try { - setError(undefined) - const { error } = await supabase - .from('soc2_downloads') - .insert([{ contact_email: values.email, document: 'soc2' }]) - - if (error) throw error - - resetForm() - setFormSubmitted(true) - } catch (error: any) { - setError(error.message) - } - } return ( @@ -49,49 +19,12 @@ const SOC2 = () => {

- You can request for our latest SOC 2 document through our{' '} + You can request for our latest SOC 2 document either through our{' '} security portal, or by submitting - your email here. + your request here.

- {formSubmitted ? ( -

- Thank you for your submission! A member from the Supabase team will reach out to - you shortly! -

- ) : ( - - {({ isSubmitting }: any) => ( - <> - setEmail(e.target.value)} - type="email" - name="email" - id="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" - actions={ - - } - /> - {error &&

{error}

} - - )} - - )} + diff --git a/apps/www/public/downloads/docs/Supabase+DPA.pdf b/apps/www/public/downloads/docs/Supabase+DPA.pdf new file mode 100644 index 00000000000..5f2492f04a1 Binary files /dev/null and b/apps/www/public/downloads/docs/Supabase+DPA.pdf differ diff --git a/apps/www/supabase/functions/hubspot-notification/index.ts b/apps/www/supabase/functions/hubspot-notification/index.ts index 220cd3258c8..7cb06314695 100644 --- a/apps/www/supabase/functions/hubspot-notification/index.ts +++ b/apps/www/supabase/functions/hubspot-notification/index.ts @@ -5,7 +5,7 @@ const HUBSPOT_PORTAL = Deno.env.get('HUBSPOT_PORTAL') const PARTNER_FORM_ID = Deno.env.get('PARTNER_FORM_ID') const ENTERPRISE_FORM_ID = Deno.env.get('ENTERPRISE_FORM_ID') const DPA_FORM_ID = Deno.env.get('DPA_FORM_ID') -const SOC2_FORM_ID = Deno.env.get('DPA_FORM_ID') +const SOC2_FORM_ID = Deno.env.get('SOC2_FORM_ID') serve(async (req) => { const requestSecret = req.headers.get('x-function-secret') @@ -28,7 +28,6 @@ serve(async (req) => { const jobtitle = input.record.title const website = input.record.website const partner_gallery_type = input.record.type - const document = input.document let formData: object = { email } @@ -36,6 +35,7 @@ serve(async (req) => { case 'partner_contacts': formData = { ...formData, jobtitle, website, partner_gallery_type } break + case 'soc2_requests': case 'enterprise_contacts': formData = { ...formData, @@ -50,9 +50,11 @@ serve(async (req) => { firstName, } break - case 'soc2_downloads': case 'dpa_downloads': - formData = { ...formData, document } + formData = { ...formData } + break + default: + break } const fields: { objectTypeId: '0-1'; name: string; value: string }[] = [] @@ -60,7 +62,14 @@ serve(async (req) => { fields.push({ objectTypeId: '0-1', name: key, value: value || 'NOT_PROVIDED' }) } - const formId = input.table === 'partner_contacts' ? PARTNER_FORM_ID : ENTERPRISE_FORM_ID + const formId = + input.table === 'partner_contacts' + ? PARTNER_FORM_ID + : input.table === 'dpa_downloads' + ? DPA_FORM_ID + : input.table === 'soc2_requests' + ? SOC2_FORM_ID + : ENTERPRISE_FORM_ID // Using HubSpot's submit data to a form API // https://legacydocs.hubspot.com/docs/methods/forms/submit_form