The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: adapt to new v2 customer update endpoint (#27081)
Kevin Grüneberg6f708d3f6204
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsxindex 95029f72ca3..83e744ec2bf 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx@@ -48,14 +48,22 @@ const BillingAddress = () => {) {errors['country'] = 'Please select a country'}+ if (+ (values.country || values.line2 || values.postal_code || values.state || values.city) &&+ !values.line1+ ) {+ errors['line1'] = 'Please provide an address line'+ }return errors}const onSubmit = async (values: any, { resetForm }: any) => {if (!slug) return console.error('Slug is required')+ const address = !values.line1 ? null : values+updateCustomerProfile(- { slug, address: values },+ { slug, address },{onSuccess: () => {toast.success('Successfully updated billing address')diff --git a/apps/studio/data/organizations/organization-customer-profile-update-mutation.ts b/apps/studio/data/organizations/organization-customer-profile-update-mutation.tsindex e6bb9e9a7e6..0bf018a7cfb 100644--- a/apps/studio/data/organizations/organization-customer-profile-update-mutation.ts+++ b/apps/studio/data/organizations/organization-customer-profile-update-mutation.ts@@ -1,20 +1,14 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import { toast } from 'react-hot-toast'-import { handleError, patch } from 'data/fetchers'+import { put, handleError } from 'data/fetchers'import type { ResponseError } from 'types'import { organizationKeys } from './keys'+import { components } from 'api-types'export type OrganizationCustomerProfileUpdateVariables = {slug: string- address?: {- city: string | null- country: string | null- line1: string | null- line2: string | null- postal_code: string | null- state: string | null- } | null+ address?: components['schemas']['CustomerBillingAddress']}export async function updateOrganizationCustomerProfile({@@ -26,13 +20,13 @@ export async function updateOrganizationCustomerProfile({const payload: any = {}if (address) payload.address = address- const { data, error } = await patch(`/platform/organizations/{slug}/customer`, {- body: payload,+ const { data, error } = await put(`/platform/organizations/{slug}/customer`, {params: {path: {slug,},},+ body: { address },})if (error) throw handleError(error)return data@@ -62,8 +56,17 @@ export const useOrganizationCustomerProfileUpdateMutation = ({OrganizationCustomerProfileUpdateVariables>((vars) => updateOrganizationCustomerProfile(vars), {async onSuccess(data, variables, context) {- const { slug } = variables- await queryClient.invalidateQueries(organizationKeys.customerProfile(slug))+ const { address, slug } = variables++ // We do not invalidate here as GET endpoint data is stale for 1-2 seconds, so we handle state manually+ queryClient.setQueriesData(organizationKeys.customerProfile(slug), (prev: any) => {+ if (!prev) return prev+ return {+ ...prev,+ address,+ }+ })+await onSuccess?.(data, variables, context)},async onError(data, variables, context) {diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 66e3d4d550a..d2c6d209729 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -155,6 +155,8 @@ export interface paths {'/platform/organizations/{slug}/customer': {/** Gets the Stripe customer */get: operations['CustomerController_getCustomer']+ /** Updates the billing customer */+ put: operations['updateCustomerV2']/** Updates the Stripe customer */patch: operations['CustomerController_updateCustomer']}@@ -2555,12 +2557,12 @@ export interface components {opt_in_tags: string[]}CustomerBillingAddress: {- city: string | null- country: string | null- line1: string | null- line2: string | null- postal_code: string | null- state: string | null+ city?: string+ country: string+ line1: string+ line2?: string+ postal_code?: string+ state?: string}CustomerResponse: {email: string@@ -2569,6 +2571,9 @@ export interface components {invoice_settings: Record<string, never>billing_via_partner: boolean}+ BillingCustomerUpdateBody: {+ address?: components['schemas']['CustomerBillingAddress']+ }CustomerUpdateResponse: {id: stringobject: string@@ -6851,6 +6856,32 @@ export interface operations {}}}+ /** Updates the billing customer */+ updateCustomerV2: {+ parameters: {+ path: {+ /** @description Organization slug */+ slug: string+ }+ }+ requestBody: {+ content: {+ 'application/json': components['schemas']['BillingCustomerUpdateBody']+ }+ }+ responses: {+ 200: {+ content: never+ }+ 403: {+ content: never+ }+ /** @description Failed to update the billing customer */+ 500: {+ content: never+ }+ }+ }/** Updates the Stripe customer */CustomerController_updateCustomer: {parameters: {