File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
app/(app)/dashboard/(components) Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import { Textarea } from '@/components/ui/textarea'
4343import axios from 'axios'
4444import { useSession } from 'next-auth/react'
4545import { Routes } from '@/config/routes'
46+ import { polarCustomerPortalRequestUrl } from '@/config/external-links'
4647import {
4748 Tooltip ,
4849 TooltipContent ,
@@ -448,7 +449,7 @@ export default function AccountSettings() {
448449 </ Link >
449450 ) : (
450451 < Link
451- href = 'https://polar.sh/textbee/portal/'
452+ href = { polarCustomerPortalRequestUrl ( currentUser ?. email ) }
452453 className = 'text-xs font-medium bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 px-3 py-1.5 rounded-md transition-colors'
453454 >
454455 Manage Subscription →
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Spinner } from '@/components/ui/spinner'
66import { useQuery } from '@tanstack/react-query'
77import httpBrowserClient from '@/lib/httpBrowserClient'
88import { ApiEndpoints } from '@/config/api'
9+ import { polarCustomerPortalRequestUrl } from '@/config/external-links'
910import Link from 'next/link'
1011import {
1112 Tooltip ,
@@ -27,6 +28,14 @@ export default function SubscriptionInfo() {
2728 . then ( ( res ) => res . data ) ,
2829 } )
2930
31+ const { data : currentUser } = useQuery ( {
32+ queryKey : [ 'currentUser' ] ,
33+ queryFn : ( ) =>
34+ httpBrowserClient
35+ . get ( ApiEndpoints . auth . whoAmI ( ) )
36+ . then ( ( res ) => res . data ?. data ) ,
37+ } )
38+
3039 // Format price with currency symbol
3140 const formatPrice = (
3241 amount : number | null | undefined ,
@@ -254,7 +263,7 @@ export default function SubscriptionInfo() {
254263 </ Link >
255264 ) : (
256265 < Link
257- href = 'https://polar.sh/textbee/portal/'
266+ href = { polarCustomerPortalRequestUrl ( currentUser ?. email ) }
258267 className = 'text-sm font-medium text-white bg-brand-600 hover:bg-brand-700 px-4 py-2 rounded-md transition-colors'
259268 >
260269 Manage Subscription →
Original file line number Diff line number Diff line change 1+ const POLAR_CUSTOMER_PORTAL_REQUEST_BASE =
2+ 'https://polar.sh/textbee/portal/request'
3+
4+ export function polarCustomerPortalRequestUrl (
5+ email ?: string | null
6+ ) : string {
7+ const trimmed = email ?. trim ( )
8+ if ( ! trimmed ) return POLAR_CUSTOMER_PORTAL_REQUEST_BASE
9+ return `${ POLAR_CUSTOMER_PORTAL_REQUEST_BASE } ?email=${ encodeURIComponent ( trimmed ) } `
10+ }
11+
112export const ExternalLinks = {
213 patreon : 'https://patreon.com/vernu' ,
314 github : 'https://github.com/vernu/textbee' ,
You can’t perform that action at this time.
0 commit comments