mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
- Mandatory address input when adding a new payment method - Removed the global HCaptcha store that wasn't used consistently and would sometimes block payment method changes - Remove the custom billing address data & tax id form on org creation and plan upgrades in favour of Stripe's `AddressElement` - Unify usage of the Stripe payment elements into a single component - Customers can mark "Purchasing as a business" and will then be able to put down a tax id - Adjusted billing address form to have better labels + tax id is filtered down to selected country - Adjusted Stripe Elements styling to use floating labels (otherwise very hard to use with address element) + additional styling changes - New flag to filter out payment methods that do not have an address for org upgrades and credit top ups, this will be enforced a few days after rolling this out - Added Google Maps Places API integration for address auto-completion via Stripe AddressElement - Upgraded Stripe dependencies - Slight adjustments to styling of plan upgrade modal
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { useIsLoggedIn, useParams } from 'common'
|
|
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
|
|
import { useMemo } from 'react'
|
|
|
|
import { useProjectByRef, useProjectByRefQuery } from './useSelectedProject'
|
|
|
|
/**
|
|
* @deprecated Use useSelectedOrganizationQuery instead for access to loading states etc
|
|
*
|
|
* Example migration:
|
|
* ```
|
|
* // Old:
|
|
* const organization = useSelectedOrganization()
|
|
*
|
|
* // New:
|
|
* const { data: organization } = useSelectedOrganizationQuery()
|
|
* ```
|
|
*/
|
|
export function useSelectedOrganization({ enabled = true } = {}) {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
const { ref, slug } = useParams()
|
|
const { data } = useOrganizationsQuery({ enabled: isLoggedIn && enabled })
|
|
|
|
const selectedProject = useProjectByRef(ref)
|
|
|
|
return useMemo(() => {
|
|
return data?.find((org) => {
|
|
if (slug !== undefined) return org.slug === slug
|
|
if (selectedProject !== undefined) return org.id === selectedProject.organization_id
|
|
return undefined
|
|
})
|
|
}, [data, selectedProject, slug])
|
|
}
|
|
|
|
export function useSelectedOrganizationQuery({ enabled = true } = {}) {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
const { ref, slug } = useParams()
|
|
const { data: selectedProject } = useProjectByRefQuery(ref)
|
|
|
|
return useOrganizationsQuery({
|
|
enabled: isLoggedIn && enabled,
|
|
select: (data) => {
|
|
return data.find((org) => {
|
|
if (slug !== undefined) return org.slug === slug
|
|
if (selectedProject !== undefined) return org.id === selectedProject.organization_id
|
|
return undefined
|
|
})
|
|
},
|
|
})
|
|
}
|