The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Enforce country selection in billing address if any other field is not empty
Joshen Lim68796a34e26c
diff --git a/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx b/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsxindex a75637f2b43..2c6d7cf7235 100644--- a/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx+++ b/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx@@ -57,6 +57,12 @@ const BillingAddress = () => {const onValidate = (values: any) => {const errors = {} as any+ if (+ (values.line1 || values.line2 || values.postal_code || values.state || values.city) &&+ !values.country+ ) {+ errors['country'] = 'Please select a country'+ }if (isEqual(values, initialValues)) {setIsDirty(false)} else {@@ -110,7 +116,7 @@ const BillingAddress = () => {placeholder="Address line 2"disabled={!canUpdateBillingAddress}/>- <div className="flex items-center space-x-2">+ <div className="flex space-x-2"><ListboxclassName="w-full"id="country"@@ -139,7 +145,7 @@ const BillingAddress = () => {disabled={!canUpdateBillingAddress}/></div>- <div className="flex items-center space-x-2">+ <div className="flex space-x-2"><InputclassName="w-full"id="city"diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsxindex 98951927271..aa209366fd4 100644--- a/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx+++ b/studio/components/interfaces/Organization/BillingSettingsV2/BillingAddress/BillingAddress.tsx@@ -40,6 +40,17 @@ const BillingAddress = () => {const initialValues = { city, country, line1, line2, postal_code, state }+ const validate = (values: any) => {+ const errors = {} as any+ if (+ (values.line1 || values.line2 || values.postal_code || values.state || values.city) &&+ !values.country+ ) {+ errors['country'] = 'Please select a country'+ }+ return errors+ }+const onSubmit = async (values: any, { resetForm }: any) => {if (!slug) return console.error('Slug is required')@@ -84,7 +95,13 @@ const BillingAddress = () => {)}{isSuccess && (- <Form validateOnBlur id={formId} initialValues={initialValues} onSubmit={onSubmit}>+ <Form+ validateOnBlur+ id={formId}+ initialValues={initialValues}+ validate={validate}+ onSubmit={onSubmit}+ >{({ values, initialValues, handleReset, resetForm }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)@@ -132,7 +149,7 @@ const BillingAddress = () => {placeholder="Address line 2"disabled={!canUpdateBillingAddress}/>- <div className="flex items-center space-x-2">+ <div className="flex space-x-2"><ListboxclassName="w-full"id="country"@@ -161,7 +178,7 @@ const BillingAddress = () => {disabled={!canUpdateBillingAddress}/></div>- <div className="flex items-center space-x-2">+ <div className="flex space-x-2"><InputclassName="w-full"id="city"