The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update setupOrg to use create organization mutation
Joshen Lim2350efa81580
diff --git a/studio/data/organizations/organization-create-mutation.ts b/studio/data/organizations/organization-create-mutation.tsindex 7e1fb5fe28d..d3aa1e97de7 100644--- a/studio/data/organizations/organization-create-mutation.ts+++ b/studio/data/organizations/organization-create-mutation.ts@@ -7,7 +7,7 @@ import { organizationKeys } from './keys'export type OrganizationCreateVariables = {name: string- kind: string+ kind?: stringsize?: string}@@ -42,7 +42,7 @@ export const useOrganizationCreateMutation = ({},async onError(data, variables, context) {if (onError === undefined) {- toast.error(`Failed to create new organization: ${data.message}`)+ toast.error(`Failed to create organization: ${data.message}`)} else {onError(data, variables, context)}diff --git a/studio/pages/vercel/setupOrg.tsx b/studio/pages/vercel/setupOrg.tsxindex fa47213c7ab..e2911b40e59 100644--- a/studio/pages/vercel/setupOrg.tsx+++ b/studio/pages/vercel/setupOrg.tsx@@ -2,13 +2,11 @@ import { runInAction } from 'mobx'import { observer, useLocalObservable } from 'mobx-react-lite'import { useRouter } from 'next/router'import { ChangeEvent, createContext, useContext, useEffect, useState } from 'react'+import { Button, Input, Select } from 'ui'import VercelIntegrationLayout from 'components/layouts/VercelIntegrationLayout'+import { useOrganizationCreateMutation } from 'data/organizations/organization-create-mutation'import { useOrganizationsQuery } from 'data/organizations/organizations-query'-import { useStore } from 'hooks'-import { post } from 'lib/common/fetch'-import { API_URL } from 'lib/constants'-import { Button, Input, Select } from 'ui'const PageContext = createContext(null)function SetupOrg() {@@ -74,38 +72,19 @@ function SetupOrg() {export default observer(SetupOrg)const CreateOrganization = observer(({}) => {- const PageState: any = useContext(PageContext)const router = useRouter()-- const { ui, app } = useStore()+ const PageState: any = useContext(PageContext)const { data: organizations } = useOrganizationsQuery()const [orgName, setOrgName] = useState('')- const [loading, setLoading] = useState(false)- async function onClick() {- setLoading(true)- const response = await post(`${API_URL}/organizations`, {- name: orgName,- })- if (response.error) {- ui.setNotification({- category: 'error',- message: `Failed to set up organization: ${response.error.message}`,- })- setLoading(false)- } else {- const org = response+ const { mutate: createOrganization, isLoading: isCreating } = useOrganizationCreateMutation({+ onSuccess: (org) => {PageState.selectedOrg = org-const query = new URLSearchParams(PageState.queryParams).toString()router.push(`/vercel/setupProject?${query}`)- }- }-- function onOrgNameChange(e: any) {- setOrgName(e.target.value)- }+ },+ })return (<div className="">@@ -126,10 +105,14 @@ const CreateOrganization = observer(({}) => {placeholder="Organization name"descriptionText="What's the name of your company or team?"value={orgName}- onChange={onOrgNameChange}+ onChange={(e: any) => setOrgName(e.target.value)}/></div>- <Button disabled={loading || orgName == ''} loading={loading} onClick={onClick}>+ <Button+ disabled={isCreating || orgName === ''}+ loading={isCreating}+ onClick={() => createOrganization({ name: orgName })}+ >Create organization</Button></div>