diff --git a/clients/apps/web/src/app/(main)/(topbar)/(backer)/settings/page.tsx b/clients/apps/web/src/app/(main)/(topbar)/(backer)/settings/page.tsx index a7578827e4..266e9f26e3 100644 --- a/clients/apps/web/src/app/(main)/(topbar)/(backer)/settings/page.tsx +++ b/clients/apps/web/src/app/(main)/(topbar)/(backer)/settings/page.tsx @@ -2,7 +2,6 @@ import AccessTokensSettings from '@/components/Settings/AccessTokensSettings' import AuthenticationSettings from '@/components/Settings/AuthenticationSettings' -import ConnectedAppSettings from '@/components/Settings/ConnectedAppSettings' import GeneralSettings from '@/components/Settings/GeneralSettings' import OAuthSettings from '@/components/Settings/OAuth/OAuthSettings' import PaymentMethodSettings from '@/components/Settings/PaymentMethodSettings' @@ -25,14 +24,6 @@ export default function Page() { -
- - -
-
= ({ - icon, - title, - subtitle, - action, - error, -}) => { - return ( -
-
{icon}
-
-
{title}
-
- {subtitle} -
- {error && ( -
{error}
- )} -
-
{action}
-
- ) -} - -interface DiscordConnectedAppProps { - oauthAccount: OAuthAccountRead | undefined - returnTo: string -} - -const DiscordConnectedApp: React.FC = ({ - oauthAccount, - returnTo, -}) => { - const authorizeURL = getUserDiscordAuthorizeURL({ returnTo }) - const searchParams = useSearchParams() - - const callback = useMemo(() => searchParams.get('callback'), [searchParams]) - const error = useMemo(() => searchParams.get('error'), [searchParams]) - - return ( - - - - - - } - title={ - oauthAccount ? ( - <> - {oauthAccount.account_username ? ( - <> - {oauthAccount.account_username} ({oauthAccount.account_email}) - - ) : ( - oauthAccount.account_email - )} - - ) : ( - 'Connect Discord' - ) - } - subtitle={ - oauthAccount - ? 'Your Discord account is connected.' - : 'Sign in with your Discord account to enable your benefits, like access to private Discord servers.' - } - action={ - <> - {oauthAccount && ( -
- Connected{' '} - -
- )} - {!oauthAccount && ( - - )} - - } - error={callback === 'discord' && error !== null ? error : undefined} - /> - ) -} - -const ConnectedAppSettings = () => { - const { currentUser, reloadUser } = useAuth() - const pathname = usePathname() - const discordAccount = useDiscordAccount() - - // Force to reload the user to make sure we have fresh data after connecting an app - useEffect(() => { - reloadUser() - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - - return ( - <> - {currentUser && ( - - - - - - )} - - ) -} - -export default ConnectedAppSettings diff --git a/clients/apps/web/src/utils/auth.ts b/clients/apps/web/src/utils/auth.ts index fb2b0ec8ad..a008f7235b 100644 --- a/clients/apps/web/src/utils/auth.ts +++ b/clients/apps/web/src/utils/auth.ts @@ -1,12 +1,11 @@ import { getServerURL } from '@/utils/api' import { IntegrationsDiscordApiIntegrationsDiscordBotAuthorizeRequest, - IntegrationsDiscordApiIntegrationsDiscordUserAuthorizeRequest, IntegrationsGithubApiIntegrationsGithubAuthorizeRequest, IntegrationsGithubApiRedirectToOrganizationInstallationRequest, IntegrationsGithubRepositoryBenefitApiIntegrationsGithubRepositoryBenefitUserAuthorizeRequest, IntegrationsGoogleApiIntegrationsGoogleAuthorizeRequest, - MagicLinkApiMagicLinkAuthenticateRequest + MagicLinkApiMagicLinkAuthenticateRequest, } from '@polar-sh/sdk' export const getGitHubAuthorizeURL = ( @@ -60,16 +59,6 @@ export const getMagicLinkAuthenticateURL = ( return `${getServerURL()}/v1/magic_link/authenticate?${searchParams}` } -export const getUserDiscordAuthorizeURL = ( - params: IntegrationsDiscordApiIntegrationsDiscordUserAuthorizeRequest, -): string => { - const searchParams = new URLSearchParams() - if (params.returnTo !== undefined) { - searchParams.set('return_to', params.returnTo) - } - return `${getServerURL()}/v1/integrations/discord/user/authorize?${searchParams}` -} - export const getBotDiscordAuthorizeURL = ( params: IntegrationsDiscordApiIntegrationsDiscordBotAuthorizeRequest, ): string => {