Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Scaffold success state logic for enterprise request page

Joshen Limce263e1d5b51
diff --git a/studio/components/interfaces/Billing/EnterpriseRequest.tsx b/studio/components/interfaces/Billing/EnterpriseRequest.tsx
index 886f4d0463a..4c4bd21ae12 100644
--- a/studio/components/interfaces/Billing/EnterpriseRequest.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseRequest.tsx
@@ -1,4 +1,4 @@
-import { FC } from 'react'
+import { FC, useState } from 'react'
import { Transition } from '@headlessui/react'
import { Button, Form, Input, IconArrowLeft } from '@supabase/ui'
@@ -16,6 +16,8 @@ const EnterpriseRequest: FC<Props> = ({ onSelectBack }) => {
const { profile, selectedProject } = ui
const projectRef = selectedProject?.ref
+ const [isSuccessful, setIsSuccessful] = useState(false)
+
const initialValues = {
name: `${profile?.first_name} ${profile?.last_name}`,
email: profile?.primary_email,
@@ -31,18 +33,31 @@ const EnterpriseRequest: FC<Props> = ({ onSelectBack }) => {
const onSubmit = async (values: any, { setSubmitting }: any) => {
setSubmitting(true)
- const res = await post(`${API_URL}/projects/${projectRef}/subscription/enterprise`, {
- name: values.name,
- email: values.email,
- company: values.company,
- message: values.message,
- })
- if (!res.error) {
- // Do something
+ await timeout(1000)
+ const res = {} as any
+ // const res = await post(`${API_URL}/projects/${projectRef}/subscription/enterprise`, {
+ // name: values.name,
+ // email: values.email,
+ // company: values.company,
+ // message: values.message,
+ // })
+ if (res.error) {
+ ui.setNotification({
+ category: 'error',
+ message: `Unable to send request: ${res.error.message}`,
+ error: res.error,
+ })
+ } else {
+ console.log('Done')
+ setIsSuccessful(true)
}
setSubmitting(false)
}
+ if (isSuccessful) {
+ return <div>Hello</div>
+ }
+
return (
<Transition
show
diff --git a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
index b7bc9c903cc..5c035c9df01 100644
--- a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
+++ b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx
@@ -62,6 +62,7 @@ const ExitSurvey: FC<Props> = ({ onSelectBack }) => {
ui.setNotification({
category: 'error',
message: `Failed to cancel subscription: ${res?.error?.message}`,
+ error: res.error,
})
} else {
console.log('Succesfully updated subscription')