customProviders.utils.ts 1.4 KB

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