customProviders.utils.ts44 lines · main
| 1 | import type { CustomOAuthProvider } from '@supabase/auth-js' |
| 2 | |
| 3 | /** Next plan to upgrade to for more custom providers: Free → Pro, Pro → Team */ |
| 4 | export function getNextPlanForCustomProviders(planId: string | undefined): 'Pro' | 'Team' | null { |
| 5 | if (planId === 'free') return 'Pro' |
| 6 | if (planId === 'pro') return 'Team' |
| 7 | return null |
| 8 | } |
| 9 | |
| 10 | export const CUSTOM_PROVIDER_TYPE_OPTIONS = [ |
| 11 | { name: 'OIDC', value: 'oidc', icon: null }, |
| 12 | { name: 'OAuth2', value: 'oauth2', icon: null }, |
| 13 | ] |
| 14 | |
| 15 | export const CUSTOM_PROVIDER_ENABLED_OPTIONS = [ |
| 16 | { name: 'Enabled', value: 'true', icon: null }, |
| 17 | { name: 'Disabled', value: 'false', icon: null }, |
| 18 | ] |
| 19 | |
| 20 | export function filterCustomProviders({ |
| 21 | providers, |
| 22 | searchString, |
| 23 | providerTypes, |
| 24 | enabledStatuses, |
| 25 | }: { |
| 26 | providers: CustomOAuthProvider[] |
| 27 | searchString: string |
| 28 | providerTypes: string[] |
| 29 | enabledStatuses: string[] |
| 30 | }) { |
| 31 | return providers.filter((provider) => { |
| 32 | const matchesSearch = |
| 33 | searchString === '' || |
| 34 | provider.name.toLowerCase().includes(searchString.toLowerCase()) || |
| 35 | provider.identifier.toLowerCase().includes(searchString.toLowerCase()) |
| 36 | |
| 37 | const matchesType = providerTypes.length === 0 || providerTypes.includes(provider.provider_type) |
| 38 | |
| 39 | const matchesEnabled = |
| 40 | enabledStatuses.length === 0 || enabledStatuses.includes(provider.enabled ? 'true' : 'false') |
| 41 | |
| 42 | return matchesSearch && matchesType && matchesEnabled |
| 43 | }) |
| 44 | } |